[autotests] Wrap integration tests in dbus-session-run

Each test needs a dedicated dbus session as the test needs to register
services (e.g. kglobalaccel) and might fail if that cannot be registered.

Due to the wrapping in another command the test need to make sure that
any process they start terminates before them. E.g. the activities test
must stop kactivitymanagerd in cleanupTestCase, otherwise the test times
out.
icc-effect-5.14.5
Martin Gräßlin 2016-09-14 07:59:14 +02:00
parent a69300f762
commit bf7c670444
2 changed files with 7 additions and 1 deletions

View File

@ -11,7 +11,7 @@ function(integrationTest)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_executable(${ARGS_NAME} ${ARGS_SRCS})
target_link_libraries(${ARGS_NAME} KWinIntegrationTestFramework kwin Qt5::Test ${ARGS_LIBS})
add_test(kwin-${ARGS_NAME} ${ARGS_NAME})
add_test(NAME kwin-${ARGS_NAME} COMMAND dbus-run-session ${CMAKE_CURRENT_BINARY_DIR}/${ARGS_NAME})
endfunction()
integrationTest(NAME testStart SRCS start_test.cpp)

View File

@ -44,6 +44,7 @@ class ActivitiesTest : public QObject
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
void testSetOnActivitiesValidates();
@ -72,6 +73,11 @@ void ActivitiesTest::initTestCase()
waylandServer()->initWorkspace();
}
void ActivitiesTest::cleanupTestCase()
{
QProcess::execute(QStringLiteral("kactivitymanagerd"), QStringList{QStringLiteral("stop")});
}
void ActivitiesTest::init()
{
screens()->setCurrent(0);