Commit 1c61e611 authored by Martin Flöser's avatar Martin Flöser

[autotests] Support new way to run the tests without need to install

Summary:
KWin was quite good in ensuring that you don't need to install by
passing paths to the tests. The new way is much nicer, so code is
adjusted for the new way. Also if we require a newer ECM in future we
need to support the new way.

No guarantee that the tests don't pick something up from the system env,
that needs more testing.

References: https://community.kde.org/Guidelines_and_HOWTOs/Making_apps_run_uninstalled

Test Plan: The tests which loaded helpers pass

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7543
parent f8be3f74
......@@ -9,7 +9,7 @@ set(KF5_MIN_VERSION "5.34.0")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH} )
find_package(ECM 0.0.11 REQUIRED NO_MODULE)
find_package(ECM 5.38 REQUIRED NO_MODULE)
include(FeatureSummary)
include(WriteBasicConfigVersionFile)
......
......@@ -17,7 +17,7 @@ add_subdirectory(tabbox)
set( testScreenPaintData_SRCS test_screen_paint_data.cpp )
add_executable(testScreenPaintData ${testScreenPaintData_SRCS})
target_link_libraries( testScreenPaintData kwineffects Qt5::Test Qt5::Widgets KF5::WindowSystem)
add_test(kwin-testScreenPaintData testScreenPaintData)
add_test(NAME kwin-testScreenPaintData COMMAND testScreenPaintData)
ecm_mark_as_test(testScreenPaintData)
########################################################
......@@ -26,7 +26,7 @@ ecm_mark_as_test(testScreenPaintData)
set( testWindowPaintData_SRCS test_window_paint_data.cpp )
add_executable(testWindowPaintData ${testWindowPaintData_SRCS})
target_link_libraries( testWindowPaintData kwineffects Qt5::Widgets Qt5::Test )
add_test(kwin-testWindowPaintData testWindowPaintData)
add_test(NAME kwin-testWindowPaintData COMMAND testWindowPaintData)
ecm_mark_as_test(testWindowPaintData)
########################################################
......@@ -46,7 +46,7 @@ target_link_libraries( testVirtualDesktops
KF5::ConfigCore
KF5::WindowSystem
)
add_test(kwin-testVirtualDesktops testVirtualDesktops)
add_test(NAME kwin-testVirtualDesktops COMMAND testVirtualDesktops)
ecm_mark_as_test(testVirtualDesktops)
########################################################
......@@ -70,7 +70,7 @@ target_link_libraries( testClientMachine
XCB::XFIXES
${X11_X11_LIB} # to make jenkins happy
)
add_test(kwin-testClientMachine testClientMachine)
add_test(NAME kwin-testClientMachine COMMAND testClientMachine)
ecm_mark_as_test(testClientMachine)
########################################################
......@@ -89,7 +89,7 @@ target_link_libraries( testXcbWrapper
KF5::WindowSystem
XCB::XCB
)
add_test(kwin-testXcbWrapper testXcbWrapper)
add_test(NAME kwin-testXcbWrapper COMMAND testXcbWrapper)
ecm_mark_as_test(testXcbWrapper)
if (XCB_ICCCM_FOUND)
......@@ -104,7 +104,7 @@ if (XCB_ICCCM_FOUND)
XCB::XCB
XCB::ICCCM
)
add_test(kwin-testXcbSizeHints testXcbSizeHints)
add_test(NAME kwin-testXcbSizeHints COMMAND testXcbSizeHints)
ecm_mark_as_test(testXcbSizeHints)
endif()
......@@ -124,7 +124,7 @@ target_link_libraries( testXcbWindow
KF5::WindowSystem
XCB::XCB
)
add_test(kwin-testXcbWindow testXcbWindow)
add_test(NAME kwin-testXcbWindow COMMAND testXcbWindow)
ecm_mark_as_test(testXcbWindow)
########################################################
......@@ -147,7 +147,7 @@ target_link_libraries(testBuiltInEffectLoader
kwin4_effect_builtins
)
add_test(kwin-testBuiltInEffectLoader testBuiltInEffectLoader)
add_test(NAME kwin-testBuiltInEffectLoader COMMAND testBuiltInEffectLoader)
ecm_mark_as_test(testBuiltInEffectLoader)
########################################################
......@@ -186,7 +186,7 @@ target_link_libraries(testScriptedEffectLoader
kwin4_effect_builtins
)
add_test(kwin-testScriptedEffectLoader testScriptedEffectLoader)
add_test(NAME kwin-testScriptedEffectLoader COMMAND testScriptedEffectLoader)
ecm_mark_as_test(testScriptedEffectLoader)
########################################################
......@@ -208,7 +208,7 @@ target_link_libraries(testPluginEffectLoader
kwin4_effect_builtins
)
add_test(kwin-testPluginEffectLoader testPluginEffectLoader)
add_test(NAME kwin-testPluginEffectLoader COMMAND testPluginEffectLoader)
ecm_mark_as_test(testPluginEffectLoader)
########################################################
......@@ -254,7 +254,7 @@ target_link_libraries(testScreens
KF5::WindowSystem
)
add_test(kwin_testScreens testScreens)
add_test(NAME kwin_testScreens COMMAND testScreens)
ecm_mark_as_test(testScreens)
########################################################
......@@ -293,7 +293,7 @@ target_link_libraries( testXRandRScreens
XCB::SHM
)
add_test(kwin-testXRandRScreens testXRandRScreens)
add_test(NAME kwin-testXRandRScreens COMMAND testXRandRScreens)
ecm_mark_as_test(testXRandRScreens)
########################################################
......@@ -341,7 +341,7 @@ target_link_libraries(testScreenEdges
XCB::SHM
)
add_test(kwin_testScreenEdges testScreenEdges)
add_test(NAME kwin_testScreenEdges COMMAND testScreenEdges)
ecm_mark_as_test(testScreenEdges)
########################################################
......@@ -361,7 +361,7 @@ target_link_libraries(testOnScreenNotification
KF5::ConfigCore
)
add_test(kwin-testOnScreenNotification testOnScreenNotification)
add_test(NAME kwin-testOnScreenNotification COMMAND testOnScreenNotification)
ecm_mark_as_test(testOnScreenNotification)
########################################################
......@@ -377,20 +377,19 @@ target_link_libraries(testGestures
Qt5::Test
)
add_test(kwin-testGestures testGestures)
add_test(NAME kwin-testGestures COMMAND testGestures)
ecm_mark_as_test(testGestures)
########################################################
# Test X11 TimestampUpdate
########################################################
add_executable(testX11TimestampUpdate test_x11_timestamp_update.cpp)
target_compile_definitions(testX11TimestampUpdate PRIVATE KWINBACKENDPATH="${CMAKE_BINARY_DIR}/plugins/platforms/x11/standalone/KWinX11Platform.so")
target_link_libraries(testX11TimestampUpdate
Qt5::Test
KF5::CoreAddons
kwin
)
add_test(kwin-testX11TimestampUpdate testX11TimestampUpdate)
add_test(NAME kwin-testX11TimestampUpdate COMMAND testX11TimestampUpdate)
ecm_mark_as_test(testX11TimestampUpdate)
set(testOpenGLContextAttributeBuilder_SRCS
......@@ -404,7 +403,7 @@ if(HAVE_EPOXY_GLX)
endif()
add_executable(testOpenGLContextAttributeBuilder ${testOpenGLContextAttributeBuilder_SRCS})
target_link_libraries(testOpenGLContextAttributeBuilder Qt5::Test)
add_test(kwin-testOpenGLContextAttributeBuilder testOpenGLContextAttributeBuilder)
add_test(NAME kwin-testOpenGLContextAttributeBuilder COMMAND testOpenGLContextAttributeBuilder)
ecm_mark_as_test(testOpenGLContextAttributeBuilder)
set(testXkb_SRCS
......@@ -421,13 +420,13 @@ target_link_libraries(testXkb
KF5::WaylandServer
XKB::XKB
)
add_test(kwin-testXkb testXkb)
add_test(NAME kwin-testXkb COMMAND testXkb)
ecm_mark_as_test(testXkb)
if(HAVE_GBM)
add_executable(testGbmSurface test_gbm_surface.cpp ../plugins/platforms/drm/gbm_surface.cpp)
target_link_libraries(testGbmSurface Qt5::Test)
add_test(kwin-testGbmSurface testGbmSurface)
add_test(NAME kwin-testGbmSurface COMMAND testGbmSurface)
ecm_mark_as_test(testGbmSurface)
endif()
......@@ -436,6 +435,6 @@ target_link_libraries(testVirtualKeyboardDBus
Qt5::Test
Qt5::DBus
)
add_test(kwin-testVirtualKeyboardDBus testVirtualKeyboardDBus)
add_test(NAME kwin-testVirtualKeyboardDBus COMMAND testVirtualKeyboardDBus)
ecm_mark_as_test(testVirtualKeyboardDBus)
......@@ -19,7 +19,7 @@ function(drmTest)
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_executable(${ARGS_NAME} ${ARGS_SRCS})
target_link_libraries(${ARGS_NAME} mockDrm Qt5::Test)
add_test(kwin-drm-${ARGS_NAME} ${ARGS_NAME})
add_test(NAME kwin-drm-${ARGS_NAME} COMMAND ${ARGS_NAME})
ecm_mark_as_test(${ARGS_NAME})
endfunction()
......
add_definitions(-DKWINBACKENDPATH="${CMAKE_BINARY_DIR}/plugins/platforms/virtual/KWinWaylandVirtualBackend.so")
add_definitions(-DKWINQPAPATH="${CMAKE_BINARY_DIR}/plugins/qpa/")
add_subdirectory(helper)
add_library(KWinIntegrationTestFramework STATIC kwin_wayland_test.cpp test_helpers.cpp)
......@@ -12,12 +10,12 @@ function(integrationTest)
cmake_parse_arguments(ARGS "${optionArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_executable(${ARGS_NAME} ${ARGS_SRCS})
target_link_libraries(${ARGS_NAME} KWinIntegrationTestFramework kwin Qt5::Test ${ARGS_LIBS})
add_test(NAME kwin-${ARGS_NAME} COMMAND dbus-run-session ${CMAKE_CURRENT_BINARY_DIR}/${ARGS_NAME})
add_test(NAME kwin-${ARGS_NAME} COMMAND dbus-run-session ${CMAKE_BINARY_DIR}/bin/${ARGS_NAME})
if (${ARGS_WAYLAND_ONLY})
add_executable(${ARGS_NAME}_waylandonly ${ARGS_SRCS})
set_target_properties(${ARGS_NAME}_waylandonly PROPERTIES COMPILE_DEFINITIONS "NO_XWAYLAND")
target_link_libraries(${ARGS_NAME}_waylandonly KWinIntegrationTestFramework kwin Qt5::Test ${ARGS_LIBS})
add_test(NAME kwin-${ARGS_NAME}-waylandonly COMMAND dbus-run-session ${CMAKE_CURRENT_BINARY_DIR}/${ARGS_NAME}_waylandonly)
add_test(NAME kwin-${ARGS_NAME}-waylandonly COMMAND dbus-run-session ${CMAKE_BINARY_DIR}/bin/${ARGS_NAME}_waylandonly)
endif()
endfunction()
......
......@@ -52,7 +52,7 @@ WaylandTestApplication::WaylandTestApplication(OperationMode mode, int &argc, ch
setUseKActivities(false);
#endif
qputenv("KWIN_COMPOSE", QByteArrayLiteral("Q"));
initPlatform(KPluginMetaData(QStringLiteral(KWINBACKENDPATH)));
initPlatform(KPluginMetaData(QStringLiteral("KWinWaylandVirtualBackend.so")));
WaylandServer::create(this);
}
......
......@@ -176,11 +176,14 @@ Q_DECLARE_METATYPE(KWin::Test::ShellSurfaceType)
int main(int argc, char *argv[]) \
{ \
setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); \
setenv("QT_QPA_PLATFORM_PLUGIN_PATH", KWINQPAPATH, true); \
setenv("QT_QPA_PLATFORM_PLUGIN_PATH", QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath().toLocal8Bit().constData(), true); \
setenv("KWIN_FORCE_OWN_QPA", "1", true); \
DPI; \
KWin::WaylandTestApplication app(OperationMode, argc, argv); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
const auto ownPath = app.libraryPaths().last(); \
app.removeLibraryPath(ownPath); \
app.addLibraryPath(ownPath); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
......
......@@ -871,7 +871,7 @@ void TestShellClient::testUnresponsiveWindow()
{
// this test verifies that killWindow properly terminates a process
// for this an external binary is launched
const QString kill = QFINDTESTDATA(QStringLiteral("helper/kill"));
const QString kill = QFINDTESTDATA(QStringLiteral("kill"));
QVERIFY(!kill.isEmpty());
QSignalSpy shellClientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded);
QVERIFY(shellClientAddedSpy.isValid());
......
......@@ -97,9 +97,9 @@ void XClipboardSyncTest::testSync_data()
void XClipboardSyncTest::testSync()
{
// this test verifies the syncing of X11 to Wayland clipboard
const QString copy = QFINDTESTDATA(QStringLiteral("helper/copy"));
const QString copy = QFINDTESTDATA(QStringLiteral("copy"));
QVERIFY(!copy.isEmpty());
const QString paste = QFINDTESTDATA(QStringLiteral("helper/paste"));
const QString paste = QFINDTESTDATA(QStringLiteral("paste"));
QVERIFY(!paste.isEmpty());
QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
......
......@@ -6,7 +6,7 @@ include_directories(${UDEV_INCLUDE_DIR})
set( testLibinputDevice_SRCS device_test.cpp mock_libinput.cpp ../../libinput/device.cpp )
add_executable(testLibinputDevice ${testLibinputDevice_SRCS})
target_link_libraries( testLibinputDevice Qt5::Test Qt5::DBus KF5::ConfigCore)
add_test(kwin-testLibinputDevice testLibinputDevice)
add_test(NAME kwin-testLibinputDevice COMMAND testLibinputDevice)
ecm_mark_as_test(testLibinputDevice)
########################################################
......@@ -20,7 +20,7 @@ set( testLibinputKeyEvent_SRCS
)
add_executable(testLibinputKeyEvent ${testLibinputKeyEvent_SRCS})
target_link_libraries( testLibinputKeyEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputKeyEvent testLibinputKeyEvent)
add_test(NAME kwin-testLibinputKeyEvent COMMAND testLibinputKeyEvent)
ecm_mark_as_test(testLibinputKeyEvent)
########################################################
......@@ -34,7 +34,7 @@ set( testLibinputPointerEvent_SRCS
)
add_executable(testLibinputPointerEvent ${testLibinputPointerEvent_SRCS})
target_link_libraries( testLibinputPointerEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputPointerEvent testLibinputPointerEvent)
add_test(NAME kwin-testLibinputPointerEvent COMMAND testLibinputPointerEvent)
ecm_mark_as_test(testLibinputPointerEvent)
########################################################
......@@ -48,7 +48,7 @@ set( testLibinputTouchEvent_SRCS
)
add_executable(testLibinputTouchEvent ${testLibinputTouchEvent_SRCS})
target_link_libraries( testLibinputTouchEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputTouchEvent testLibinputTouchEvent)
add_test(NAME kwin-testLibinputTouchEvent COMMAND testLibinputTouchEvent)
ecm_mark_as_test(testLibinputTouchEvent)
########################################################
......@@ -62,7 +62,7 @@ set( testLibinputGestureEvent_SRCS
)
add_executable(testLibinputGestureEvent ${testLibinputGestureEvent_SRCS})
target_link_libraries( testLibinputGestureEvent Qt5::Test Qt5::DBus Qt5::Widgets KF5::ConfigCore)
add_test(kwin-testLibinputGestureEvent testLibinputGestureEvent)
add_test(NAME kwin-testLibinputGestureEvent COMMAND testLibinputGestureEvent)
ecm_mark_as_test(testLibinputGestureEvent)
########################################################
......@@ -86,7 +86,7 @@ target_link_libraries( testLibinputContext
KF5::ConfigCore
KF5::WindowSystem
)
add_test(kwin-testLibinputContext testLibinputContext)
add_test(NAME kwin-testLibinputContext COMMAND testLibinputContext)
ecm_mark_as_test(testLibinputContext)
########################################################
......@@ -95,5 +95,5 @@ ecm_mark_as_test(testLibinputContext)
set( testInputEvents_SRCS input_event_test.cpp mock_libinput.cpp ../../libinput/device.cpp ../../input_event.cpp )
add_executable(testInputEvents ${testInputEvents_SRCS})
target_link_libraries( testInputEvents Qt5::Test Qt5::DBus Qt5::Gui KF5::ConfigCore)
add_test(kwin-testInputEvents testInputEvents)
add_test(NAME kwin-testInputEvents COMMAND testInputEvents)
ecm_mark_as_test(testInputEvents)
......@@ -3,7 +3,7 @@ include(ECMMarkAsTest)
macro(KWINEFFECTS_UNIT_TESTS)
foreach(_testname ${ARGN})
add_executable(${_testname} ${_testname}.cpp)
add_test(kwineffects-${_testname} ${_testname})
add_test(NAME kwineffects-${_testname} COMMAND ${_testname})
target_link_libraries(${_testname} Qt5::Test kwineffects)
ecm_mark_as_test(${_testname})
endforeach()
......@@ -14,6 +14,6 @@ kwineffects_unit_tests(
)
add_executable(kwinglplatformtest kwinglplatformtest.cpp mock_gl.cpp ../../libkwineffects/kwinglplatform.cpp)
add_test(kwineffects-kwinglplatformtest kwinglplatformtest)
add_test(NAME kwineffects-kwinglplatformtest COMMAND kwinglplatformtest)
target_link_libraries(kwinglplatformtest Qt5::Test Qt5::Gui Qt5::X11Extras KF5::ConfigCore XCB::XCB)
ecm_mark_as_test(kwinglplatformtest)
add_executable(blendPictureTest blendpicture_test.cpp)
set_target_properties(blendPictureTest PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
add_test(xrenderutils-blendPictureTest blendPictureTest)
add_test(NAME xrenderutils-blendPictureTest COMMAND blendPictureTest)
target_link_libraries(blendPictureTest
kwinxrenderutils
Qt5::Test
......
......@@ -29,7 +29,7 @@ target_link_libraries( testTabBoxClientModel
KF5::WindowSystem
XCB::XCB
)
add_test(kwin-testTabBoxClientModel testTabBoxClientModel)
add_test(NAME kwin-testTabBoxClientModel COMMAND testTabBoxClientModel)
ecm_mark_as_test(testTabBoxClientModel)
########################################################
......@@ -61,7 +61,7 @@ target_link_libraries( testTabBoxHandler
KF5::WindowSystem
XCB::XCB
)
add_test(kwin-testTabBoxHandler testTabBoxHandler)
add_test(NAME kwin-testTabBoxHandler COMMAND testTabBoxHandler)
ecm_mark_as_test(testTabBoxHandler)
########################################################
......@@ -75,7 +75,7 @@ set( testTabBoxConfig_SRCS
add_executable( testTabBoxConfig ${testTabBoxConfig_SRCS} )
target_link_libraries( testTabBoxConfig Qt5::Core Qt5::Test )
add_test(kwin-testTabBoxConfig testTabBoxConfig)
add_test(NAME kwin-testTabBoxConfig COMMAND testTabBoxConfig)
ecm_mark_as_test(testTabBoxConfig)
......@@ -90,5 +90,5 @@ set( testDesktopChain_SRCS
add_executable( testDesktopChain ${testDesktopChain_SRCS} )
target_link_libraries( testDesktopChain Qt5::Core Qt5::Test )
add_test(kwin-testDesktopChain testDesktopChain)
add_test(NAME kwin-testDesktopChain COMMAND testDesktopChain)
ecm_mark_as_test(testDesktopChain)
......@@ -46,7 +46,7 @@ X11TestApplication::X11TestApplication(int &argc, char **argv)
{
setX11Connection(QX11Info::connection());
setX11RootWindow(QX11Info::appRootWindow());
initPlatform(KPluginMetaData(QStringLiteral(KWINBACKENDPATH)));
initPlatform(KPluginMetaData(QStringLiteral("KWinX11Platform.so")));
}
X11TestApplication::~X11TestApplication()
......
......@@ -13,6 +13,7 @@ set(kwin5_aurorae_PART_SRCS
)
add_library(kwin5_aurorae MODULE ${kwin5_aurorae_PART_SRCS})
set_target_properties(kwin5_aurorae PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kdecoration2/")
target_link_libraries(kwin5_aurorae
KDecoration2::KDecoration
......
......@@ -3,6 +3,7 @@ set(kglobalaccel_plugin_SRCS
)
add_library(KF5GlobalAccelPrivateKWin MODULE ${kglobalaccel_plugin_SRCS})
set_target_properties(KF5GlobalAccelPrivateKWin PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kglobalaccel5.platforms/")
target_link_libraries(KF5GlobalAccelPrivateKWin
KF5::GlobalAccelPrivate
kwin
......
......@@ -13,6 +13,7 @@ ecm_qt_declare_logging_category(
)
add_library(KWinSceneOpenGL MODULE scene_opengl.cpp)
set_target_properties(KWinSceneOpenGL PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kwin.scenes/")
target_link_libraries(KWinSceneOpenGL
kwin
SceneOpenGLBackend
......
set(SCENE_QPAINTER_SRCS scene_qpainter.cpp)
add_library(KWinSceneQPainter MODULE scene_qpainter.cpp)
set_target_properties(KWinSceneQPainter PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kwin.scenes/")
target_link_libraries(KWinSceneQPainter
kwin
SceneQPainterBackend
......
......@@ -13,6 +13,7 @@ ecm_qt_declare_logging_category(
)
add_library(KWinSceneXRender MODULE ${SCENE_XRENDER_SRCS})
set_target_properties(KWinSceneXRender PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kwin.scenes/")
target_link_libraries(KWinSceneXRender
kwin
kwinxrenderutils
......
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