From bf7c67044440392249f324e6088656f4b3c0b9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 14 Sep 2016 07:59:14 +0200 Subject: [PATCH] [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. --- autotests/integration/CMakeLists.txt | 2 +- autotests/integration/activities_test.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/autotests/integration/CMakeLists.txt b/autotests/integration/CMakeLists.txt index 456188ec8a..a172e68282 100644 --- a/autotests/integration/CMakeLists.txt +++ b/autotests/integration/CMakeLists.txt @@ -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) diff --git a/autotests/integration/activities_test.cpp b/autotests/integration/activities_test.cpp index 4e3c69ed97..1acfead397 100644 --- a/autotests/integration/activities_test.cpp +++ b/autotests/integration/activities_test.cpp @@ -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);