Commit 2682aee9 authored by Heiko Becker's avatar Heiko Becker Committed by Heiko Becker
Browse files

Port test to Qt5/KF5 and make it use Qt Test

It was disabled in 2011 when doing some dbus related changes.
Fortunately, kmix is organized in libraries nowadays and it's much
easier and quicker to build the test.

To be honest I'm not entirely sure it's a meaningful test, though,
but I guess it's better than nothing.
parent 6b466e52
Pipeline #151712 skipped
......@@ -343,6 +343,15 @@ install(TARGETS kmixctrl ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES desktop/kmixctrl_restore.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
####################################################################################################
########### tests ##################################################################################
####################################################################################################
if(BUILD_TESTING)
find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED)
add_subdirectory(tests)
endif()
####################################################################################################
########### other installs #########################################################################
####################################################################################################
......
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/.. )
set(kmix_adaptor_SRCS)
qt4_add_dbus_adaptor( kmix_adaptor_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/../dbus/org.kde.KMix.Mixer.xml
${CMAKE_CURRENT_SOURCE_DIR}/../dbus/dbusmixerwrapper.cpp DBusMixerWrapper)
########### next target ###############
set(profiletest_SRCS profiletest.cpp )
kde4_add_executable(profiletest ${profiletest_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/../gui/guiprofile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../core/MasterControl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../core/mixer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../core/mixdevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../core/volume.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../backends/mixer_backend.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../core/mixset.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../core/kmixdevicemanager.cpp
${kmix_adaptor_SRCS}
)
target_link_libraries(profiletest ${KDE4_KDECORE_LIBS} ${KDE4_SOLID_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} )
if (HAVE_LIBASOUND2)
target_link_libraries(profiletest ${ASOUND_LIBRARY})
endif (HAVE_LIBASOUND2)
if (PULSEAUDIO_FOUND)
target_link_libraries(profiletest ${PULSEAUDIO_LIBRARY} ${PULSEAUDIO_MAINLOOP_LIBRARY})
endif (PULSEAUDIO_FOUND)
add_executable(profiletest ${profiletest_SRCS})
target_link_libraries(profiletest
kmixgui
Qt5::Core
Qt5::DBus
Qt5::Test
KF5::ConfigCore
KF5::ConfigGui
KF5::I18n
KF5::Solid
)
add_test(NAME profiletest
COMMAND profiletest
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
......@@ -19,37 +19,20 @@
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "../gui/guiprofile.h"
#include "profiletest.h"
#include <QTest>
#include <iostream>
#include "../gui/guiprofile.h"
int main(int argc, char* argv[]) {
void ProfileTest::testReadProfile()
{
GUIProfile* guiprof = new GUIProfile();
char dummyFilename[] = "profiletest.xml";
QString fileName;
if ( argc >=1 && argv[1] != 0 ) {
fileName = argv[1];
}
else {
fileName = dummyFilename;
}
QString fileName = QStringLiteral("profiletest.xml");
bool ok = guiprof->readProfile(fileName);
if ( !ok ) {
std::cerr << "Error: GuiProfile '" << qPrintable(fileName) << "' is NOT ok" << std::endl;
}
else {
std::cout << "GuiProfile '" << qPrintable(fileName) << "' read successfully:\n----------------------\n";
std::cout << (*guiprof) ;
std::cout << "----------------------\n";
}
if ( ok ) {
return 0;
}
else {
return 1;
}
QVERIFY(ok);
}
QTEST_GUILESS_MAIN(ProfileTest)
/*
SPDX-FileCopyrightText: 2022 Heiko Becker <heiko.becker@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
class ProfileTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testReadProfile();
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment