on xenial help sign in
More fixes
commit581f8c9635fb4fb610543632003753eea64c497a authorMichael Terry <michael.terry@canonical.com> dateThu 21 Apr 2016, 09:10 (10 years ago) parent5a702fe
27 files changed+233−100
cmake/modules/QmlTest.cmake+77−28 include/paths.h.in+22 plugins/Ubuntu/Gestures/CMakeLists.txt+1−1 tests/CMakeLists.txt+2−6 tests/mocks/Unity/Application/ApplicationInfo.cpp+1−5 tests/mocks/Unity/CMakeLists.txt+3 tests/mocks/Unity/Indicators/CMakeLists.txt+4 tests/mocks/Unity/Launcher/MockLauncherItem.cpp+2−6 tests/mocks/Unity/fake_scope.cpp+2−2 tests/plugins/AccountsService/CMakeLists.txt+6 tests/plugins/Dash/CMakeLists.txt+12 tests/plugins/GlobalShortcut/CMakeLists.txt+10−1 tests/plugins/Greeter/Unity/Launcher/CMakeLists.txt+5−20 tests/plugins/Greeter/Unity/Launcher/launchermodelastest.cpp+4 tests/plugins/IntegratedLightDM/CMakeLists.txt+19−17 tests/plugins/IntegratedLightDM/dbus.cpp+2−1 tests/plugins/ScreenGrabber/CMakeLists.txt+6 tests/plugins/Ubuntu/Gestures/CMakeLists.txt+8−1 tests/plugins/Ubuntu/Gestures/GestureTest.cpp+2−1 tests/plugins/Unity/Indicators/CMakeLists.txt+11−1 tests/plugins/Unity/Launcher/CMakeLists.txt+11−2 tests/plugins/Unity/Launcher/launchermodeltest.cpp+5−4 tests/plugins/Utils/CMakeLists.txt+4−1 tests/plugins/Utils/DeviceConfigParserTest.cpp+3−1 tests/plugins/Wizard/CMakeLists.txt+6 tests/qmltests/CMakeLists.txt+4−1 tests/qmltests/Dash/tst_GenericScopeView.qml+1−1
cmake/modules/QmlTest.cmake+77−28
@@ -55,6 +55,45 @@ function(add_qml_test PATH COMPONENT_NAME)
5555endfunction()
5656
5757
58+# add_qml_test_data(path component_name
59+# [...]
60+# )
61+#
62+# Install file called ${component_name} (or ${component_name}.qml) under
63+# ${path}.
64+
65+function(add_qml_test_data PATH COMPONENT_NAME)
66+ set(filename "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/${COMPONENT_NAME}")
67+
68+ if (IS_DIRECTORY "${filename}")
69+ # As a convenience, allow specifying a directory and we will install
70+ # all files in the dir. We do it this way rather than passing
71+ # DIRECTORY to install() because we want to process any qml files.
72+ file(GLOB subfiles RELATIVE "${filename}" "${filename}/*")
73+ foreach(subfile ${subfiles})
74+ add_qml_test_data("${PATH}/${COMPONENT_NAME}" "${subfile}")
75+ endforeach()
76+ return()
77+ endif()
78+
79+ if (NOT EXISTS "${filename}")
80+ set(filename "${filename}.qml")
81+ set(COMPONENT_NAME "${COMPONENT_NAME}.qml")
82+ endif()
83+
84+ if ("${filename}" MATCHES "\\.qml$")
85+ file(READ "${filename}" contents)
86+ string(REGEX REPLACE "(\"[./]*/)qml/" "\\1" contents "${contents}")
87+ set(filename "${CMAKE_CURRENT_BINARY_DIR}/${PATH}/${COMPONENT_NAME}")
88+ file(WRITE "${filename}" "${contents}")
89+ endif()
90+
91+ install(FILES "${filename}"
92+ DESTINATION "${SHELL_APP_DIR}/tests/qmltests/${PATH}"
93+ )
94+endfunction()
95+
96+
5897# add_qml_unittest(path component_name
5998# [...]
6099# )
@@ -72,7 +111,9 @@ function(add_qml_unittest PATH COMPONENT_NAME)
72111 ARGS -input ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS}
73112 )
74113
75− install_qmltest("${PATH}" "${COMPONENT_NAME}")
114+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml")
115+ add_qml_test_data("${PATH}" "tst_${COMPONENT_NAME}.qml")
116+ endif()
76117endfunction()
77118
78119
@@ -94,7 +135,9 @@ function(add_manual_qml_test PATH COMPONENT_NAME)
94135 ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS}
95136 )
96137
97− install_qmltest("${PATH}" "${COMPONENT_NAME}")
138+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml")
139+ add_qml_test_data("${PATH}" "tst_${COMPONENT_NAME}.qml")
140+ endif()
98141endfunction()
99142
100143
@@ -213,19 +256,6 @@ endfunction()
213256
214257################### INTERNAL ####################
215258
216−function(install_qmltest PATH COMPONENT_NAME)
217− set(filename "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml")
218− set(out_filename "${CMAKE_CURRENT_BINARY_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml")
219− if (EXISTS "${filename}")
220− file(READ "${filename}" contents)
221− string(REGEX REPLACE "(import \"[./]*)/qml" "\\1" contents "${contents}")
222− file(WRITE "${out_filename}" "${contents}")
223− install(FILES "${out_filename}"
224− DESTINATION "${SHELL_APP_DIR}/tests/qmltests/${PATH}"
225− )
226− endif()
227−endfunction()
228−
229259function(add_test_target TARGET_NAME)
230260 cmake_parse_arguments(TEST "" "" "COMMAND;ENVIRONMENT;DEPENDS" ${ARGN})
231261
@@ -241,7 +271,8 @@ function(add_test_target TARGET_NAME)
241271 foreach(ONE_ENV ${TEST_ENVIRONMENT})
242272 set(script "${script}export ${ONE_ENV}\n")
243273 endforeach()
244− set(script "${script}export UNITY_TESTING_DATADIR=\"${CMAKE_INSTALL_PREFIX}/${SHELL_APP_DIR}/\"\n")
274+ set(script "${script}export UNITY_TESTING_DATADIR=\"${CMAKE_INSTALL_PREFIX}/${SHELL_APP_DIR}\"\n")
275+ set(script "${script}export UNITY_TESTING_LIBDIR=\"${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}\"\n")
245276 set(script "${script}\n")
246277 foreach(ONE_CMD ${TEST_COMMAND})
247278 if (NOT ONE_CMD MATCHES "\\$\\(")
@@ -251,26 +282,44 @@ function(add_test_target TARGET_NAME)
251282 endforeach()
252283 set(script "${script}$@")
253284
254− # Now some replacements...
255− # replace build/source roots with their install paths
256− string(REPLACE "${CMAKE_BINARY_DIR}/tests/mocks" "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}/qml/mocks" script "${script}")
257− string(REPLACE "${CMAKE_BINARY_DIR}/tests/uqmlscene" "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}" script "${script}")
258− string(REPLACE "${CMAKE_BINARY_DIR}/tests/utils/modules" "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}/qml/utils" script "${script}")
259− string(REPLACE "${CMAKE_BINARY_DIR}/plugins" "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}/qml" script "${script}")
260− string(REPLACE "${CMAKE_SOURCE_DIR}/tests/qmltests" "${CMAKE_INSTALL_PREFIX}/${SHELL_APP_DIR}/tests/qmltests" script "${script}")
261− # tests like to write xml output to our builddir; we don't need that
262− string(REGEX REPLACE "( '--parameter')? '-o'( '--parameter')? '[^ ]*,xunitxml' " " " script "${script}")
285+ set(filename "${CMAKE_BINARY_DIR}/tests/scripts/${TARGET_NAME}.sh")
263286
287+ # Generate script to file then read it back to resolve any generator
288+ # expressions before we try to replace paths.
264289 file(GENERATE
265− OUTPUT "${CMAKE_BINARY_DIR}/tests/scripts/${TARGET_NAME}.sh"
290+ OUTPUT "${filename}"
266291 CONTENT "${script}"
267292 )
268293
269− install(FILES "${CMAKE_BINARY_DIR}/tests/scripts/${TARGET_NAME}.sh"
294+ # Do replacement at install time to save needless work and to make sure
295+ # we are modifying file after generate step above (which doesn't happen
296+ # immediately). We can't use a custom-defined function or macro here...
297+ # So instead we use a giant ugly code block.
298+
299+ # START OF CODE BLOCK --------------------------------------------------
300+ install(CODE "
301+ file(READ \"${filename}\" replacestr)
302+
303+ # Now some replacements...
304+ # replace build/source roots with their install paths
305+ string(REPLACE \"${CMAKE_BINARY_DIR}/plugins\" \"${CMAKE_INSTALL_PREFIX}/${SHELL_INSTALL_QML}\" replacestr \"\${replacestr}\")
306+ string(REPLACE \"${CMAKE_BINARY_DIR}/tests/mocks\" \"${CMAKE_INSTALL_PREFIX}/${SHELL_INSTALL_QML}/mocks\" replacestr \"\${replacestr}\")
307+ string(REPLACE \"${CMAKE_BINARY_DIR}/tests/plugins\" \"${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}/tests/plugins\" replacestr \"\${replacestr}\")
308+ string(REPLACE \"${CMAKE_BINARY_DIR}/tests/uqmlscene\" \"${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}\" replacestr \"\${replacestr}\")
309+ string(REPLACE \"${CMAKE_BINARY_DIR}/tests/utils/modules\" \"${CMAKE_INSTALL_PREFIX}/${SHELL_INSTALL_QML}/utils\" replacestr \"\${replacestr}\")
310+ string(REPLACE \"${CMAKE_SOURCE_DIR}/tests/qmltests\" \"${CMAKE_INSTALL_PREFIX}/${SHELL_APP_DIR}/tests/qmltests\" replacestr \"\${replacestr}\")
311+ # tests like to write xml output to our builddir; we don't need that
312+ string(REGEX REPLACE \"( '--parameter')? '-o'( '--parameter')? '[^ ]*,xunitxml' \" \" \" replacestr \"\${replacestr}\")
313+
314+ file(WRITE \"${filename}\" \"\${replacestr}\")
315+ ")
316+ # END OF CODE BLOCK --------------------------------------------------
317+
318+ install(FILES "${filename}"
270319 PERMISSIONS OWNER_EXECUTE OWNER_READ
271320 GROUP_EXECUTE GROUP_READ
272321 WORLD_EXECUTE WORLD_READ
273− DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests"
322+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/scripts"
274323 )
275324endfunction()
276325
include/paths.h.in+22
@@ -51,6 +51,28 @@ inline QString translationDirectory() {
5151 }
5252}
5353
54+inline QString testDataDir() {
55+ // Can't use isRunningInstalled, since tests don't use the normal unity8
56+ // executable. $UNITY_TESTING_DATADIR is set by installed tests.
57+ QString datadir(qgetenv("UNITY_TESTING_DATADIR"));
58+ if (datadir.isEmpty()) {
59+ return sourceDirectory() + "/tests";
60+ } else {
61+ return datadir + "/tests";
62+ }
63+}
64+
65+inline QString testLibDir() {
66+ // Can't use isRunningInstalled, since tests don't use the normal unity8
67+ // executable. $UNITY_TESTING_DATADIR is set by installed tests.
68+ QString libdir(qgetenv("UNITY_TESTING_LIBDIR"));
69+ if (libdir.isEmpty()) {
70+ return buildDirectory() + "/tests";
71+ } else {
72+ return libdir + "/tests";
73+ }
74+}
75+
5476inline QString qmlDirectory() {
5577 if (isRunningInstalled()) {
5678 return QStringLiteral("@CMAKE_INSTALL_PREFIX@/@SHELL_APP_DIR@/");
plugins/Ubuntu/Gestures/CMakeLists.txt+1−1
@@ -16,7 +16,7 @@ set(UbuntuGesturesQml_SOURCES
1616
1717add_definitions(-DUBUNTUGESTURESQML_LIBRARY)
1818
19−add_library(UbuntuGesturesQml MODULE ${UbuntuGesturesQml_SOURCES})
19+add_library(UbuntuGesturesQml SHARED ${UbuntuGesturesQml_SOURCES})
2020target_link_libraries(UbuntuGesturesQml UbuntuGestures)
2121
2222qt5_use_modules(UbuntuGesturesQml Core Quick)
tests/CMakeLists.txt+2−6
@@ -48,7 +48,6 @@ macro(unity8_parse_arguments)
4848 list(APPEND ld_paths
4949 ${UNITY_MOCKPATH}/libusermetrics
5050 ${UNITY_MOCKPATH}/IntegratedLightDM/liblightdm
51− ${UNITY_MOCKPATH}/QMenuModel
5251 )
5352 endif()
5453
@@ -127,12 +126,9 @@ function(add_unity8_qmlbenchmark PATH COMPONENT_NAME ITERATIONS)
127126 add_unity8_qmltest(${PATH} ${COMPONENT_NAME} ITERATIONS ${ITERATIONS} ${ARGN})
128127endfunction()
129128
130−# add files needed for qml tests
129+# add files needed for qml tests, just here for better alignment with add_unity8_qmltest
131130function(add_unity8_qmltest_data PATH COMPONENT_NAME)
132− set(filename "${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/${COMPONENT_NAME}.qml")
133− install(FILES "${filename}"
134− DESTINATION "${SHELL_APP_DIR}/tests/qmltests/${PATH}"
135− )
131+ add_qml_test_data("${PATH}" "${COMPONENT_NAME}")
136132endfunction()
137133
138134
tests/mocks/Unity/Application/ApplicationInfo.cpp+1−5
@@ -120,11 +120,7 @@ void ApplicationInfo::setSession(Session* session)
120120
121121void ApplicationInfo::setIconId(const QString &iconId)
122122{
123− QString datadir(qgetenv("UNITY_TESTING_DATADIR"));
124− if (datadir.isEmpty())
125− datadir = "../.."; // relative path for code checkout
126−
127− setIcon(QUrl(datadir + "/tests/graphics/applicationIcons/" + iconId + "@18.png"));
123+ setIcon(QUrl(testDataDir() + "/graphics/applicationIcons/" + iconId + "@18.png"));
128124}
129125
130126void ApplicationInfo::setScreenshotId(const QString &screenshotId)
tests/mocks/Unity/CMakeLists.txt+3
@@ -65,4 +65,7 @@ target_link_libraries(FakeUnityQml
6565
6666qt5_use_modules(FakeUnityQml Qml)
6767
68+add_unity8_mock(Unity 0.2 Unity TARGETS FakeUnityQml)
69+
70+# and one copy in a separate directory for autopilot
6871add_unity8_mock(Unity 0.2 Unity PREFIX scopefakes TARGETS FakeUnityQml)
tests/mocks/Unity/Indicators/CMakeLists.txt+4
@@ -30,6 +30,10 @@ target_link_libraries(IndicatorsFakeQml
3030 QMenuModelQml
3131)
3232
33+set_target_properties(IndicatorsFakeQml PROPERTIES
34+ INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SHELL_INSTALL_QML}/mocks/QMenuModel"
35+)
36+
3337qt5_use_modules(IndicatorsFakeQml Core Qml Quick)
3438
3539add_unity8_mock(Unity.Indicators 0.1 Unity/Indicators TARGETS IndicatorsFakeQml)
tests/mocks/Unity/Launcher/MockLauncherItem.cpp+2−6
@@ -29,7 +29,7 @@ MockLauncherItem::MockLauncherItem(const QString &appId, const QString& desktopF
2929 m_appId(appId),
3030 m_desktopFile(desktopFile),
3131 m_name(name),
32− m_icon(icon),
32+ m_icon(testDataDir() + "/graphics/applicationIcons/" + icon + ".png"),
3333 m_pinned(false),
3434 m_running(false),
3535 m_recent(false),
@@ -63,11 +63,7 @@ QString MockLauncherItem::name() const
6363
6464QString MockLauncherItem::icon() const
6565{
66− QString datadir(qgetenv("UNITY_TESTING_DATADIR"));
67− if (datadir.isEmpty())
68− datadir = "../.."; // relative path for code checkout
69−
70− return datadir + "/tests/graphics/applicationIcons/" + m_icon + ".png";
66+ return m_icon;
7167}
7268
7369bool MockLauncherItem::pinned() const
tests/mocks/Unity/fake_scope.cpp+2−2
@@ -258,11 +258,11 @@ QVariantMap Scope::customizations() const
258258 m["foreground-color"] = "blue";
259259 m["page-header"] = h;
260260 } else if (m_id == "MockScope4") {
261− h["navigation-background"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/artwork/background.png");
261+ h["navigation-background"] = QUrl(testDataDir() + "/qmltests/Dash/artwork/background.png");
262262 m["page-header"] = h;
263263 } else if (m_id == "MockScope5") {
264264 h["background"] = "gradient:///lightgrey/grey";
265− h["logo"] = QUrl(sourceDirectory() + "/tests/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
265+ h["logo"] = QUrl(testDataDir() + "/qmltests/Dash/tst_PageHeader/logo-ubuntu-orange.svg");
266266 h["divider-color"] = "red";
267267 h["navigation-background"] = "color:///black";
268268 m["page-header"] = h;
tests/plugins/AccountsService/CMakeLists.txt+6
@@ -41,6 +41,9 @@ add_executable(mock-server
4141 UscServer.cpp
4242 )
4343qt5_use_modules(mock-server Core DBus)
44+install(TARGETS mock-server
45+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/AccountsService"
46+)
4447
4548add_executable(test-accountsservice
4649 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsService.cpp
@@ -48,6 +51,9 @@ add_executable(test-accountsservice
4851 client.cpp
4952 )
5053qt5_use_modules(test-accountsservice Core DBus Test)
54+install(TARGETS test-accountsservice
55+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/AccountsService"
56+)
5157
5258add_unity8_unittest(AccountsService dbus-test-runner
5359 ARG_PREFIX "--parameter"
tests/plugins/Dash/CMakeLists.txt+12
@@ -30,6 +30,9 @@ macro(add_lvwph_test FILENAME TESTNAME)
3030 ${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/Dash/listviewwithpageheader.cpp)
3131 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
3232 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
33+ install(TARGETS ${TESTNAME}TestExec
34+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Dash"
35+ )
3336
3437 add_unity8_uitest(${TESTNAME} ${TESTNAME}TestExec DEPENDS Dash-qml)
3538endmacro()
@@ -46,6 +49,9 @@ macro(add_dashview_try_test FILENAME TESTNAME)
4649 )
4750 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
4851 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
52+ install(TARGETS ${TESTNAME}TestExec
53+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Dash"
54+ )
4955
5056 add_unity8_uitest(${TESTNAME} ${TESTNAME}TestExec DEPENDS Dash-qml)
5157
@@ -56,6 +62,9 @@ macro(add_dashview_try_test FILENAME TESTNAME)
5662 )
5763 qt5_use_modules(${TESTNAME}TryExec Test Core Qml)
5864 target_link_libraries(${TESTNAME}TryExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
65+ install(TARGETS ${TESTNAME}TryExec
66+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Dash"
67+ )
5968 add_manual_test(${TESTNAME} ${TESTNAME}TryExec DEPENDS Dash-qml)
6069endmacro()
6170
@@ -67,6 +76,9 @@ add_dashview_try_test(organicgrid OrganicGrid)
6776add_executable(CardCreatorTestExec cardcreatortest.cpp)
6877qt5_use_modules(CardCreatorTestExec Test Core Qml)
6978target_link_libraries(CardCreatorTestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
79+install(TARGETS CardCreatorTestExec
80+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Dash"
81+)
7082add_unity8_uitest(CardCreator CardCreatorTestExec DEPENDS Dash-qml)
7183
7284# plain qml test
tests/plugins/GlobalShortcut/CMakeLists.txt+10−1
@@ -11,4 +11,13 @@ add_definitions(-DBUILT_PLUGINS_DIR="${CMAKE_BINARY_DIR}/plugins")
1111add_executable(GlobalShortcutTestExec GlobalShortcutTest.cpp ${CMAKE_SOURCE_DIR}/plugins/GlobalShortcut/globalshortcut.cpp)
1212qt5_use_modules(GlobalShortcutTestExec Test Quick)
1313target_link_libraries(GlobalShortcutTestExec ${Qt5Quick_LIBRARIES} GlobalShortcut-qml)
14−add_unity8_uitest(GlobalShortcut GlobalShortcutTestExec DEPENDS GlobalShortcut-qml)
14+install(TARGETS GlobalShortcutTestExec
15+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/GlobalShortcut"
16+)
17+install(FILES shortcut.qml
18+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/GlobalShortcut"
19+)
20+add_unity8_uitest(GlobalShortcut GlobalShortcutTestExec
21+ DEPENDS GlobalShortcut-qml
22+ ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/GlobalShortcut
23+)
tests/plugins/Greeter/Unity/Launcher/CMakeLists.txt+5−20
@@ -9,7 +9,7 @@ include_directories(
99 )
1010
1111add_definitions(-DSM_BUSNAME=sessionBus)
12−add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
12+add_definitions(-DTESTDIR="plugins/Greeter/Unity/Launcher")
1313add_definitions(-DLAUNCHER_TESTING)
1414
1515### LauncherModelASTest
@@ -31,7 +31,10 @@ target_link_libraries(launchermodelastestExec
3131 ${GSETTINGS_QT_LDFLAGS}
3232 )
3333add_dependencies(launchermodelastestExec mock-server)
34−qt5_use_modules(launchermodelastestExec Test Core DBus Gui)
34+qt5_use_modules(launchermodelastestExec Test Core DBus Gui Qml)
35+install(TARGETS launchermodelastestExec
36+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Greeter/Unity/Launcher"
37+)
3538add_unity8_unittest(LauncherModelAS dbus-test-runner
3639 ARG_PREFIX "--parameter"
3740 ARGS
@@ -40,21 +43,3 @@ add_unity8_unittest(LauncherModelAS dbus-test-runner
4043 --task $<TARGET_FILE:launchermodelastestExec>
4144 --wait-for org.freedesktop.Accounts
4245)
43−
44−# copy .desktop files into build directory for shadow builds
45−file(GLOB DESKTOP_FILES *.desktop)
46−
47−foreach(DESKTOP_FILE ${DESKTOP_FILES})
48− file(COPY "${DESKTOP_FILE}"
49− DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
50− )
51−endforeach()
52−
53−# copy .svg files into build directory for shadow builds
54−file(GLOB DESKTOP_FILES *.svg)
55−
56−foreach(DESKTOP_FILE ${DESKTOP_FILES})
57− file(COPY "${DESKTOP_FILE}"
58− DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
59− )
60−endforeach()
tests/plugins/Greeter/Unity/Launcher/launchermodelastest.cpp+4
@@ -28,6 +28,7 @@
2828#include <QSignalSpy>
2929#include <QtTest>
3030
31+#include <paths.h>
3132
3233class LauncherModelASTest : public QObject
3334{
@@ -45,6 +46,9 @@ private Q_SLOTS:
4546 }
4647
4748 void init() {
49+ // Launcher will look in current dir in testing mode for data
50+ QDir::setCurrent(testLibDir() + "/" + TESTDIR);
51+
4852 // Prepare some fake list
4953 QList<QVariantMap> list;
5054 QVariantMap item;
tests/plugins/IntegratedLightDM/CMakeLists.txt+19−17
@@ -1,6 +1,3 @@
1−add_definitions(
2− -DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
3− )
41include_directories(
52 ${CMAKE_CURRENT_BINARY_DIR}
63 )
@@ -9,18 +6,19 @@ add_executable(GreeterDBusTestExec
96 dbus.cpp
107 ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/Greeter.cpp
118 )
12−# This add_dependencies is needed since we're linking with with -L and -l below
13−# make seems to work but ninja breaks without it
14−add_dependencies(GreeterDBusTestExec MockLightDM)
159qt5_use_modules(GreeterDBusTestExec Core DBus Quick Test)
16−target_link_libraries(GreeterDBusTestExec
17− -L${CMAKE_BINARY_DIR}/tests/mocks/IntegratedLightDM/liblightdm
18− -llightdm-qt5-2
19− )
10+target_link_libraries(GreeterDBusTestExec MockLightDM)
2011target_include_directories(GreeterDBusTestExec PUBLIC
2112 ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM
2213 ${CMAKE_SOURCE_DIR}/tests/mocks/IntegratedLightDM
2314 )
15+set_target_properties(GreeterDBusTestExec PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}/qml/mocks/IntegratedLightDM/liblightdm")
16+install(TARGETS GreeterDBusTestExec
17+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/IntegratedLightDM"
18+)
19+install(FILES greeter.qml
20+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/IntegratedLightDM"
21+)
2422add_unity8_uitest(GreeterDBus dbus-test-runner
2523 ARG_PREFIX "--parameter"
2624 ARGS --task $<TARGET_FILE:GreeterDBusTestExec>
@@ -40,6 +38,9 @@ target_link_libraries(GreeterPamTestExec
4038target_include_directories(GreeterPamTestExec PUBLIC
4139 ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/liblightdm
4240 )
41+install(TARGETS GreeterPamTestExec
42+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/IntegratedLightDM"
43+)
4344add_qmltest_target(testGreeterPam GreeterPamTestExec COMMAND $<TARGET_FILE:GreeterPamTestExec>)
4445
4546add_executable(GreeterUsersModelTestExec
@@ -47,19 +48,17 @@ add_executable(GreeterUsersModelTestExec
4748 ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/UsersModel.cpp
4849 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
4950 )
50−# This add_dependencies is needed since we're linking with with -L and -l below
51−# make seems to work but ninja breaks without it
52−add_dependencies(GreeterUsersModelTestExec MockLightDM)
5351qt5_use_modules(GreeterUsersModelTestExec Core Test)
54−target_link_libraries(GreeterUsersModelTestExec
55− -L${CMAKE_BINARY_DIR}/tests/mocks/IntegratedLightDM/liblightdm
56− -llightdm-qt5-2
57− )
52+target_link_libraries(GreeterUsersModelTestExec MockLightDM)
5853target_include_directories(GreeterUsersModelTestExec PUBLIC
5954 ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM
6055 ${CMAKE_SOURCE_DIR}/plugins/Utils
6156 ${CMAKE_SOURCE_DIR}/tests/mocks/IntegratedLightDM
6257 )
58+set_target_properties(GreeterUsersModelTestExec PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}/qml/mocks/IntegratedLightDM/liblightdm")
59+install(TARGETS GreeterUsersModelTestExec
60+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/IntegratedLightDM"
61+)
6362add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec
6463 ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full
6564 DEPENDS MockLightDM
@@ -78,6 +77,9 @@ target_include_directories(GreeterIntegratedTestExec PUBLIC
7877 ${GLIB_INCLUDE_DIRS}
7978 ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/liblightdm
8079 )
80+install(TARGETS GreeterIntegratedTestExec
81+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/IntegratedLightDM"
82+)
8183add_unity8_unittest(GreeterIntegrated dbus-test-runner
8284 ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/IntegratedLightDM/liblightdm/
8385 ARG_PREFIX "--parameter"
tests/plugins/IntegratedLightDM/dbus.cpp+2−1
@@ -23,6 +23,7 @@
2323#include <QQuickItem>
2424#include <QQuickView>
2525#include <QtTestGui>
26+#include <paths.h>
2627
2728class GreeterDBusTest : public QObject
2829{
@@ -58,7 +59,7 @@ private Q_SLOTS:
5859 void init()
5960 {
6061 view = new QQuickView();
61− view->setSource(QUrl::fromLocalFile(CURRENT_SOURCE_DIR "/greeter.qml"));
62+ view->setSource(QUrl::fromLocalFile(testLibDir() + "/plugins/IntegratedLightDM/greeter.qml"));
6263 greeter = dynamic_cast<Greeter*>(view->rootObject()->property("greeter").value<QObject*>());
6364 QVERIFY(greeter);
6465 QVERIFY(greeter->authenticationUser() == "");
tests/plugins/ScreenGrabber/CMakeLists.txt+6
@@ -11,4 +11,10 @@ add_definitions(-DBUILT_PLUGINS_DIR="${CMAKE_BINARY_DIR}/plugins")
1111add_executable(ScreenGrabberTestExec ScreenGrabberTest.cpp ${CMAKE_SOURCE_DIR}/plugins/ScreenGrabber/screengrabber.cpp)
1212qt5_use_modules(ScreenGrabberTestExec Test Quick Concurrent)
1313target_link_libraries(ScreenGrabberTestExec ${Qt5Quick_LIBRARIES} ScreenGrabber-qml)
14+install(TARGETS ScreenGrabberTestExec
15+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/ScreenGrabber"
16+)
17+install(FILES grabber.qml
18+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/ScreenGrabber"
19+)
1420add_unity8_uitest(ScreenGrabber ScreenGrabberTestExec DEPENDS ScreenGrabber-qml)
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+8−1
@@ -12,12 +12,19 @@ include_directories(
1212 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
1313 )
1414
15−export_qmlfiles(UbuntuGesturesTest .)
15+export_qmlfiles(UbuntuGesturesTest .
16+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Ubuntu/Gestures"
17+)
1618
1719macro(build_gesture_test CLASSNAME)
1820 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp TestItem.cpp)
1921 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
2022 target_link_libraries(${CLASSNAME}TestExec UbuntuGesturesQml UbuntuGestures)
23+ install(TARGETS ${CLASSNAME}TestExec
24+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Ubuntu/Gestures"
25+ )
26+ # To find libUbuntuGestures.so
27+ set_target_properties(${CLASSNAME}TestExec PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SHELL_PRIVATE_LIBDIR}")
2128endmacro()
2229
2330set(UNITY_IMPORT_PATHS
tests/plugins/Ubuntu/Gestures/GestureTest.cpp+2−1
@@ -24,6 +24,7 @@
2424
2525#include <Timer.h>
2626#include <TouchRegistry.h>
27+#include <paths.h>
2728
2829using namespace UbuntuGestures;
2930
@@ -45,7 +46,7 @@ void GestureTest::init()
4546{
4647 m_view = new QQuickView;
4748 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
48− m_view->setSource(QUrl::fromLocalFile(m_qmlFilename));
49+ m_view->setSource(QUrl::fromLocalFile(testLibDir() + "/plugins/Ubuntu/Gestures/" + m_qmlFilename));
4950 m_view->show();
5051 QVERIFY(QTest::qWaitForWindowExposed(m_view));
5152 QVERIFY(m_view->rootObject() != 0);
tests/plugins/Unity/Indicators/CMakeLists.txt+11−1
@@ -24,8 +24,18 @@ macro(indicator_test TEST)
2424 ${GIO_LIBRARIES}
2525 ${QMENUMODEL_LDFLAGS}
2626 )
27+ install(TARGETS ${TEST}Exec
28+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Unity/Indicators"
29+ )
30+
31+ set(ldpath "")
32+ foreach(lib ${test_ADDITIONAL_LIBS})
33+ set(ldpath "$<TARGET_FILE_DIR:${lib}>:")
34+ endforeach(lib)
2735
28− add_unity8_unittest(${TEST} ${TEST}Exec)
36+ add_unity8_unittest(${TEST} ${TEST}Exec
37+ ENVIRONMENT "LD_LIBRARY_PATH=${ldpath}"
38+ )
2939endmacro(indicator_test)
3040
3141indicator_test(IndicatorsManager ADDITIONAL_LIBS IndicatorsQml)
tests/plugins/Unity/Launcher/CMakeLists.txt+11−2
@@ -11,7 +11,7 @@ include_directories(
1111 )
1212
1313add_definitions(-DSM_BUSNAME=sessionBus)
14−add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
14+add_definitions(-DTESTDIR="plugins/Unity/Launcher")
1515add_definitions(-DLAUNCHER_TESTING)
1616
1717### LauncherModelTest
@@ -37,7 +37,10 @@ target_link_libraries(launchermodeltestExec
3737 ${GSETTINGS_QT_LDFLAGS}
3838 )
3939add_dependencies(launchermodeltestExec mock-server)
40−qt5_use_modules(launchermodeltestExec Test Core DBus Xml Gui)
40+qt5_use_modules(launchermodeltestExec Test Core DBus Xml Gui Qml)
41+install(TARGETS launchermodeltestExec
42+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Unity/Launcher"
43+ )
4144
4245add_unity8_unittest(LauncherModel dbus-test-runner
4346 ARG_PREFIX "--parameter"
@@ -56,6 +59,9 @@ foreach(DESKTOP_FILE ${DESKTOP_FILES})
5659 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
5760 )
5861endforeach()
62+install(FILES ${DESKTOP_FILES}
63+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Unity/Launcher"
64+ )
5965
6066# copy .svg files into build directory for shadow builds
6167file(GLOB DESKTOP_FILES *.svg)
@@ -65,3 +71,6 @@ foreach(DESKTOP_FILE ${DESKTOP_FILES})
6571 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
6672 )
6773endforeach()
74+install(FILES ${DESKTOP_FILES}
75+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Unity/Launcher"
76+ )
tests/plugins/Unity/Launcher/launchermodeltest.cpp+5−4
@@ -34,6 +34,8 @@
3434#include <QDBusMetaType>
3535#include <QDomDocument>
3636
37+#include <paths.h>
38+
3739// This is a mock, specifically to test the LauncherModel
3840class MockApp: public unity::shell::application::ApplicationInfoInterface
3941{
@@ -163,6 +165,9 @@ private Q_SLOTS:
163165
164166 // Adding 2 apps to the mock appmanager. Both should appear in the launcher.
165167 void init() {
168+ // Launcher will look in current dir in testing mode for data
169+ QDir::setCurrent(testLibDir() + "/" + TESTDIR);
170+
166171 QDBusInterface accountsInterface(QStringLiteral("org.freedesktop.Accounts"),
167172 QStringLiteral("/org/freedesktop/Accounts"),
168173 QStringLiteral("org.freedesktop.Accounts"));
@@ -576,7 +581,6 @@ private Q_SLOTS:
576581 appManager->removeApplication(0);
577582
578583 // "delete" the .desktop files
579− QString oldCurrent = QDir::currentPath();
580584 if (deleted) {
581585 // In testing mode, the launcher searches the current dir for the sample .desktop file
582586 // We can make that fail by changing the current dir
@@ -591,9 +595,6 @@ private Q_SLOTS:
591595 QCOMPARE(reply.isValid(), true);
592596
593597 QCOMPARE(launcherModel->rowCount(), deleted ? 0 : 2);
594−
595− // Restoring current dir
596− QDir::setCurrent(oldCurrent);
597598 }
598599
599600 void testSettings() {
tests/plugins/Utils/CMakeLists.txt+4−1
@@ -15,8 +15,11 @@ foreach(util_test
1515 add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
1616 qt5_use_modules(${util_test}TestExec Test Core Qml)
1717 target_link_libraries(${util_test}TestExec Utils-qml)
18+ install(TARGETS ${util_test}TestExec
19+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Utils"
20+ )
1821 add_unity8_unittest(${util_test} ${util_test}TestExec ADD_TEST
19− ENVIRONMENT XDG_CONFIG_HOME=${CMAKE_CURRENT_BINARY_DIR}
22+ ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Utils
2023 )
2124
2225endforeach()
tests/plugins/Utils/DeviceConfigParserTest.cpp+3−1
@@ -45,13 +45,15 @@ private Q_SLOTS:
4545 }
4646
4747 void testCustomFile() {
48− QSettings s("./devices.conf", QSettings::IniFormat);
48+ QTemporaryDir dir;
49+ QSettings s(dir.path() + "/devices.conf", QSettings::IniFormat);
4950 s.beginGroup("fakedevice");
5051
5152 s.setValue("SupportedOrientations", QStringList() << "Portrait" << "Landscape" << "InvertedLandscape");
5253 s.setValue("PrimaryOrientation", "InvertedLandscape");
5354 s.sync();
5455
56+ qputenv("XDG_CONFIG_HOME", dir.path().toUtf8());
5557 DeviceConfigParser p;
5658 p.setName("fakedevice");
5759
tests/plugins/Wizard/CMakeLists.txt+6
@@ -8,6 +8,9 @@ add_executable(tst-wizard-pagelist
88 ${CMAKE_SOURCE_DIR}/plugins/Wizard/PageList.cpp
99)
1010qt5_use_modules(tst-wizard-pagelist Core Qml Test)
11+install(TARGETS tst-wizard-pagelist
12+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Wizard"
13+)
1114add_unity8_unittest(WizardPageList tst-wizard-pagelist ENVIRONMENT WIZARD_TESTING=1)
1215
1316add_executable(tst-wizard-system
@@ -15,4 +18,7 @@ add_executable(tst-wizard-system
1518 ${CMAKE_SOURCE_DIR}/plugins/Wizard/System.cpp
1619)
1720qt5_use_modules(tst-wizard-system Core DBus Qml Test)
21+install(TARGETS tst-wizard-system
22+ DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/Wizard"
23+)
1824add_unity8_unittest(WizardSystem tst-wizard-system)
tests/qmltests/CMakeLists.txt+4−1
@@ -12,7 +12,7 @@ add_unity8_qmltest(Components Carousel)
1212add_unity8_qmltest(Components Dialogs LIGHTDM)
1313add_unity8_qmltest(Components DraggingArea)
1414add_unity8_qmltest(Components LazyImage)
15−add_unity8_qmltest_data(Components/tst_LazyImage ImageControls)
15+add_unity8_qmltest_data(Components tst_LazyImage)
1616add_unity8_qmltest(Components Lockscreen)
1717add_unity8_qmltest(Components ModeSwitchWarningDialog)
1818add_unity8_qmltest(Components PhysicalKeysMapper)
@@ -33,6 +33,9 @@ add_unity8_qmltest(Dash CardTool)
3333add_unity8_qmltest(Dash GenericScopeView)
3434add_unity8_qmltest(Dash DashPageHeader)
3535add_unity8_qmltest(Dash PreviewView)
36+add_unity8_qmltest_data(Dash artwork)
37+add_unity8_qmltest_data(Dash CardHelpers.js)
38+add_unity8_qmltest_data(Dash tst_PageHeader)
3639add_unity8_qmltest(Dash/Previews Preview)
3740add_unity8_qmltest(Dash/Previews PreviewActions)
3841add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
tests/qmltests/Dash/tst_GenericScopeView.qml+1−1
@@ -431,7 +431,7 @@ Item {
431431 { tag: "Default", index: 0, foreground: UbuntuColors.darkGrey, background: "color:///#ffffff", logo: "" },
432432 { tag: "Foreground", index: 1, foreground: "yellow", background: "color:///#ffffff", logo: "" },
433433 { tag: "Logo+Background", index: 2, foreground: UbuntuColors.darkGrey, background: "gradient:///lightgrey/grey",
434− logo: Qt.resolvedUrl("../Dash/tst_PageHeader/logo-ubuntu-orange.svg") },
434+ logo: Qt.resolvedUrl("tst_PageHeader/logo-ubuntu-orange.svg") },
435435 ];
436436 }
437437