on xenial help sign in
* Refactor QmlTest.cmake module so that all tests can go through it.
5c2db7cLukáš Tinkl
CMakeLists.txt+9
@@ -116,6 +116,14 @@ include_directories(
116 ${APPLICATION_API_INCLUDE_DIRS}
116 ${APPLICATION_API_INCLUDE_DIRS}
117)
117)
118
118
119+set(ARTIFACTS_DIR "" CACHE PATH "Store test artifacts in this directory.")
120+
121+# Quiet logger
122+set(QUIET_LOGGER OFF CACHE BOOL "Disable test output on stdout.")
123+if(NOT QUIET_LOGGER)
124+ set(STDOUT_LOGGER "-o" "-,txt")
125+endif()
126+
119# add subdirectories to build
127# add subdirectories to build
120add_subdirectory(include)
128add_subdirectory(include)
121add_subdirectory(libs)
129add_subdirectory(libs)
@@ -124,6 +132,7 @@ add_subdirectory(tools)
124add_subdirectory(qml)
132add_subdirectory(qml)
125
133
126# Tests
134# Tests
135+set(NO_TESTS OFF CACHE BOOL "Disable tests.")
127if (NOT NO_TESTS)
136if (NOT NO_TESTS)
128 include(CTest)
137 include(CTest)
129 enable_testing()
138 enable_testing()
cmake/modules/QmlPlugins.cmake+1−3
@@ -107,8 +107,6 @@ macro(export_qmlplugin PLUGIN VERSION PATH)
107 set(multi TARGETS)
107 set(multi TARGETS)
108 cmake_parse_arguments(QMLPLUGIN "${options}" "${single}" "${multi}" ${ARGN})
108 cmake_parse_arguments(QMLPLUGIN "${options}" "${single}" "${multi}" ${ARGN})
109
109
110− get_target_property(qmlplugindump_executable qmlplugindump LOCATION)
111−
112 if(QMLPLUGIN_BINARY_DIR)
110 if(QMLPLUGIN_BINARY_DIR)
113 set(qmlplugin_dir ${QMLPLUGIN_BINARY_DIR}/${PATH})
111 set(qmlplugin_dir ${QMLPLUGIN_BINARY_DIR}/${PATH})
114 else()
112 else()
@@ -127,7 +125,7 @@ macro(export_qmlplugin PLUGIN VERSION PATH)
127 set(qmltypes_path ${CMAKE_CURRENT_SOURCE_DIR}/${plugin_suffix}.qmltypes)
125 set(qmltypes_path ${CMAKE_CURRENT_SOURCE_DIR}/${plugin_suffix}.qmltypes)
128
126
129 add_custom_target(${target_prefix}-qmltypes
127 add_custom_target(${target_prefix}-qmltypes
130− COMMAND env ${QMLPLUGIN_ENVIRONMENT} ${qmlplugindump_executable} -notrelocatable
128+ COMMAND env ${QMLPLUGIN_ENVIRONMENT} $<TARGET_FILE:qmlplugindump> -notrelocatable
131 ${PLUGIN} ${VERSION} ${QMLPLUGIN_MODULE_DIR} > ${qmltypes_path}
129 ${PLUGIN} ${VERSION} ${QMLPLUGIN_MODULE_DIR} > ${qmltypes_path}
132 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
130 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
133 )
131 )
cmake/modules/QmlTest.cmake+285−191
@@ -1,218 +1,312 @@
1−# add_qml_test(path component_name [NO_ADD_TEST] [NO_TARGETS]
1+# If you need to override the qmlscene or qmltestrunner executables,
2−# [TARGETS target1 [target2 [...]]]
2+# create the corresponding executable target.
3−# [IMPORT_PATHS import_path1 [import_path2 [...]]
3+
4−# [PROPERTIES prop1 value1 [prop2 value2 [...]]])
4+# These functions respect the global STDOUT_LOGGER and ARTIFACTS_DIR variables.
5+
6+# You can use those with cmake_parse_arguments
7+# if you need to wrap and mangle arguments.
8+set(QMLTEST_OPTIONS ADD_TEST CACHE INTERNAL "")
9+set(QMLTEST_SINGLE ITERATIONS ARG_PREFIX CACHE INTERNAL "")
10+set(QMLTEST_MULTI ARGS ENVIRONMENT DEPENDS IMPORT_PATHS TARGETS CACHE INTERNAL "")
11+
12+# import_executables(name1 [name2 [...]]
13+# [OPTIONAL] # continue when not found
14+# )
5#
15#
6−# NO_ADD_TEST will prevent adding the test to the "test" target
16+# This will find the named executables and import them
7−# NO_TARGETS will prevent adding the test to any targets
17+# to an imported target of the same name.
8−# TARGETS lists the targets the test should be added to
18+
9−# IMPORT_PATHS will pass those paths to qmltestrunner as "-import" arguments
19+function(import_executables)
10−# PROPERTIES will be set on the target and test target. See CMake's set_target_properties()
20+ cmake_parse_arguments(QMLTEST "OPTIONAL" "" "" ${ARGN})
21+
22+ foreach(NAME ${QMLTEST_UNPARSED_ARGUMENTS})
23+ if(NOT TARGET ${NAME})
24+ add_executable(${NAME} IMPORTED GLOBAL)
25+ find_program(${NAME}_exe ${NAME})
26+
27+ if(NOT QMLTEST_OPTIONAL AND NOT ${NAME}_exe)
28+ message(FATAL_ERROR "Could not locate ${NAME}.")
29+ elseif(NOT ${NAME}_exe)
30+ message(STATUS "Could not locate ${NAME}, skipping.")
31+ else()
32+ set_target_properties(${NAME} PROPERTIES IMPORTED_LOCATION ${${NAME}_exe})
33+ endif()
34+ endif()
35+ endforeach()
36+endfunction()
37+
38+
39+# add_qml_test(path component_name
40+# [...]
41+# )
11#
42#
12−# Two targets will be created:
43+# Add test targets for ${component_name} under ${path}. It's assumed
13−# - testComponentName - Runs the test with qmltestrunner
44+# that the test file is named ${path}/tst_${component_name}.qml.
14−# - tryComponentName - Runs the test with uqmlscene, for manual interaction
45+#
15−# - gdbtestComponentName - Runs the test with qmltestrunner under gdb
46+# This function wraps add_manual_qml_test and add_qml_unittest,
47+# see below for available arguments.
48+
49+function(add_qml_test PATH COMPONENT_NAME)
50+ cmake_parse_arguments(QMLTEST "${QMLTEST_OPTIONS}" "${QMLTEST_SINGLE}" "${QMLTEST_MULTI}" ${ARGN})
51+ mangle_arguments()
52+
53+ add_qml_unittest(${ARGV})
54+ add_manual_qml_test(${ARGV})
55+endfunction()
56+
57+
58+# add_qml_unittest(path component_name
59+# [...]
60+# )
61+#
62+# Add test targets for ${component_name} under ${path}. It's assumed
63+# that the test file is named ${path}/tst_${component_name}.qml.
64+#
65+# This function wraps add_executable_test, see below for available arguments.
66+
67+function(add_qml_unittest PATH COMPONENT_NAME)
68+ import_executables(qmltestrunner)
69+
70+ add_executable_test(${COMPONENT_NAME} qmltestrunner
71+ ${ARGN}
72+ ARGS -input ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS}
73+ )
74+endfunction()
75+
76+
77+# add_manual_qml_test(path component_name
78+# [...]
79+# )
80+#
81+# Add manual test targets for ${component_name} under ${path}. It's assumed
82+# that the test file is named ${path}/tst_${component_name}.qml.
16#
83#
17−# To change/set a default value for the whole test suite, prior to calling add_qml_test, set:
84+# This function wraps add_manual_test, see below for available arguments.
18−# qmltest_DEFAULT_NO_ADD_TEST (default: FALSE)
85+
19−# qmltest_DEFAULT_TARGETS
86+function(add_manual_qml_test PATH COMPONENT_NAME)
20−# qmltest_DEFAULT_IMPORT_PATHS
87+ import_executables(qmlscene)
21−# qmltest_DEFAULT_PROPERTIES
88+ cmake_parse_arguments(QMLTEST "${QMLTEST_OPTIONS}" "${QMLTEST_SINGLE}" "${QMLTEST_MULTI}" ${ARGN})
22−
89+
23−find_program(qmltestrunner_exe qmltestrunner)
90+ add_manual_test(${COMPONENT_NAME} qmlscene
24−
91+ ${ARGN}
25−if(NOT qmltestrunner_exe)
92+ ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS}
26− msg(FATAL_ERROR "Could not locate qmltestrunner.")
93+ )
94+endfunction()
95+
96+
97+# add_executable_test(target component_name
98+# [...] # see doc for add_manual_qml_test for common arguments
99+# [ADD_TEST] # whether to add to the "test" target
100+# [ARG_PREFIX arg_prefix] # prefix logging arguments with this string
101+# [ARGS] arg1 [arg2 [...]] # pass these arguments to the test executable
102+# [TARGETS target1 [target2 [...]]] # make the listed targets depend on this test
103+# # if a corresponding xvfbtarget1, xvfbtarget2 etc. exists,
104+# # this test running under xvfb will be added as a dependency
105+# # of those targets
106+# [ITERATIONS count] # run this test as a benchmark for ${count} iterations
107+# )
108+#
109+# Logging options in the standard form of "-o filename,format"
110+# will be appended to the arguments list, prefixed with ARG_PREFIX.
111+# XUnitXML files will be stored in current binary dir or under
112+# ARTIFACTS_DIR, if set.
113+#
114+# Three targets will be created:
115+# - test${component_name} - Runs the test
116+# - xvfbtest${component_name} - Runs the test under xvfb
117+# - gdbtest${component_name} - Runs the test under gdb
118+
119+function(add_executable_test COMPONENT_NAME TARGET)
120+ import_executables(gdb xvfb-run OPTIONAL)
121+
122+ cmake_parse_arguments(QMLTEST "${QMLTEST_OPTIONS}" "${QMLTEST_SINGLE}" "${QMLTEST_MULTI}" ${ARGN})
123+ mangle_arguments()
124+
125+ if(ARTIFACTS_DIR)
126+ file(RELATIVE_PATH path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
127+ file(MAKE_DIRECTORY ${ARTIFACTS_DIR}/${path})
128+ set(file_logger -o ${ARTIFACTS_DIR}/${path}/test${COMPONENT_NAME}.xml,xunitxml)
129+ else()
130+ set(file_logger -o ${CMAKE_CURRENT_BINARY_DIR}/test${COMPONENT_NAME}.xml,xunitxml)
27−endif()
131+ endif()
28−
132+
29−set(qmlscene_exe ${CMAKE_BINARY_DIR}/tests/uqmlscene/uqmlscene)
133+ bake_arguments("${QMLTEST_ARG_PREFIX}" args ${iterations} ${file_logger} ${STDOUT_LOGGER})
30−
134+
31−set(test_env LC_ALL=C UNITY_TESTING=1)
135+ set(qmltest_command
32−
136+ $<TARGET_FILE:${TARGET}>
33−macro(add_manual_qml_test SUBPATH COMPONENT_NAME)
137+ ${QMLTEST_ARGS}
34− set(options NO_ADD_TEST NO_TARGETS)
138+ ${args}
35− set(multi_value_keywords IMPORT_PATHS TARGETS PROPERTIES ENVIRONMENT)
139+ )
36−
140+
37− cmake_parse_arguments(qmltest "${options}" "" "${multi_value_keywords}" ${ARGN})
141+ add_qmltest_target(test${COMPONENT_NAME} ${TARGET}
38− cmake_parse_arguments(qmltest_default "${options}" "" "${multi_value_keywords}" ${qmltest_DEFAULT_PROPERTIES})
142+ COMMAND ${qmltest_command}
39−
143+ ${depends}
40− set(qmlscene_TARGET try${COMPONENT_NAME})
144+ ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT}
41− set(qmltest_FILE ${SUBPATH}/tst_${COMPONENT_NAME})
145+ ${add_test}
42−
146+ ${targets}
43− set(qmlscene_imports "")
147+ )
44− if(NOT "${qmltest_IMPORT_PATHS}" STREQUAL "")
148+
45− foreach(IMPORT_PATH ${qmltest_IMPORT_PATHS})
149+ if(TARGET xvfb-run)
46− list(APPEND qmlscene_imports "-I")
150+ add_qmltest_target(xvfbtest${COMPONENT_NAME} ${TARGET}
47− list(APPEND qmlscene_imports ${IMPORT_PATH})
151+ COMMAND $<TARGET_FILE:xvfb-run> --server-args "-screen 0 1024x768x24" --auto-servernum ${qmltest_command}
48− endforeach(IMPORT_PATH)
152+ ${depends}
49− elseif(NOT "${qmltest_DEFAULT_IMPORT_PATHS}" STREQUAL "")
153+ ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT} LD_PRELOAD=/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/mesa/libGL.so.1
50− foreach(IMPORT_PATH ${qmltest_DEFAULT_IMPORT_PATHS})
154+ TARGETS ${xvfb_targets}
51− list(APPEND qmlscene_imports "-I")
155+ )
52− list(APPEND qmlscene_imports ${IMPORT_PATH})
53− endforeach(IMPORT_PATH)
54 endif()
156 endif()
55
157
56− if("${qmltest_ENVIRONMENT}" STREQUAL "")
158+ if(TARGET gdb)
57− set(qmltest_ENVIRONMENT "${qmltest_default_ENVIRONMENT}")
159+ add_qmltest_target(gdbtest${COMPONENT_NAME} ${TARGET}
160+ COMMAND $<TARGET_FILE:gdb> -ex run -args ${qmltest_command}
161+ ${depends}
162+ ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT}
163+ )
58 endif()
164 endif()
165+endfunction()
166+
167+
168+# add_manual_test(target component_name
169+# [DEPENDS target1 [target2 [...]]] # make this test depend on the specified targets
170+# [IMPORT_PATHS import_path1 [import_path2 [...]] # use these QML import paths
171+# # (they're searched first to last)
172+# [ENVIRONMENT var1=value1 [var2=value2 [...]]] # set these environment variables
173+# )
174+#
175+# Two targets will be created:
176+# - try${component_name} - Runs the test for manual interaction
177+# - gdbtry${component_name} - Runs the test under gdb
178+
179+function(add_manual_test COMPONENT_NAME TARGET)
180+ import_executables(gdb OPTIONAL)
181+
182+ cmake_parse_arguments(QMLTEST "${QMLTEST_OPTIONS}" "${QMLTEST_SINGLE}" "${QMLTEST_MULTI}" ${ARGN})
183+ mangle_arguments()
184+
185+ bake_arguments("${QMLTEST_ARG_PREFIX}" args -qmljsdebugger=port:3768)
186+
187+ set(qmltry_command
188+ $<TARGET_FILE:${TARGET}>
189+ ${QMLTEST_ARGS}
190+ ${args}
191+ )
59
192
60− set(qmlscene_command
193+ add_qmltest_target(try${COMPONENT_NAME} ${TARGET}
61− env ${test_env} ${qmltest_ENVIRONMENT}
194+ COMMAND ${qmltry_command}
62− ${qmlscene_exe} -qmljsdebugger=port:3768 ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
195+ ${depends}
63− ${qmlscene_imports}
196+ ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT}
64 )
197 )
65− add_custom_target(${qmlscene_TARGET} ${qmlscene_command})
198+
66−
199+ if(TARGET gdb)
67−endmacro(add_manual_qml_test)
200+ add_qmltest_target(gdbtry${COMPONENT_NAME} ${TARGET}
68−
201+ COMMAND $<TARGET_FILE:gdb> -ex run -args ${qmltry_command}
69−macro(add_qml_benchmark SUBPATH COMPONENT_NAME ITERATIONS)
202+ ${depends}
70− add_qml_test_internal(${SUBPATH} ${COMPONENT_NAME} ${ITERATIONS} ${ARGN})
203+ ENVIRONMENT QML2_IMPORT_PATH=${imports} ${QMLTEST_ENVIRONMENT}
71−endmacro(add_qml_benchmark)
204+ )
72−
73−macro(add_qml_test SUBPATH COMPONENT_NAME)
74− add_qml_test_internal(${SUBPATH} ${COMPONENT_NAME} 0 ${ARGN})
75−endmacro(add_qml_test)
76−
77−macro(add_qml_test_internal SUBPATH COMPONENT_NAME ITERATIONS)
78− set(options NO_ADD_TEST NO_TARGETS)
79− set(multi_value_keywords IMPORT_PATHS TARGETS PROPERTIES ENVIRONMENT)
80−
81− cmake_parse_arguments(qmltest "${options}" "" "${multi_value_keywords}" ${ARGN})
82− cmake_parse_arguments(qmltest_default "${options}" "" "${multi_value_keywords}" ${qmltest_DEFAULT_PROPERTIES})
83−
84− set(qmltest_TARGET test${COMPONENT_NAME})
85− set(qmltest_gdb_TARGET gdbtest${COMPONENT_NAME})
86− set(qmltest_xvfb_TARGET xvfbtest${COMPONENT_NAME})
87− set(qmltest_FILE ${SUBPATH}/tst_${COMPONENT_NAME})
88−
89− set(qmltestrunner_imports "")
90− if(NOT "${qmltest_IMPORT_PATHS}" STREQUAL "")
91− foreach(IMPORT_PATH ${qmltest_IMPORT_PATHS})
92− list(APPEND qmltestrunner_imports "-import")
93− list(APPEND qmltestrunner_imports ${IMPORT_PATH})
94− endforeach(IMPORT_PATH)
95− elseif(NOT "${qmltest_DEFAULT_IMPORT_PATHS}" STREQUAL "")
96− foreach(IMPORT_PATH ${qmltest_DEFAULT_IMPORT_PATHS})
97− list(APPEND qmltestrunner_imports "-import")
98− list(APPEND qmltestrunner_imports ${IMPORT_PATH})
99− endforeach(IMPORT_PATH)
100 endif()
205 endif()
206+endfunction()
207+
208+
209+################### INTERNAL ####################
210+
211+# add_qmltest_target(target_name target
212+# COMMAND test_exe [arg1 [...]] # execute this test with arguments
213+# [...] # see above for available arguments:
214+# # ADD_TEST, ENVIRONMENT, DEPENDS and TARGETS
215+# )
101
216
217+function(add_qmltest_target TARGET_NAME TARGET)
218+ cmake_parse_arguments(QMLTEST "${QMLTEST_OPTIONS}" "${QMLTEST_SINGLE}" "COMMAND;${QMLTEST_MULTI}" ${ARGN})
219+ mangle_arguments()
220+
221+ # Additional arguments
102 string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_lower)
222 string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_lower)
103 if(cmake_generator_lower STREQUAL "unix makefiles")
223 if(cmake_generator_lower STREQUAL "unix makefiles")
104− set(function_ARGS $(FUNCTION))
224+ set(function "$(FUNCTION)")
105− else()
106− set(function_ARGS "")
107 endif()
225 endif()
108
226
109− if (${ITERATIONS} GREATER 0)
227+ add_custom_target(${TARGET_NAME}
110− set(ITERATIONS_STRING "-iterations" ${ITERATIONS})
228+ env ${QMLTEST_ENVIRONMENT}
111− else()
229+ ${QMLTEST_COMMAND} ${function}
112− set(ITERATIONS_STRING "")
230+ DEPENDS ${TARGET} ${QMLTEST_DEPENDS}
231+ )
232+
233+ if(QMLTEST_ADD_TEST)
234+ add_test(
235+ NAME ${TARGET_NAME}
236+ COMMAND ${QMLTEST_COMMAND}
237+ )
238+
239+ foreach(ENV ${QMLTEST_ENVIRONMENT})
240+ set_property(TEST ${TARGET_NAME} APPEND PROPERTY ENVIRONMENT ${ENV})
241+ endforeach()
242+
243+ set_property(TEST ${TARGET_NAME} APPEND PROPERTY DEPENDS ${TARGET})
244+ foreach(DEPEND ${DEPENDS})
245+ set_property(TEST ${TARGET_NAME} APPEND PROPERTY DEPENDS ${DEPEND})
246+ endforeach()
113 endif()
247 endif()
114
248
115− if("${qmltest_ENVIRONMENT}" STREQUAL "")
249+ foreach(UPSTREAM_TARGET ${QMLTEST_TARGETS})
116− set(qmltest_ENVIRONMENT "${qmltest_default_ENVIRONMENT}")
250+ add_dependencies(${UPSTREAM_TARGET} ${TARGET_NAME})
251+ endforeach()
252+endfunction()
253+
254+
255+# mangle_arguments(${ARGN})
256+#
257+# Verify there were no unparsed arguments and
258+# mangle the known ones for further processing.
259+
260+macro(mangle_arguments)
261+ if(QMLTEST_UNPARSED_ARGUMENTS)
262+ message(FATAL_ERROR "Unexpected arguments: ${QMLTEST_UNPARSED_ARGUMENTS}")
117 endif()
263 endif()
118
264
119− set(qmltest_command
265+ if(QMLTEST_ADD_TEST)
120− env ${test_env} ${qmltest_ENVIRONMENT}
266+ set(add_test ADD_TEST)
121− ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
122− ${qmltestrunner_imports}
123− ${ITERATIONS_STRING}
124− -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
125− -o -,txt
126− ${function_ARGS}
127− )
128− find_program(DPKG dpkg-architecture)
129− if(DPKG)
130− exec_program(${DPKG} ARGS "-qDEB_BUILD_MULTIARCH" OUTPUT_VARIABLE ARCH_TRIPLET )
131− set(LD_PRELOAD_PATH "LD_PRELOAD=/usr/lib/${ARCH_TRIPLET}/mesa/libGL.so.1")
132 endif()
267 endif()
133− set(qmltest_xvfb_command
134− env ${test_env} ${qmltest_ENVIRONMENT} ${LD_PRELOAD_PATH}
135− xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
136− ${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
137− ${qmltestrunner_imports}
138− -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
139− -o -,txt
140− ${function_ARGS}
141− )
142
268
143− set(qmltest_gdb_command
269+ if(QMLTEST_IMPORT_PATHS)
144− env ${test_env} ${qmltest_ENVIRONMENT} ${LD_PRELOAD_PATH}
270+ string(REPLACE ";" ":" imports "${QMLTEST_IMPORT_PATHS}")
145− gdb -e ${qmltestrunner_exe} -ex \"run -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml ${qmltestrunner_imports} ${ITERATIONS_STRING}\"
271+ endif()
146− )
147
272
148− add_qmltest_target(${qmltest_TARGET} "${qmltest_command}" TRUE ${qmltest_NO_ADD_TEST})
273+ if(QMLTEST_ITERATIONS)
149− add_qmltest_target(${qmltest_xvfb_TARGET} "${qmltest_xvfb_command}" ${qmltest_NO_TARGETS} TRUE)
274+ set(iterations -iterations ${QMLTEST_ITERATIONS})
150− add_qmltest_target(${qmltest_gdb_TARGET} "${qmltest_gdb_command}" TRUE TRUE)
151− add_manual_qml_test(${SUBPATH} ${COMPONENT_NAME} ${ARGN})
152−endmacro(add_qml_test_internal)
153−
154−macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS ENVVAR)
155− set(testCommand
156− ${ENVVAR}
157− LD_LIBRARY_PATH=${LD_PATH}
158− dbus-test-runner
159− -m 300
160− -t ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
161− -p -o -p ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
162− -p -o -p -,txt)
163−
164− add_qmltest_target(test${CLASS_NAME} "${testCommand}" FALSE TRUE)
165− add_dependencies(test${CLASS_NAME} ${CLASS_NAME}TestExec ${DEPS})
166−
167− find_program( HAVE_GCC gcc )
168− if (NOT ${HAVE_GCC} STREQUAL "")
169− exec_program( gcc ARGS "-dumpmachine" OUTPUT_VARIABLE ARCH_TRIPLET )
170− set(LD_PRELOAD_PATH "LD_PRELOAD=/usr/lib/${ARCH_TRIPLET}/mesa/libGL.so.1")
171 endif()
275 endif()
172− set(xvfbtestCommand
276+
173− ${LD_PRELOAD_PATH}
277+ if(QMLTEST_DEPENDS)
174− ${ENVVAR}
278+ set(depends DEPENDS ${QMLTEST_DEPENDS})
175− LD_LIBRARY_PATH=${LD_PATH}
176− xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
177− dbus-test-runner
178− -m 300
179− -t ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
180− -p -o -p ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
181− -p -o -p -,txt)
182−
183− add_qmltest_target(xvfbtest${CLASS_NAME} "${xvfbtestCommand}" FALSE TRUE)
184− add_dependencies(qmluitests xvfbtest${CLASS_NAME})
185−endmacro(add_binary_qml_test)
186−
187−macro(add_qmltest_target qmltest_TARGET qmltest_command qmltest_NO_TARGETS qmltest_NO_ADD_TEST)
188− add_custom_target(${qmltest_TARGET} ${qmltest_command})
189−
190− if(NOT "${qmltest_PROPERTIES}" STREQUAL "")
191− set_target_properties(${qmltest_TARGET} PROPERTIES ${qmltest_PROPERTIES})
192− elseif(NOT "${qmltest_DEFAULT_PROPERTIES}" STREQUAL "")
193− set_target_properties(${qmltest_TARGET} PROPERTIES ${qmltest_DEFAULT_PROPERTIES})
194 endif()
279 endif()
195
280
196− if("${qmltest_NO_ADD_TEST}" STREQUAL FALSE AND NOT "${qmltest_DEFAULT_NO_ADD_TEST}" STREQUAL "TRUE")
281+ if(QMLTEST_TARGETS)
197− add_test(${qmltest_TARGET} ${qmltest_command})
282+ set(targets TARGETS ${QMLTEST_TARGETS})
283+ endif()
198
284
199− if(NOT "${qmltest_UNPARSED_ARGUMENTS}" STREQUAL "")
285+ set(xvfb_targets "")
200− set_tests_properties(${qmltest_TARGET} PROPERTIES ${qmltest_PROPERTIES})
286+ foreach(target ${QMLTEST_TARGETS})
201− elseif(NOT "${qmltest_DEFAULT_PROPERTIES}" STREQUAL "")
287+ if(TARGET xvfb${target})
202− set_tests_properties(${qmltest_TARGET} PROPERTIES ${qmltest_DEFAULT_PROPERTIES})
288+ list(APPEND xvfb_targets xvfb${target})
203 endif()
289 endif()
204− endif("${qmltest_NO_ADD_TEST}" STREQUAL FALSE AND NOT "${qmltest_DEFAULT_NO_ADD_TEST}" STREQUAL "TRUE")
205−
206− if("${qmltest_NO_TARGETS}" STREQUAL "FALSE")
207− if(NOT "${qmltest_TARGETS}" STREQUAL "")
208− foreach(TARGET ${qmltest_TARGETS})
209− add_dependencies(${TARGET} ${qmltest_TARGET})
210− endforeach(TARGET)
290+ endforeach()
211− elseif(NOT "${qmltest_DEFAULT_TARGETS}" STREQUAL "")
291+ set(xvfb_targets "${xvfb_targets}" PARENT_SCOPE)
212− foreach(TARGET ${qmltest_DEFAULT_TARGETS})
292+endmacro()
213− add_dependencies(${TARGET} ${qmltest_TARGET})
293+
214− endforeach(TARGET)
215− endif()
216− endif("${qmltest_NO_TARGETS}" STREQUAL "FALSE")
217
294
218−endmacro(add_qmltest_target)
295+# bake_arguments(prefix output
296+# arg1 [arg2 [...]]
297+# )
298+#
299+# If set, add the argument prefix before every passed
300+# argument and store the result in ${OUTPUT} variable.
301+
302+function(bake_arguments PREFIX OUTPUT)
303+ set(args "${ARGN}")
304+ if(PREFIX)
305+ set(args "")
306+ foreach(arg ${ARGN})
307+ list(APPEND args ${PREFIX})
308+ list(APPEND args ${arg})
309+ endforeach()
310+ endif()
311+ set(${OUTPUT} "${args}" PARENT_SCOPE)
312+endfunction()
debian/changelog+24−31
@@ -1,47 +1,40 @@
1−unity8 (8.10+15.10.20150616.1-0ubuntu1) wily; urgency=medium
1+unity8 (8.10+15.10.20150618-0ubuntu1) wily; urgency=medium
2
2
3 [ Albert Astals Cid ]
3 [ Albert Astals Cid ]
4− * Bind running to the proper object.visible
4+ * Refactor QmlTest.cmake module so that all tests can go through it.
5− * Do not use template in generated card creator code
5+ Also a bit of cleanup around tests.
6− * Fix regression introduced by the concierge change
6+ * Support fallback images for dash card and preview widgets (LP:
7− * Take into account the extra margin on top when calculating the
7+ #1324142)
8− display margin
9− * workaround oxide 1.7 issue (LP: #1459142)
10
8
11 [ CI Train Bot ]
9 [ CI Train Bot ]
12 * New rebuild forced.
10 * New rebuild forced.
11+ * Resync trunk.
13
12
14− [ Federico Gimenez ]
13+ [ Daniel d'Andrada ]
15− * On the autopilot helpers, swipe if the item to open from the dash is
14+ * Fix Shell tests
16− not visible. unity8-autopilot dependencies now require ubuntu-ui-
17− toolkit-autopilot (>= 1.2.1485+15.04.20150417.1-0ubuntu1)
18−
19− [ Florian Boucault ]
20− * Notifications: shaped icon was stretching the icon instead of
21− respecting its aspect ratio and filling the whole shape. (LP:
22− #1450229)
23
15
24 [ Josh Arenson ]
16 [ Josh Arenson ]
25− * Implement bare-bones shellMode=greeter and shellMode=shell
17+ * Refactor greeter emulator to unlock the greeter via dbus
26
18
27− [ Leo Arias ]
19+ [ Lukáš Tinkl ]
28− * On the autopilot helpers, swipe if the item to open from the dash is
20+ * respect target window's devicePixelRatio in MouseTouchAdaptor
29− not visible. unity8-autopilot dependencies now require ubuntu-ui-
30− toolkit-autopilot (>= 1.2.1485+15.04.20150417.1-0ubuntu1)
31−
32− [ Leonardo Arias Fonseca ]
33− * On the autopilot helpers, swipe if the item to open from the dash is
34− not visible. unity8-autopilot dependencies now require ubuntu-ui-
35− toolkit-autopilot (>= 1.2.1485+15.04.20150417.1-0ubuntu1)
36
21
37 [ Michael Zanetti ]
22 [ Michael Zanetti ]
38− * add info on how to run a single function in make test
23+ * Refactor QmlTest.cmake module so that all tests can go through it.
24+ Also a bit of cleanup around tests.
25+
26+ [ Michał Sawicz ]
27+ * Refactor QmlTest.cmake module so that all tests can go through it.
28+ Also a bit of cleanup around tests.
39
29
40− [ Richard Huddie ]
30+ [ handsome_feng ]
41− * Slow down the speed of autopilot helpers used to swipe to a
31+ * Forbid closing apps during the edge gesture. (LP: #1445572)
42− different scope to improve the reliability. (LP: #1461059, #1457047)
32+ * Removed the horizonal rule on pin unlock screen. (LP: #1368798)
33+
34+ [ handsome_feng<445865575@qq.com> ]
35+ * Forbid closing apps during the edge gesture. (LP: #1445572)
43
36
44− -- CI Train Bot <ci-train-bot@canonical.com> Tue, 16 Jun 2015 15:12:59 +0000
37+ -- CI Train Bot <ci-train-bot@canonical.com> Thu, 18 Jun 2015 19:40:06 +0000
45
38
46unity8 (8.10+15.10.20150612-0ubuntu2) wily; urgency=medium
39unity8 (8.10+15.10.20150612-0ubuntu2) wily; urgency=medium
47
40
plugins/Dash/CardCreator.js+8
@@ -389,6 +389,10 @@ function cardString(template, components) {
389 }
389 }
390
390
391 code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
391 code += kArtShapeHolderCode.arg(artAnchors).arg(widthCode).arg(heightCode);
392+ var fallback = components["art"] && components["art"]["fallback"] || "";
393+ if (fallback !== "") {
394+ code += 'Connections { target: artShapeLoader.item ? artShapeLoader.item.image : null; onStatusChanged: if (artShapeLoader.item.image.status === Image.Error) artShapeLoader.item.image.source = "%1"; } \n'.arg(fallback);
395+ }
392 } else {
396 } else {
393 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
397 code += 'readonly property size artShapeSize: Qt.size(-1, -1);\n'
394 }
398 }
@@ -468,6 +472,10 @@ function cardString(template, components) {
468
472
469 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
473 var mascotImageVisible = useMascotShape ? 'false' : 'showHeader';
470 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
474 mascotCode = kMascotImageCode.arg(mascotAnchors).arg(mascotImageVisible);
475+ var fallback = components["mascot"] && components["mascot"]["fallback"] || "";
476+ if (fallback !== "") {
477+ code += 'Connections { target: mascotImage.image; onStatusChanged: if (mascotImage.image.status === Image.Error) mascotImage.source = "%1"; } \n'.arg(fallback);
478+ }
471 }
479 }
472
480
473 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white")';
481 var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item && backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white")';
plugins/Wizard/PageList.cpp+1−1
@@ -45,7 +45,7 @@ PageList::PageList(QObject *parent)
45 QSet<QString> disabledPages;
45 QSet<QString> disabledPages;
46 QStringList dataDirs;
46 QStringList dataDirs;
47
47
48− if (!isRunningInstalled() && getenv("UNITY_TEST_ENV") == nullptr) {
48+ if (!isRunningInstalled() && getenv("WIZARD_TESTING") == nullptr) {
49 dataDirs << qmlDirectory();
49 dataDirs << qmlDirectory();
50 } else {
50 } else {
51 dataDirs = shellDataDirs();
51 dataDirs = shellDataDirs();
qml/Components/PinLockscreen.qml+1−5
@@ -52,7 +52,7 @@ Item {
52 verticalCenter: parent.verticalCenter;
52 verticalCenter: parent.verticalCenter;
53 verticalCenterOffset: Math.max(-units.gu(10), -(root.height - height) / 2) + units.gu(4)
53 verticalCenterOffset: Math.max(-units.gu(10), -(root.height - height) / 2) + units.gu(4)
54 }
54 }
55− spacing: units.gu(2)
55+ spacing: units.gu(4)
56
56
57 Column {
57 Column {
58 id: shakeContainer
58 id: shakeContainer
@@ -154,10 +154,6 @@ Item {
154 }
154 }
155 }
155 }
156
156
157− ThinDivider {
158− anchors { left: parent.left; right: parent.right; margins: units.gu(2) }
159− }
160−
161 Grid {
157 Grid {
162 id: numbersGrid
158 id: numbersGrid
163 objectName: "numbersGrid"
159 objectName: "numbersGrid"
qml/Components/ZoomableImage.qml+1
@@ -30,6 +30,7 @@ Item {
30 property var zoomable: false
30 property var zoomable: false
31 property alias imageStatus: imageRenderer.status
31 property alias imageStatus: imageRenderer.status
32 property alias asynchronous: imageRenderer.asynchronous
32 property alias asynchronous: imageRenderer.asynchronous
33+ readonly property alias status: imageRenderer.status
33
34
34 Flickable {
35 Flickable {
35 id: flickable
36 id: flickable
qml/Dash/Previews/PreviewHeader.qml+6
@@ -22,6 +22,7 @@ import "../"
22/*! This preview widget shows a header
22/*! This preview widget shows a header
23 * The title comes in widgetData["title"]
23 * The title comes in widgetData["title"]
24 * The mascot comes in widgetData["mascot"]
24 * The mascot comes in widgetData["mascot"]
25+ * The mascot fall back image comes in widgetData["fallback"]
25 * The subtitle comes in widgetData["subtitle"]
26 * The subtitle comes in widgetData["subtitle"]
26 * The attributes comes in widgetData["attributes"]
27 * The attributes comes in widgetData["attributes"]
27 */
28 */
@@ -35,11 +36,15 @@ PreviewWidget {
35 id: headerRoot
36 id: headerRoot
36 objectName: "innerPreviewHeader"
37 objectName: "innerPreviewHeader"
37 readonly property url mascot: root.widgetData["mascot"] || ""
38 readonly property url mascot: root.widgetData["mascot"] || ""
39+ readonly property url fallback: root.widgetData["fallback"] || ""
38 readonly property string title: root.widgetData["title"] || ""
40 readonly property string title: root.widgetData["title"] || ""
39 readonly property string subtitle: root.widgetData["subtitle"] || ""
41 readonly property string subtitle: root.widgetData["subtitle"] || ""
40 readonly property var attributes: root.widgetData["attributes"] || null
42 readonly property var attributes: root.widgetData["attributes"] || null
41 readonly property color fontColor: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
43 readonly property color fontColor: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
42
44
45+ // Rewire the source since we may have unwired it on onStatusChanged
46+ onMascotChanged: if (mascotShapeLoader.item) mascotShapeLoader.item.image.source = mascot;
47+
43 implicitHeight: row.height + row.margins * 2
48 implicitHeight: row.height + row.margins * 2
44 width: parent.width
49 width: parent.width
45
50
@@ -82,6 +87,7 @@ PreviewWidget {
82 fillMode: Image.PreserveAspectCrop
87 fillMode: Image.PreserveAspectCrop
83 horizontalAlignment: Image.AlignHCenter
88 horizontalAlignment: Image.AlignHCenter
84 verticalAlignment: Image.AlignVCenter
89 verticalAlignment: Image.AlignVCenter
90+ onStatusChanged: if (status === Image.Error) source = headerRoot.fallback;
85 }
91 }
86 }
92 }
87 }
93 }
qml/Dash/Previews/PreviewImageGallery.qml+14
@@ -20,6 +20,7 @@ import "../../Components"
20
20
21/*! This preview widget shows a horizontal list of images.
21/*! This preview widget shows a horizontal list of images.
22 * The URIs for the images should be an array in widgetData["sources"].
22 * The URIs for the images should be an array in widgetData["sources"].
23+ * Images fall back to widgetData["fallback"] if loading fails
23 */
24 */
24
25
25PreviewWidget {
26PreviewWidget {
@@ -72,6 +73,14 @@ PreviewWidget {
72 overlay.show();
73 overlay.show();
73 }
74 }
74 }
75 }
76+
77+ Connections {
78+ target: sourceImage
79+ // If modelData would change after failing to load it would not be
80+ // reloaded since the source binding is destroyed by the source = fallback
81+ // But at the moment the model never changes
82+ onStatusChanged: if (sourceImage.status === Image.Error) sourceImage.source = widgetData["fallback"];
83+ }
75 }
84 }
76 }
85 }
77
86
@@ -122,6 +131,11 @@ PreviewWidget {
122 source: modelData ? modelData : ""
131 source: modelData ? modelData : ""
123 fillMode: Image.PreserveAspectFit
132 fillMode: Image.PreserveAspectFit
124 sourceSize { width: screenshot.width; height: screenshot.height }
133 sourceSize { width: screenshot.width; height: screenshot.height }
134+
135+ // If modelData would change after failing to load it would not be
136+ // reloaded since the source binding is destroyed by the source = fallback
137+ // But at the moment the model never changes
138+ onStatusChanged: if (status === Image.Error) source = widgetData["fallback"];
125 }
139 }
126
140
127 MouseArea {
141 MouseArea {
qml/Dash/Previews/PreviewZoomableImage.qml+13
@@ -21,6 +21,7 @@ import "../../Components"
21/*! \brief Preview widget for image.
21/*! \brief Preview widget for image.
22
22
23 This widget shows image contained in widgetData["source"],
23 This widget shows image contained in widgetData["source"],
24+ and falls back to widgetData["fallback"] if loading fails
24 can be zoomable accordingly with widgetData["zoomable"].
25 can be zoomable accordingly with widgetData["zoomable"].
25 */
26 */
26
27
@@ -53,6 +54,14 @@ PreviewWidget {
53 overlay.show();
54 overlay.show();
54 }
55 }
55 }
56 }
57+
58+ Connections {
59+ target: lazyImage.sourceImage
60+ // If modelData would change after failing to load it would not be
61+ // reloaded since the source binding is destroyed by the source = fallback
62+ // But at the moment the model never changes
63+ onStatusChanged: if (lazyImage.sourceImage.status === Image.Error) lazyImage.sourceImage.source = widgetData["fallback"];
64+ }
56 }
65 }
57
66
58 PreviewOverlay {
67 PreviewOverlay {
@@ -67,6 +76,10 @@ PreviewWidget {
67 anchors.fill: parent
76 anchors.fill: parent
68 source: widgetData["source"]
77 source: widgetData["source"]
69 zoomable: widgetData["zoomable"] ? widgetData["zoomable"] : false
78 zoomable: widgetData["zoomable"] ? widgetData["zoomable"] : false
79+ // If modelData would change after failing to load it would not be
80+ // reloaded since the source binding is destroyed by the source = fallback
81+ // But at the moment the model never changes
82+ onStatusChanged: if (status === Image.Error) source = widgetData["fallback"];
70 }
83 }
71 }
84 }
72}
85}
qml/Stages/PhoneStage.qml+7
@@ -548,6 +548,13 @@ Rectangle {
548 }
548 }
549 }
549 }
550
550
551+ //eat touch events during the right edge gesture
552+ MouseArea {
553+ objectName: "eventEaterArea"
554+ anchors.fill: parent
555+ enabled: spreadDragArea.dragging
556+ }
557+
551 DirectionalDragArea {
558 DirectionalDragArea {
552 id: spreadDragArea
559 id: spreadDragArea
553 objectName: "spreadDragArea"
560 objectName: "spreadDragArea"
qml/Stages/TabletStage.qml+6
@@ -724,6 +724,12 @@ Rectangle {
724 }
724 }
725 }
725 }
726
726
727+ //eat touch events during the right edge gesture
728+ MouseArea {
729+ anchors.fill: parent
730+ enabled: spreadDragArea.dragging
731+ }
732+
727 DirectionalDragArea {
733 DirectionalDragArea {
728 id: spreadDragArea
734 id: spreadDragArea
729 objectName: "spreadDragArea"
735 objectName: "spreadDragArea"
runtests.sh+1−1
@@ -41,7 +41,7 @@ sleep 1
41
41
42cd -
42cd -
43
43
44−make -k qmltests
44+make -k xvfballtests
45if [ $? -ne 0 ]; then
45if [ $? -ne 0 ]; then
46 echo '<?xml version="1.0" encoding="UTF-8" ?><testsuite errors="0" failures="1" tests="1" name="makeExitStatusTest"><properties/><testcase result="fail" name="makeExitStatus"><failure message="Make test did not suceed" result="fail"/></testcase><system-err/></testsuite>' > testMakeExitStatus.xml
46 echo '<?xml version="1.0" encoding="UTF-8" ?><testsuite errors="0" failures="1" tests="1" name="makeExitStatusTest"><properties/><testcase result="fail" name="makeExitStatus"><failure message="Make test did not suceed" result="fail"/></testcase><system-err/></testsuite>' > testMakeExitStatus.xml
47fi
47fi
src/MouseTouchAdaptor.cpp+6−6
@@ -104,10 +104,10 @@ bool MouseTouchAdaptor::handleButtonPress(xcb_button_press_event_t *pressEvent)
104 if (button != Qt::LeftButton)
104 if (button != Qt::LeftButton)
105 return true;
105 return true;
106
106
107− QPoint windowPos(pressEvent->event_x, pressEvent->event_y);
108−
109 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(pressEvent->event));
107 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(pressEvent->event));
110
108
109+ QPoint windowPos(pressEvent->event_x / targetWindow->devicePixelRatio(), pressEvent->event_y / targetWindow->devicePixelRatio());
110+
111 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
111 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
112 false /* autoCommit */);
112 false /* autoCommit */);
113 touchEvent.press(0 /* touchId */, windowPos);
113 touchEvent.press(0 /* touchId */, windowPos);
@@ -125,10 +125,10 @@ bool MouseTouchAdaptor::handleButtonRelease(xcb_button_release_event_t *releaseE
125 if (button != Qt::LeftButton)
125 if (button != Qt::LeftButton)
126 return true;
126 return true;
127
127
128− QPoint windowPos(releaseEvent->event_x, releaseEvent->event_y);
129−
130 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(releaseEvent->event));
128 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(releaseEvent->event));
131
129
130+ QPoint windowPos(releaseEvent->event_x / targetWindow->devicePixelRatio(), releaseEvent->event_y / targetWindow->devicePixelRatio());
131+
132 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
132 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
133 false /* autoCommit */);
133 false /* autoCommit */);
134 touchEvent.release(0 /* touchId */, windowPos);
134 touchEvent.release(0 /* touchId */, windowPos);
@@ -144,10 +144,10 @@ bool MouseTouchAdaptor::handleMotionNotify(xcb_motion_notify_event_t *event)
144 return true;
144 return true;
145 }
145 }
146
146
147− QPoint windowPos(event->event_x, event->event_y);
148−
149 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(event->event));
147 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(event->event));
150
148
149+ QPoint windowPos(event->event_x / targetWindow->devicePixelRatio(), event->event_y / targetWindow->devicePixelRatio());
150+
151 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
151 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice,
152 false /* autoCommit */);
152 false /* autoCommit */);
153 touchEvent.move(0 /* touchId */, windowPos);
153 touchEvent.move(0 /* touchId */, windowPos);
tests/CMakeLists.txt+120−8
@@ -1,16 +1,128 @@
1+include(QmlTest)
2+
1# QML tests that do not require graphical capabilities.
3# QML tests that do not require graphical capabilities.
2−add_custom_target(qmlunittests)
4+add_custom_target(unittests)
3
5
4# QML tests that require graphical capabilities.
6# QML tests that require graphical capabilities.
5−add_custom_target(qmluitests)
7+add_custom_target(uitests)
8+add_custom_target(xvfbuitests)
6
9
7−add_custom_target(qmltests)
10+add_custom_target(alltests)
8−add_dependencies(qmltests qmlunittests qmluitests)
11+add_dependencies(alltests unittests uitests)
9
12
10−add_subdirectory(libs)
13+add_custom_target(xvfballtests)
11−add_subdirectory(qmltests)
14+add_dependencies(xvfballtests unittests xvfbuitests)
15+
16+# Support libraries and plugins
12add_subdirectory(mocks)
17add_subdirectory(mocks)
13−add_subdirectory(whitespace)
14−add_subdirectory(plugins)
15add_subdirectory(utils)
18add_subdirectory(utils)
16add_subdirectory(uqmlscene)
19add_subdirectory(uqmlscene)
20+
21+# Use our custom implementation of qmlscene and import dbus-test-runner
22+add_executable(qmlscene ALIAS uqmlscene)
23+import_executables(dbus-test-runner)
24+
25+set(UNITY_IMPORT_PATHS
26+ ${CMAKE_BINARY_DIR}/tests/mocks
27+ ${CMAKE_BINARY_DIR}/tests/utils/modules
28+ ${CMAKE_BINARY_DIR}/plugins
29+)
30+set(UNITY_IMPORT_PATHS ${UNITY_IMPORT_PATHS} CACHE INTERNAL "")
31+
32+macro(unity8_parse_arguments)
33+ cmake_parse_arguments(U8TEST
34+ "${QMLTEST_OPTIONS};LIGHTDM"
35+ "${QMLTEST_SINGLE}"
36+ "${QMLTEST_MULTI}"
37+ ${ARGN}
38+ )
39+
40+ set(ld_paths)
41+ if(U8TEST_LIGHTDM)
42+ list(APPEND ld_paths
43+ ${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics
44+ ${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm
45+ )
46+ endif()
47+
48+ if(ld_paths)
49+ string(REPLACE ";" ":" ld_library_path "${ld_paths}")
50+ set(ld_library_path LD_LIBRARY_PATH=${ld_library_path})
51+ endif()
52+
53+ set(U8TEST_ARGN "${ARGN}")
54+ list(REMOVE_ITEM U8TEST_ARGN LIGHTDM)
55+
56+ set(environment
57+ UNITY_TESTING=1
58+ LANGUAGE=C
59+ LC_ALL=C.UTF-8
60+ ${ld_library_path}
61+ )
62+endmacro()
63+
64+
65+# add a non-graphical unit test
66+# see QmlTest.cmake for additional options
67+function(add_unity8_unittest COMPONENT_NAME TARGET)
68+ unity8_parse_arguments(${ARGN})
69+ add_executable_test(${COMPONENT_NAME} ${TARGET}
70+ ADD_TEST
71+ IMPORT_PATHS ${UNITY_IMPORT_PATHS}
72+ TARGETS unittests
73+ ${U8TEST_ARGN}
74+ ENVIRONMENT ${environment}
75+ QT_QPA_PLATFORM=minimal
76+ ${U8TEST_ENVIRONMENT}
77+ )
78+endfunction()
79+
80+# add a graphical unit test
81+function(add_unity8_uitest COMPONENT_NAME TARGET)
82+ unity8_parse_arguments(${ARGN})
83+ add_executable_test(${COMPONENT_NAME} ${TARGET}
84+ IMPORT_PATHS ${UNITY_IMPORT_PATHS}
85+ TARGETS uitests
86+ ${U8TEST_ARGN}
87+ ENVIRONMENT ${environment}
88+ ${U8TEST_ENVIRONMENT}
89+ )
90+endfunction()
91+
92+# add a non-graphical qml unit test
93+function(add_unity8_qmlunittest PATH COMPONENT_NAME)
94+ unity8_parse_arguments(${ARGN})
95+ add_qml_unittest(${PATH} ${COMPONENT_NAME}
96+ ADD_TEST
97+ IMPORT_PATHS ${UNITY_IMPORT_PATHS}
98+ TARGET unittests
99+ ${U8TEST_ARGN}
100+ ENVIRONMENT ${environment}
101+ QT_QPA_PLATFORM=minimal
102+ ${U8TEST_ENVIRONMENT}
103+ )
104+endfunction()
105+
106+# add a graphical qml test
107+function(add_unity8_qmltest PATH COMPONENT_NAME)
108+ unity8_parse_arguments(${ARGN})
109+ add_qml_test(${PATH} ${COMPONENT_NAME}
110+ IMPORT_PATHS ${UNITY_IMPORT_PATHS}
111+ TARGETS uitests
112+ ${U8TEST_ARGN}
113+ ENVIRONMENT ${environment}
114+ ${U8TEST_ENVIRONMENT}
115+ )
116+endfunction()
117+
118+# add a graphical qml benchmark
119+function(add_unity8_qmlbenchmark PATH COMPONENT_NAME ITERATIONS)
120+ add_unity8_qmltest(${PATH} ${COMPONENT_NAME} ITERATIONS ${ITERATIONS} ${ARGN})
121+endfunction()
122+
123+
124+# Actual test definitions
125+add_subdirectory(libs)
126+add_subdirectory(plugins)
127+add_subdirectory(qmltests)
128+add_subdirectory(whitespace)
tests/autopilot/unity8/application_lifecycle/tests/__init__.py+2−2
@@ -31,8 +31,8 @@ class ApplicationLifeCycleTestCase(tests.UnityTestCase):
31 super().setUp()
31 super().setUp()
32 self._qml_mock_enabled = False
32 self._qml_mock_enabled = False
33 self._data_dirs_mock_enabled = False
33 self._data_dirs_mock_enabled = False
34− unity_proxy = self.launch_unity()
34+ self.launch_unity()
35− process_helpers.unlock_unity(unity_proxy)
35+ process_helpers.unlock_unity()
36
36
37 def create_test_application(self):
37 def create_test_application(self):
38 desktop_file_dict = fixture_setup.DEFAULT_DESKTOP_FILE_DICT
38 desktop_file_dict = fixture_setup.DEFAULT_DESKTOP_FILE_DICT
tests/autopilot/unity8/greeter/__init__.py+52
@@ -0,0 +1,52 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+#
3+# Unity Autopilot Test Suite
4+# Copyright (C) 2015 Canonical
5+#
6+# This program is free software: you can redistribute it and/or modify
7+# it under the terms of the GNU General Public License as published by
8+# the Free Software Foundation, either version 3 of the License, or
9+# (at your option) any later version.
10+#
11+# This program is distributed in the hope that it will be useful,
12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+# GNU General Public License for more details.
15+#
16+# You should have received a copy of the GNU General Public License
17+# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#
19+
20+import dbus
21+
22+from autopilot.matchers import Eventually
23+from testtools.matchers import Equals
24+
25+
26+def hide_greeter_with_dbus():
27+ dbus_proxy = _get_greeter_dbus_proxy()
28+ if _is_greeter_active():
29+ dbus_proxy.HideGreeter()
30+
31+
32+def show_greeter_with_dbus():
33+ dbus_proxy = _get_greeter_dbus_proxy()
34+ if not _is_greeter_active():
35+ dbus_proxy.ShowGreeter()
36+
37+
38+def wait_for_greeter():
39+ Eventually(Equals(True), timeout=300).match(_is_greeter_active)
40+
41+
42+def _get_greeter_dbus_proxy():
43+ bus = dbus.SessionBus()
44+ return bus.get_object('com.canonical.UnityGreeter', '/')
45+
46+
47+def _is_greeter_active():
48+ try:
49+ dbus_proxy = _get_greeter_dbus_proxy()
50+ return dbus_proxy.Get('com.canonical.UnityGreeter', 'IsActive')
51+ except:
52+ return False
tests/autopilot/unity8/indicators/tests/__init__.py+1−1
@@ -31,7 +31,7 @@ class IndicatorTestCase(tests.UnityTestCase):
31 def setUp(self):
31 def setUp(self):
32 super().setUp()
32 super().setUp()
33 self.unity_proxy = self.launch_unity()
33 self.unity_proxy = self.launch_unity()
34− process_helpers.unlock_unity(self.unity_proxy)
34+ process_helpers.unlock_unity()
35
35
36
36
37class DeviceIndicatorTestCase(IndicatorTestCase):
37class DeviceIndicatorTestCase(IndicatorTestCase):
tests/autopilot/unity8/process_helpers.py+7−94
@@ -19,14 +19,11 @@
19
19
20import logging
20import logging
21import subprocess
21import subprocess
22−import dbus
23
22
24import ubuntuuitoolkit
23import ubuntuuitoolkit
25−from autopilot.exceptions import ProcessSearchError
26from autopilot.introspection import get_proxy_object_for_existing_process
24from autopilot.introspection import get_proxy_object_for_existing_process
27
25
28−from unity8.shell import emulators
26+from unity8 import greeter
29−from unity8.shell.emulators import main_window as main_window_emulator
30
27
31logger = logging.getLogger(__name__)
28logger = logging.getLogger(__name__)
32
29
@@ -39,104 +36,20 @@ class CannotAccessUnity(Exception):
39 pass
36 pass
40
37
41
38
42−def unlock_unity(unity_proxy_obj=None):
39+def unlock_unity():
43 """Helper function that attempts to unlock the unity greeter.
40 """Helper function that attempts to unlock the unity greeter.
44
41
45− If unity_proxy_object is None create a proxy object by querying for the
46− running unity process.
47− Otherwise re-use the passed proxy object.
48−
49− :raises RuntimeError: if the greeter attempts and fails to be unlocked.
50−
51− :raises RuntimeWarning: when the greeter cannot be found because it is
52− already unlocked.
53− :raises CannotAccessUnity: if unity is not introspectable or cannot be
54− found on dbus.
55− :raises CannotAccessUnity: if unity's upstart status is not "start" or the
56− upstart job cannot be found at all.
57−
58 """
42 """
59− if unity_proxy_obj is None:
43+ greeter.wait_for_greeter()
60− try:
44+ greeter.hide_greeter_with_dbus()
61− pid = get_unity_pid()
62− unity = _get_unity_proxy_object(pid)
63− main_window = unity.select_single(main_window_emulator.QQuickView)
64− except ProcessSearchError as e:
65− raise CannotAccessUnity(
66− "Cannot introspect unity, make sure that it has been started "
67− "with testability. Perhaps use the function "
68− "'restart_unity_with_testability' this module provides."
69− "(%s)"
70− % str(e)
71− )
72− else:
73− main_window = unity_proxy_obj.select_single(
74− main_window_emulator.QQuickView)
75−
76− greeter = main_window.get_greeter()
77− if greeter.created is False:
78− raise RuntimeWarning("Greeter appears to be already unlocked.")
79−
80− bus = dbus.SessionBus()
81− dbus_proxy = bus.get_object("com.canonical.UnityGreeter", "/")
82− try:
83− dbus_proxy.HideGreeter()
84− except dbus.DBusException:
85− logger.info("Failed to unlock greeter")
86− raise
87− else:
88− greeter.created.wait_for(False)
89− logger.info("Greeter unlocked, continuing.")
90
45
91
46
92−def lock_unity(unity_proxy_obj=None):
47+def lock_unity():
93 """Helper function that attempts to lock unity greeter.
48 """Helper function that attempts to lock unity greeter.
94
49
95− If unity_proxy_object is None create a proxy object by querying for the
96− running unity process.
97− Otherwise re-use the passed proxy object.
98−
99− :raises RuntimeError: if the greeter attempts and fails to be locked.
100−
101− :raises RuntimeWarning: when the greeter is found because it is
102− already locked.
103− :raises CannotAccessUnity: if unity is not introspectable or cannot be
104− found on dbus.
105− :raises CannotAccessUnity: if unity's upstart status is not "start" or the
106− upstart job cannot be found at all.
107−
108 """
50 """
109− if unity_proxy_obj is None:
51+ greeter.show_greeter_with_dbus()
110− try:
52+ greeter.wait_for_greeter()
111− pid = get_unity_pid()
112− unity = _get_unity_proxy_object(pid)
113− main_window = unity.select_single(main_window_emulator.QQuickView)
114− except ProcessSearchError as e:
115− raise CannotAccessUnity(
116− "Cannot introspect unity, make sure that it has been started "
117− "with testability. Perhaps use the function "
118− "'restart_unity_with_testability' this module provides."
119− "(%s)"
120− % str(e)
121− )
122− else:
123− main_window = unity_proxy_obj.select_single(
124− main_window_emulator.QQuickView)
125−
126− greeter = main_window.get_greeter()
127− if greeter.created is True:
128− raise RuntimeWarning("Greeter appears to be already locked.")
129−
130− bus = dbus.SessionBus()
131− dbus_proxy = bus.get_object("com.canonical.UnityGreeter", "/")
132− try:
133− dbus_proxy.ShowGreeter()
134− except dbus.DBusException:
135− logger.info("Failed to lock greeter")
136− raise
137− else:
138− greeter.created.wait_for(True)
139− logger.info("Greeter locked, continuing.")
140
53
141
54
142def restart_unity_with_testability(*args):
55def restart_unity_with_testability(*args):
tests/autopilot/unity8/shell/tests/test_emulators.py+2−2
@@ -41,8 +41,8 @@ class MainWindowTestCase(tests.UnityTestCase):
41
41
42 def setUp(self):
42 def setUp(self):
43 super().setUp()
43 super().setUp()
44− unity_proxy = self.launch_unity()
44+ self.launch_unity()
45− process_helpers.unlock_unity(unity_proxy)
45+ process_helpers.unlock_unity()
46
46
47
47
48class DashEmulatorTestCase(tests.DashBaseTestCase):
48class DashEmulatorTestCase(tests.DashBaseTestCase):
tests/autopilot/unity8/shell/tests/test_notifications.py+22−22
@@ -119,8 +119,8 @@ class InteractiveNotificationBase(NotificationsBase):
119
119
120 def test_interactive(self):
120 def test_interactive(self):
121 """Interactive notification must react upon click on itself."""
121 """Interactive notification must react upon click on itself."""
122− unity_proxy = self.launch_unity()
122+ self.launch_unity()
123− unlock_unity(unity_proxy)
123+ unlock_unity()
124
124
125 notify_list = self._get_notifications_list()
125 notify_list = self._get_notifications_list()
126
126
@@ -156,8 +156,8 @@ class InteractiveNotificationBase(NotificationsBase):
156 """Snap-decision with three actions should use
156 """Snap-decision with three actions should use
157 one-over two button layout.
157 one-over two button layout.
158 """
158 """
159− unity_proxy = self.launch_unity()
159+ self.launch_unity()
160− unlock_unity(unity_proxy)
160+ unlock_unity()
161
161
162 summary = "Theatre at Ferria Stadium"
162 summary = "Theatre at Ferria Stadium"
163 body = "at Ferria Stadium in Bilbao, Spain\n07578545317"
163 body = "at Ferria Stadium in Bilbao, Spain\n07578545317"
@@ -197,8 +197,8 @@ class InteractiveNotificationBase(NotificationsBase):
197 """Snap-decision should block input to shell
197 """Snap-decision should block input to shell
198 without greeter/lockscreen.
198 without greeter/lockscreen.
199 """
199 """
200− unity_proxy = self.launch_unity()
200+ self.launch_unity()
201− unlock_unity(unity_proxy)
201+ unlock_unity()
202
202
203 summary = "Incoming file"
203 summary = "Incoming file"
204 body = "Frank would like to send you the file: essay.pdf"
204 body = "Frank would like to send you the file: essay.pdf"
@@ -421,8 +421,8 @@ class EphemeralNotificationsTests(NotificationsBase):
421
421
422 def test_icon_summary_body(self):
422 def test_icon_summary_body(self):
423 """Notification must display the expected summary and body text."""
423 """Notification must display the expected summary and body text."""
424− unity_proxy = self.launch_unity()
424+ self.launch_unity()
425− unlock_unity(unity_proxy)
425+ unlock_unity()
426
426
427 notify_list = self._get_notifications_list()
427 notify_list = self._get_notifications_list()
428
428
@@ -458,8 +458,8 @@ class EphemeralNotificationsTests(NotificationsBase):
458 def test_icon_summary(self):
458 def test_icon_summary(self):
459 """Notification must display the expected summary and secondary
459 """Notification must display the expected summary and secondary
460 icon."""
460 icon."""
461− unity_proxy = self.launch_unity()
461+ self.launch_unity()
462− unlock_unity(unity_proxy)
462+ unlock_unity()
463
463
464 notify_list = self._get_notifications_list()
464 notify_list = self._get_notifications_list()
465
465
@@ -491,8 +491,8 @@ class EphemeralNotificationsTests(NotificationsBase):
491 def test_urgency_order(self):
491 def test_urgency_order(self):
492 """Notifications must be displayed in order according to their
492 """Notifications must be displayed in order according to their
493 urgency."""
493 urgency."""
494− unity_proxy = self.launch_unity()
494+ self.launch_unity()
495− unlock_unity(unity_proxy)
495+ unlock_unity()
496
496
497 notify_list = self._get_notifications_list()
497 notify_list = self._get_notifications_list()
498
498
@@ -578,8 +578,8 @@ class EphemeralNotificationsTests(NotificationsBase):
578
578
579 def test_summary_and_body(self):
579 def test_summary_and_body(self):
580 """Notification must display the expected summary- and body-text."""
580 """Notification must display the expected summary- and body-text."""
581− unity_proxy = self.launch_unity()
581+ self.launch_unity()
582− unlock_unity(unity_proxy)
582+ unlock_unity()
583
583
584 notify_list = self._get_notifications_list()
584 notify_list = self._get_notifications_list()
585
585
@@ -603,8 +603,8 @@ class EphemeralNotificationsTests(NotificationsBase):
603
603
604 def test_summary_only(self):
604 def test_summary_only(self):
605 """Notification must display only the expected summary-text."""
605 """Notification must display only the expected summary-text."""
606− unity_proxy = self.launch_unity()
606+ self.launch_unity()
607− unlock_unity(unity_proxy)
607+ unlock_unity()
608
608
609 notify_list = self._get_notifications_list()
609 notify_list = self._get_notifications_list()
610
610
@@ -621,8 +621,8 @@ class EphemeralNotificationsTests(NotificationsBase):
621 def test_update_notification_same_layout(self):
621 def test_update_notification_same_layout(self):
622 """Notification must allow updating its contents while being
622 """Notification must allow updating its contents while being
623 displayed."""
623 displayed."""
624− unity_proxy = self.launch_unity()
624+ self.launch_unity()
625− unlock_unity(unity_proxy)
625+ unlock_unity()
626
626
627 notify_list = self._get_notifications_list()
627 notify_list = self._get_notifications_list()
628
628
@@ -660,8 +660,8 @@ class EphemeralNotificationsTests(NotificationsBase):
660 def test_update_notification_layout_change(self):
660 def test_update_notification_layout_change(self):
661 """Notification must allow updating its contents and layout while
661 """Notification must allow updating its contents and layout while
662 being displayed."""
662 being displayed."""
663− unity_proxy = self.launch_unity()
663+ self.launch_unity()
664− unlock_unity(unity_proxy)
664+ unlock_unity()
665
665
666 notify_list = self._get_notifications_list()
666 notify_list = self._get_notifications_list()
667
667
@@ -709,8 +709,8 @@ class EphemeralNotificationsTests(NotificationsBase):
709 """ use the create notification script to get a notification dialog.
709 """ use the create notification script to get a notification dialog.
710 Check that the arguments passed to the script match the fields. """
710 Check that the arguments passed to the script match the fields. """
711
711
712− unity_proxy = self.launch_unity()
712+ self.launch_unity()
713− unlock_unity(unity_proxy)
713+ unlock_unity()
714
714
715 summary = 'Helper summary'
715 summary = 'Helper summary'
716 body = 'Helper body'
716 body = 'Helper body'
tests/copyright/CMakeLists.txt+1−1
@@ -2,5 +2,5 @@
2# Test that all source files contain a copyright header.
2# Test that all source files contain a copyright header.
3#
3#
4
4
5−add_test(copyright ${CMAKE_CURRENT_SOURCE_DIR}/check_copyright.sh
5+add_test(Copyright ${CMAKE_CURRENT_SOURCE_DIR}/check_copyright.sh
6 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
6 ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
tests/libs/UbuntuGestures/CMakeLists.txt+4−8
@@ -4,17 +4,13 @@ include_directories(
4 )
4 )
5
5
6macro(add_gesture_test CLASSNAME)
6macro(add_gesture_test CLASSNAME)
7− set(testCommand
8− ${CLASSNAME}TestExec -o ${CMAKE_BINARY_DIR}/test${CLASSNAME}.xml,xunitxml -o -,txt)
9−
10− add_test(NAME test${CLASSNAME} COMMAND ${testCommand})
11−
12− set_tests_properties(test${CLASSNAME} PROPERTIES
13− ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/libs/UbuntuGestures)
14−
15 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp)
7 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp)
16 qt5_use_modules(${CLASSNAME}TestExec Test Core Gui Quick)
8 qt5_use_modules(${CLASSNAME}TestExec Test Core Gui Quick)
17 target_link_libraries(${CLASSNAME}TestExec UbuntuGestures)
9 target_link_libraries(${CLASSNAME}TestExec UbuntuGestures)
10+
11+ add_unity8_unittest(${CLASSNAME} ${CLASSNAME}TestExec
12+ ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/libs/UbuntuGestures
13+ )
18endmacro(add_gesture_test)
14endmacro(add_gesture_test)
19
15
20add_gesture_test(TouchRegistry)
16add_gesture_test(TouchRegistry)
tests/plugins/AccountsService/CMakeLists.txt+5−4
@@ -43,12 +43,13 @@ add_executable(test-accountsservice
43 )
43 )
44qt5_use_modules(test-accountsservice Core DBus Test)
44qt5_use_modules(test-accountsservice Core DBus Test)
45
45
46−add_test(NAME test-accountsservice
47− COMMAND dbus-test-runner
46+add_unity8_unittest(AccountsService dbus-test-runner
47+ ARG_PREFIX "--parameter"
48+ ARGS
48− --task ${CMAKE_CURRENT_BINARY_DIR}/mock-server
49+ --task $<TARGET_FILE:mock-server>
49 --task-name server
50 --task-name server
50 --ignore-return
51 --ignore-return
51− --task ${CMAKE_CURRENT_BINARY_DIR}/test-accountsservice
52+ --task $<TARGET_FILE:test-accountsservice>
52 --task-name client
53 --task-name client
53 --wait-for org.freedesktop.Accounts
54 --wait-for org.freedesktop.Accounts
54 )
55 )
tests/plugins/Dash/CMakeLists.txt+10−17
@@ -32,7 +32,7 @@ macro(add_lvwph_test FILENAME TESTNAME)
32 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
32 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
33 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
33 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
34
34
35− add_binary_qml_test(${TESTNAME} "" "Dash-qml" "")
35+ add_unity8_uitest(${TESTNAME} ${TESTNAME}TestExec DEPENDS Dash-qml)
36endmacro()
36endmacro()
37
37
38add_lvwph_test(listviewwithpageheader ListViewWithPageHeader)
38add_lvwph_test(listviewwithpageheader ListViewWithPageHeader)
@@ -48,19 +48,16 @@ macro(add_dashview_try_test FILENAME TESTNAME)
48 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
48 qt5_use_modules(${TESTNAME}TestExec Test Core Qml)
49 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
49 target_link_libraries(${TESTNAME}TestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
50
50
51− add_binary_qml_test(${TESTNAME} "" "Dash-qml" "")
51+ add_unity8_uitest(${TESTNAME} ${TESTNAME}TestExec DEPENDS Dash-qml)
52
52
53− add_executable(${TESTNAME}tryExec
53+ add_executable(${TESTNAME}TryExec
54 ${FILENAME}try.cpp
54 ${FILENAME}try.cpp
55 ${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/Dash/${FILENAME}.cpp
55 ${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/Dash/${FILENAME}.cpp
56 ${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/Dash/abstractdashview.cpp
56 ${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/Dash/abstractdashview.cpp
57 )
57 )
58− qt5_use_modules(${TESTNAME}tryExec Test Core Qml)
58+ qt5_use_modules(${TESTNAME}TryExec Test Core Qml)
59− target_link_libraries(${TESTNAME}tryExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
59+ target_link_libraries(${TESTNAME}TryExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
60− add_custom_target(try${TESTNAME}
60+ add_manual_test(${TESTNAME} ${TESTNAME}TryExec DEPENDS Dash-qml)
61− ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME}tryExec
62− DEPENDS ${TESTNAME}tryExec Dash-qml
63− )
64endmacro()
61endmacro()
65
62
66add_dashview_try_test(verticaljournal VerticalJournal)
63add_dashview_try_test(verticaljournal VerticalJournal)
@@ -71,13 +68,9 @@ add_dashview_try_test(organicgrid OrganicGrid)
71add_executable(CardCreatorTestExec cardcreatortest.cpp)
68add_executable(CardCreatorTestExec cardcreatortest.cpp)
72qt5_use_modules(CardCreatorTestExec Test Core Qml)
69qt5_use_modules(CardCreatorTestExec Test Core Qml)
73target_link_libraries(CardCreatorTestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
70target_link_libraries(CardCreatorTestExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
74−add_binary_qml_test(CardCreator "" "Dash-qml" "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks/")
71+add_unity8_uitest(CardCreator CardCreatorTestExec DEPENDS Dash-qml)
75
72
76# plain qml test
73# plain qml test
77−set(qmltest_DEFAULT_TARGETS qmluitests)
74+foreach(dash_test ScopeStyle ListViewWithPageHeaderQML CardAttributes CroppedImageMinimumSourceSize)
78−set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
75+ add_unity8_qmltest(. ${dash_test})
79−set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C")
76+endforeach()
80−add_qml_test(. ScopeStyle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
81−add_qml_test(. ListViewWithPageHeaderQML IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
82−add_qml_test(. CardAttributes IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
83−add_qml_test(. CroppedImageMinimumSourceSize IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
tests/plugins/Greeter/Unity/Launcher/CMakeLists.txt+4−5
@@ -13,11 +13,6 @@ add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
13add_definitions(-DLAUNCHER_TESTING)
13add_definitions(-DLAUNCHER_TESTING)
14
14
15### LauncherModelASTest
15### LauncherModelASTest
16−set(testModelCommand dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/launchermodelastestExec
17− --parameter -o --parameter ${CMAKE_BINARY_DIR}/launchermodeltest.xml,xunitxml
18− --parameter -o --parameter -,txt)
19−add_test(NAME launchermodelastest COMMAND ${testModelCommand})
20−add_custom_target(launchermodelastest ${testModelCommand})
21add_executable(launchermodelastestExec
16add_executable(launchermodelastestExec
22 launchermodelastest.cpp
17 launchermodelastest.cpp
23 AccountsServiceDBusAdaptor.cpp
18 AccountsServiceDBusAdaptor.cpp
@@ -36,6 +31,10 @@ target_link_libraries(launchermodelastestExec
36 ${GSETTINGS_QT_LDFLAGS}
31 ${GSETTINGS_QT_LDFLAGS}
37 )
32 )
38qt5_use_modules(launchermodelastestExec Test Core DBus Gui)
33qt5_use_modules(launchermodelastestExec Test Core DBus Gui)
34+add_unity8_unittest(LauncherModelAS dbus-test-runner
35+ ARG_PREFIX "--parameter"
36+ ARGS --task $<TARGET_FILE:launchermodelastestExec>
37+)
39
38
40# copy .desktop files into build directory for shadow builds
39# copy .desktop files into build directory for shadow builds
41file(GLOB DESKTOP_FILES *.desktop)
40file(GLOB DESKTOP_FILES *.desktop)
tests/plugins/LightDM/CMakeLists.txt+13−4
@@ -18,7 +18,13 @@ target_include_directories(GreeterDBusTestExec PUBLIC
18 ${CMAKE_SOURCE_DIR}/plugins/LightDM
18 ${CMAKE_SOURCE_DIR}/plugins/LightDM
19 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM
19 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM
20 )
20 )
21−add_binary_qml_test(GreeterDBus "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm" MockLightDM "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks")
21+add_unity8_uitest(GreeterDBus dbus-test-runner
22+ ARG_PREFIX "--parameter"
23+ ARGS --task $<TARGET_FILE:GreeterDBusTestExec>
24+ DEPENDS MockLightDM
25+ IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks
26+ LIGHTDM
27+ )
22
28
23add_executable(GreeterPamTestExec
29add_executable(GreeterPamTestExec
24 pam.cpp
30 pam.cpp
@@ -31,8 +37,7 @@ target_link_libraries(GreeterPamTestExec
31target_include_directories(GreeterPamTestExec PUBLIC
37target_include_directories(GreeterPamTestExec PUBLIC
32 ${CMAKE_SOURCE_DIR}/plugins/LightDM/liblightdm
38 ${CMAKE_SOURCE_DIR}/plugins/LightDM/liblightdm
33 )
39 )
34−add_qmltest_target(testGreeterPam "${CMAKE_CURRENT_BINARY_DIR}/GreeterPamTestExec" TRUE FALSE)
40+add_qmltest_target(testGreeterPam GreeterPamTestExec COMMAND $<TARGET_FILE:GreeterPamTestExec>)
35−add_dependencies(testGreeterPam GreeterPamTestExec)
36
41
37add_executable(GreeterUsersModelTestExec
42add_executable(GreeterUsersModelTestExec
38 usersmodel.cpp
43 usersmodel.cpp
@@ -49,4 +54,8 @@ target_include_directories(GreeterUsersModelTestExec PUBLIC
49 ${CMAKE_SOURCE_DIR}/plugins/Utils
54 ${CMAKE_SOURCE_DIR}/plugins/Utils
50 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM
55 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM
51 )
56 )
52−add_binary_qml_test(GreeterUsersModel "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm" MockLightDM "LIBLIGHTDM_MOCK_MODE=full")
57+add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec
58+ ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full
59+ DEPENDS MockLightDM
60+ LIGHTDM
61+ )
tests/plugins/Ubuntu/Gestures/CMakeLists.txt+22−24
@@ -12,43 +12,41 @@ include_directories(
12 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
12 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
13 )
13 )
14
14
15−file(GLOB qmlFiles *.qml)
15+export_qmlfiles(UbuntuGesturesTest .)
16−add_custom_target(UbuntuGesturesTestQmlFiles ALL
17− COMMAND cp ${qmlFiles} ${CMAKE_CURRENT_BINARY_DIR}
18− DEPENDS ${qmlFiles}
19−)
20
16
21add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
17add_definitions(-DUBUNTU_GESTURES_PLUGIN_DIR="${CMAKE_BINARY_DIR}/plugins")
22add_definitions(-DTESTS_UTILS_MODULES_DIR="${CMAKE_BINARY_DIR}/tests/utils/modules")
18add_definitions(-DTESTS_UTILS_MODULES_DIR="${CMAKE_BINARY_DIR}/tests/utils/modules")
23
19
24−macro(add_gesture_ui_test CLASSNAME)
20+macro(build_gesture_test CLASSNAME)
25 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp TestItem.cpp)
21 add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp GestureTest.cpp TestItem.cpp)
26 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
22 qt5_use_modules(${CLASSNAME}TestExec Test Core Qml Gui Quick)
27 target_link_libraries(${CLASSNAME}TestExec UbuntuGesturesQml UbuntuGestures)
23 target_link_libraries(${CLASSNAME}TestExec UbuntuGesturesQml UbuntuGestures)
24+endmacro()
25+
26+macro(add_gesture_unit_test CLASSNAME)
27+ build_gesture_test(${CLASSNAME})
28+ add_unity8_unittest(${CLASSNAME} ${CLASSNAME}TestExec
29+ ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures
30+ DEPENDS UbuntuGesturesTest-qmlfiles
31+ ${ARGN}
32+ )
33+endmacro()
28
34
35+macro(add_gesture_ui_test CLASSNAME)
36+ build_gesture_test(${CLASSNAME})
37+ add_unity8_uitest(${CLASSNAME} ${CLASSNAME}TestExec
29− add_binary_qml_test(${CLASSNAME} ${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures UbuntuGesturesTestQmlFiles "")
38+ ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures
39+ DEPENDS UbuntuGesturesTest-qmlfiles
40+ ${ARGN}
41+ )
30 add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins
42 add_manual_qml_test(. ${CLASSNAME} IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins
31 ${CMAKE_BINARY_DIR}/tests/utils/modules)
43 ${CMAKE_BINARY_DIR}/tests/utils/modules)
32−endmacro(add_gesture_ui_test)
44+endmacro()
33−
34−macro(add_gesture_test CLASSNAME)
35− set(testCommand
36− ${CLASSNAME}TestExec -o ${CMAKE_BINARY_DIR}/test${CLASSNAME}.xml,xunitxml -o -,txt)
37−
38− add_test(NAME test${CLASSNAME} COMMAND ${testCommand})
39−
40− set_tests_properties(test${CLASSNAME} PROPERTIES
41− ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures)
42−
43− add_executable(${CLASSNAME}TestExec tst_${CLASSNAME}.cpp)
44− qt5_use_modules(${CLASSNAME}TestExec Test Core)
45− target_link_libraries(${CLASSNAME}TestExec UbuntuGesturesQml)
46−endmacro(add_gesture_test)
47
45
48add_gesture_ui_test(DirectionalDragArea)
46add_gesture_ui_test(DirectionalDragArea)
49add_gesture_ui_test(FloatingFlickable)
47add_gesture_ui_test(FloatingFlickable)
50add_gesture_ui_test(PressedOutsideNotifier)
48add_gesture_ui_test(PressedOutsideNotifier)
51add_gesture_ui_test(TouchDispatcher)
49add_gesture_ui_test(TouchDispatcher)
52add_gesture_ui_test(TouchGate)
50add_gesture_ui_test(TouchGate)
53−add_gesture_test(Damper)
51+add_gesture_unit_test(Damper)
54−add_gesture_test(AxisVelocityCalculator)
52+add_gesture_unit_test(AxisVelocityCalculator)
tests/plugins/Unity/Indicators/CMakeLists.txt+9−12
@@ -17,13 +17,8 @@ macro(indicator_test TEST)
17 set(multi_value_keywords ADDITIONAL_CPPS ADDITIONAL_LIBS)
17 set(multi_value_keywords ADDITIONAL_CPPS ADDITIONAL_LIBS)
18 cmake_parse_arguments(test "" "" "${multi_value_keywords}" ${ARGN})
18 cmake_parse_arguments(test "" "" "${multi_value_keywords}" ${ARGN})
19
19
20− set(testCommand ${CMAKE_CURRENT_BINARY_DIR}/${TEST}Exec
21− -o ${CMAKE_BINARY_DIR}/${TEST}.xml,xunitxml
22− -o -,txt)
23− add_test(NAME ${TEST} COMMAND ${testCommand})
24− add_custom_target(${TEST} ${testCommand})
25 add_executable(${TEST}Exec
20 add_executable(${TEST}Exec
26− ${TEST}.cpp
21+ ${TEST}Test.cpp
27 ${test_ADDITIONAL_CPPS}
22 ${test_ADDITIONAL_CPPS}
28 )
23 )
29 qt5_use_modules(${TEST}Exec Test Core Qml)
24 qt5_use_modules(${TEST}Exec Test Core Qml)
@@ -33,11 +28,13 @@ macro(indicator_test TEST)
33 ${GIO_LIBRARIES}
28 ${GIO_LIBRARIES}
34 ${QMENUMODEL_LDFLAGS}
29 ${QMENUMODEL_LDFLAGS}
35 )
30 )
31+
32+ add_unity8_unittest(${TEST} ${TEST}Exec)
36endmacro(indicator_test)
33endmacro(indicator_test)
37
34
38−indicator_test(indicatorsmanagertest ADDITIONAL_LIBS IndicatorsQml)
35+indicator_test(IndicatorsManager ADDITIONAL_LIBS IndicatorsQml)
39−indicator_test(indicatorsmodeltest ADDITIONAL_LIBS IndicatorsQml)
36+indicator_test(IndicatorsModel ADDITIONAL_LIBS IndicatorsQml)
40−indicator_test(menucontentactivatortest ADDITIONAL_CPPS ${INDICATORS_DIR}/menucontentactivator.cpp)
37+indicator_test(MenuContentActivator ADDITIONAL_CPPS ${INDICATORS_DIR}/menucontentactivator.cpp)
41−indicator_test(unitymenumodelstacktest ADDITIONAL_CPPS ${TEST_DIR}/mocks/QMenuModel/unitymenumodel.cpp ${INDICATORS_DIR}/unitymenumodelstack.cpp)
38+indicator_test(UnityMenuModelStack ADDITIONAL_CPPS ${TEST_DIR}/mocks/QMenuModel/unitymenumodel.cpp ${INDICATORS_DIR}/unitymenumodelstack.cpp)
42−indicator_test(rootactionstatetest ADDITIONAL_LIBS IndicatorsQml)
39+indicator_test(RootActionState ADDITIONAL_LIBS IndicatorsQml)
43−indicator_test(sharedunitymenumodeltest ADDITIONAL_LIBS IndicatorsQml)
40+indicator_test(SharedUnityMenuModel ADDITIONAL_LIBS IndicatorsQml)
tests/plugins/Unity/Indicators/indicatorsmanagertest.cpp → tests/plugins/Unity/Indicators/IndicatorsManagerTest.cpprenamed+1−1
@@ -180,4 +180,4 @@ private Q_SLOTS:
180};
180};
181
181
182QTEST_GUILESS_MAIN(IndicatorsManagerTest)
182QTEST_GUILESS_MAIN(IndicatorsManagerTest)
183−#include "indicatorsmanagertest.moc"
183+#include "IndicatorsManagerTest.moc"
tests/plugins/Unity/Indicators/indicatorsmodeltest.cpp → tests/plugins/Unity/Indicators/IndicatorsModelTest.cpprenamed+1−1
@@ -138,4 +138,4 @@ private Q_SLOTS:
138
138
139QTEST_GUILESS_MAIN(IndicatorsModelTest)
139QTEST_GUILESS_MAIN(IndicatorsModelTest)
140
140
141−#include "indicatorsmodeltest.moc"
141+#include "IndicatorsModelTest.moc"
tests/plugins/Unity/Indicators/menucontentactivatortest.cpp → tests/plugins/Unity/Indicators/MenuContentActivatorTest.cpprenamed+1−1
@@ -299,4 +299,4 @@ private:
299};
299};
300
300
301QTEST_GUILESS_MAIN(MenuConentActivatorTest)
301QTEST_GUILESS_MAIN(MenuConentActivatorTest)
302−#include "menucontentactivatortest.moc"
302+#include "MenuContentActivatorTest.moc"
tests/plugins/Unity/Indicators/rootactionstatetest.cpp → tests/plugins/Unity/Indicators/RootActionStateTest.cpprenamed+1−1
@@ -92,4 +92,4 @@ private Q_SLOTS:
92};
92};
93
93
94QTEST_GUILESS_MAIN(RootActionStateTest)
94QTEST_GUILESS_MAIN(RootActionStateTest)
95−#include "rootactionstatetest.moc"
95+#include "RootActionStateTest.moc"
tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp → tests/plugins/Unity/Indicators/SharedUnityMenuModelTest.cpprenamed+1−1
@@ -99,4 +99,4 @@ private Q_SLOTS:
99};
99};
100
100
101QTEST_GUILESS_MAIN(SharedUnityMenuModelTest)
101QTEST_GUILESS_MAIN(SharedUnityMenuModelTest)
102−#include "sharedunitymenumodeltest.moc"
102+#include "SharedUnityMenuModelTest.moc"
tests/plugins/Unity/Indicators/unitymenumodelstacktest.cpp → tests/plugins/Unity/Indicators/UnityMenuModelStackTest.cpprenamed+1−1
@@ -205,4 +205,4 @@ public:
205};
205};
206
206
207QTEST_GUILESS_MAIN(UnityMenuModelStackTest)
207QTEST_GUILESS_MAIN(UnityMenuModelStackTest)
208−#include "unitymenumodelstacktest.moc"
208+#include "UnityMenuModelStackTest.moc"
tests/plugins/Unity/Launcher/CMakeLists.txt+5−5
@@ -14,11 +14,6 @@ add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
14add_definitions(-DLAUNCHER_TESTING)
14add_definitions(-DLAUNCHER_TESTING)
15
15
16### LauncherModelTest
16### LauncherModelTest
17−set(testModelCommand dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/launchermodeltestExec
18− --parameter -o --parameter ${CMAKE_BINARY_DIR}/launchermodeltest.xml,xunitxml
19− --parameter -o --parameter -,txt)
20−add_test(NAME launchermodeltest COMMAND ${testModelCommand})
21−add_custom_target(launchermodeltest ${testModelCommand})
22add_executable(launchermodeltestExec
17add_executable(launchermodeltestExec
23 launchermodeltest.cpp
18 launchermodeltest.cpp
24 gsettings.cpp
19 gsettings.cpp
@@ -42,6 +37,11 @@ target_link_libraries(launchermodeltestExec
42 )
37 )
43qt5_use_modules(launchermodeltestExec Test Core DBus Xml Gui)
38qt5_use_modules(launchermodeltestExec Test Core DBus Xml Gui)
44
39
40+add_unity8_unittest(LauncherModel dbus-test-runner
41+ ARG_PREFIX "--parameter"
42+ ARGS --task $<TARGET_FILE:launchermodeltestExec>
43+)
44+
45# copy .desktop files into build directory for shadow builds
45# copy .desktop files into build directory for shadow builds
46file(GLOB DESKTOP_FILES *.desktop)
46file(GLOB DESKTOP_FILES *.desktop)
47
47
tests/plugins/Unity/Session/CMakeLists.txt+5−5
@@ -9,11 +9,6 @@ add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
9add_definitions(-DSESSION_TESTING)
9add_definitions(-DSESSION_TESTING)
10
10
11### SessionBackendTest
11### SessionBackendTest
12−set(testBackendCommand dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbackendtestExec
13− --parameter -o --parameter ${CMAKE_BINARY_DIR}/sessionbackendtest.xml,xunitxml
14− --parameter -o --parameter -,txt)
15−add_test(NAME sessionbackendtest COMMAND ${testBackendCommand})
16−add_custom_target(sessionbackendtest ${testBackendCommand})
17add_executable(sessionbackendtestExec
12add_executable(sessionbackendtestExec
18 sessionbackendtest.cpp
13 sessionbackendtest.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp
14 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp
@@ -22,3 +17,8 @@ target_link_libraries(sessionbackendtestExec
22 unity8-private
17 unity8-private
23 )
18 )
24qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
19qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
20+
21+add_unity8_unittest(SessionBackend dbus-test-runner
22+ ARG_PREFIX "--parameter"
23+ ARGS --task $<TARGET_FILE:sessionbackendtestExec>
24+)
tests/plugins/Utils/CMakeLists.txt+12−26
@@ -4,31 +4,17 @@ include_directories(
4 ${CMAKE_CURRENT_BINARY_DIR}
4 ${CMAKE_CURRENT_BINARY_DIR}
5 )
5 )
6
6
7−macro(run_tests)
8− set(_test_list "")
9− foreach(_test ${ARGN})
7+foreach(util_test
10− set(testCommand env "LC_ALL=C.UTF-8" ${CMAKE_CURRENT_BINARY_DIR}/${_test}Exec
8+ QLimitProxyModel
11− -o ${CMAKE_BINARY_DIR}/${_test}.xml,xunitxml
9+ UnitySortFilterProxyModel
12− -o -,txt)
10+ TimeFormatter
13− add_test(NAME ${_test} COMMAND ${testCommand})
11+ HomeKeyWatcher
14− add_custom_target(${_test} ${testCommand})
12+)
15− add_executable(${_test}Exec ${_test}.cpp modeltest.cpp)
13+ add_executable(${util_test}TestExec ${util_test}Test.cpp ModelTest.cpp)
16− qt5_use_modules(${_test}Exec Test Core Qml)
14+ qt5_use_modules(${util_test}TestExec Test Core Qml)
17− target_link_libraries(${_test}Exec
15+ target_link_libraries(${util_test}TestExec Utils-qml)
18− Utils-qml
16+ add_unity8_unittest(${util_test} ${util_test}TestExec ADD_TEST)
19− )
20− set(_test_list "${_test_list};${_test}")
21− endforeach()
17+endforeach()
22−endmacro(run_tests)
23−
24−run_tests(
25− qlimitproxymodeltest
26− unitysortfilterproxymodeltest
27− timeformattertest
28− homekeywatchertest
29− )
30
18
31# plain qml test
19# plain qml test
32−set(qmltest_DEFAULT_TARGETS qmltests)
20+add_unity8_qmlunittest(. UtilsStyle)
33−set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
34−add_qml_test(. UtilsStyle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins)
tests/plugins/Utils/homekeywatchertest.cpp → tests/plugins/Utils/HomeKeyWatcherTest.cpprenamed+1−1
@@ -320,4 +320,4 @@ AbstractTimer *FakeTimerFactory::create(QObject *parent)
320
320
321QTEST_GUILESS_MAIN(HomeKeyWatcherTest)
321QTEST_GUILESS_MAIN(HomeKeyWatcherTest)
322
322
323−#include "homekeywatchertest.moc"
323+#include "HomeKeyWatcherTest.moc"
tests/plugins/Utils/modeltest.cpp → tests/plugins/Utils/ModelTest.cpprenamed+1−1
@@ -47,7 +47,7 @@
47
47
48#include <QtGui/QtGui>
48#include <QtGui/QtGui>
49
49
50−#include "modeltest.h"
50+#include "ModelTest.h"
51
51
52#include <QtTest/QtTest>
52#include <QtTest/QtTest>
53
53
tests/plugins/Utils/modeltest.h → tests/plugins/Utils/ModelTest.hrenamed

The content is the same.

tests/plugins/Utils/qlimitproxymodeltest.cpp → tests/plugins/Utils/QLimitProxyModelTest.cpprenamed+2−2
@@ -16,7 +16,7 @@
16
16
17// local
17// local
18#include "qlimitproxymodelqml.h"
18#include "qlimitproxymodelqml.h"
19−#include "modeltest.h"
19+#include "ModelTest.h"
20
20
21// Qt
21// Qt
22#include <QTest>
22#include <QTest>
@@ -608,4 +608,4 @@ private Q_SLOTS:
608
608
609QTEST_GUILESS_MAIN(QLimitProxyModelTest)
609QTEST_GUILESS_MAIN(QLimitProxyModelTest)
610
610
611−#include "qlimitproxymodeltest.moc"
611+#include "QLimitProxyModelTest.moc"
tests/plugins/Utils/timeformattertest.cpp → tests/plugins/Utils/TimeFormatterTest.cpprenamed+1−11
@@ -45,16 +45,6 @@ private:
45 }
45 }
46
46
47private Q_SLOTS:
47private Q_SLOTS:
48− void initTestCase()
49− {
50− setenv("UNITY_TEST_ENV", "1", 1);
51− }
52−
53− void cleanupTestCase()
54− {
55− unsetenv("UNITY_TEST_ENV");
56− }
57−
58 void testTimeFormatter_Format_data() { addTestData(QList<int>() << 0); }
48 void testTimeFormatter_Format_data() { addTestData(QList<int>() << 0); }
59 void testTimeFormatter_Format()
49 void testTimeFormatter_Format()
60 {
50 {
@@ -162,4 +152,4 @@ private Q_SLOTS:
162
152
163QTEST_GUILESS_MAIN(TimeFormatterTest)
153QTEST_GUILESS_MAIN(TimeFormatterTest)
164
154
165−#include "timeformattertest.moc"
155+#include "TimeFormatterTest.moc"
tests/plugins/Utils/unitysortfilterproxymodeltest.cpp → tests/plugins/Utils/UnitySortFilterProxyModelTest.cpprenamed+2−2
@@ -19,7 +19,7 @@
19
19
20// local
20// local
21#include "unitysortfilterproxymodelqml.h"
21#include "unitysortfilterproxymodelqml.h"
22−#include "modeltest.h"
22+#include "ModelTest.h"
23
23
24// Qt
24// Qt
25#include <QTest>
25#include <QTest>
@@ -287,4 +287,4 @@ private Q_SLOTS:
287
287
288QTEST_GUILESS_MAIN(UnitySortFilterProxyModelTest)
288QTEST_GUILESS_MAIN(UnitySortFilterProxyModelTest)
289
289
290−#include "unitysortfilterproxymodeltest.moc"
290+#include "UnitySortFilterProxyModelTest.moc"
tests/plugins/Wizard/CMakeLists.txt+2−2
@@ -8,11 +8,11 @@ add_executable(tst-wizard-pagelist
8 ${CMAKE_SOURCE_DIR}/plugins/Wizard/PageList.cpp
8 ${CMAKE_SOURCE_DIR}/plugins/Wizard/PageList.cpp
9)
9)
10qt5_use_modules(tst-wizard-pagelist Core Qml Test)
10qt5_use_modules(tst-wizard-pagelist Core Qml Test)
11−add_test(NAME wizardpagelisttest COMMAND env UNITY_TEST_ENV=1 ${CMAKE_CURRENT_BINARY_DIR}/tst-wizard-pagelist)
11+add_unity8_unittest(WizardPageList tst-wizard-pagelist ENVIRONMENT WIZARD_TESTING=1)
12
12
13add_executable(tst-wizard-system
13add_executable(tst-wizard-system
14 tst_system.cpp
14 tst_system.cpp
15 ${CMAKE_SOURCE_DIR}/plugins/Wizard/System.cpp
15 ${CMAKE_SOURCE_DIR}/plugins/Wizard/System.cpp
16)
16)
17qt5_use_modules(tst-wizard-system Core DBus Qml Test)
17qt5_use_modules(tst-wizard-system Core DBus Qml Test)
18−add_test(NAME wizardsystemtest COMMAND ${CMAKE_CURRENT_BINARY_DIR}/tst-wizard-system)
18+add_unity8_unittest(WizardSystem tst-wizard-system)
tests/qmltests/CMakeLists.txt+77−94
@@ -1,97 +1,80 @@
1−# add_qml_test macro
2−include(QmlTest)
3
1
4add_subdirectory(Components)
2add_subdirectory(Components)
5
3
6−set(qmltest_DEFAULT_IMPORT_PATHS
7− ${CMAKE_BINARY_DIR}/plugins
8− ${CMAKE_BINARY_DIR}/tests/utils/modules
9− ${CMAKE_BINARY_DIR}/tests/mocks
10−)
11−
12−set(qmltest_DEFAULT_TARGETS qmlunittests)
13−set(qmltest_DEFAULT_NO_ADD_TEST FALSE)
14−set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
15−add_qml_test(utils/Unity/Test UnityTest)
16−add_qml_test(Components PhysicalKeysMapper)
17−
18−set(qmltest_DEFAULT_TARGETS qmluitests)
19−set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
20−set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
21−
22−add_qml_test(. OrientedShell)
4+add_unity8_qmltest(. OrientedShell)
23−add_qml_test(. Shell)
5+add_unity8_qmltest(. Shell LIGHTDM)
24−add_qml_test(. ShellWithPin)
6+add_unity8_qmltest(. ShellWithPin LIGHTDM)
25−add_qml_test(Components Background)
7+add_unity8_qmltest(Components Background)
26−add_qml_test(Components Carousel)
8+add_unity8_qmltest(Components Carousel)
27−add_qml_test(Components Dialogs)
9+add_unity8_qmltest(Components Dialogs LIGHTDM)
28−add_qml_test(Components DraggingArea)
10+add_unity8_qmltest(Components DraggingArea)
29−add_qml_test(Components LazyImage)
11+add_unity8_qmltest(Components LazyImage)
30−add_qml_test(Components Lockscreen)
12+add_unity8_qmltest(Components Lockscreen)
13+add_unity8_qmlunittest(Components PhysicalKeysMapper)
31−add_qml_test(Components Rating)
14+add_unity8_qmltest(Components Rating)
32−add_qml_test(Components ResponsiveGridView)
15+add_unity8_qmltest(Components ResponsiveGridView)
33−add_qml_test(Components ResponsiveVerticalJournal IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
16+add_unity8_qmltest(Components ResponsiveVerticalJournal)
34−add_qml_test(Components Showable)
17+add_unity8_qmltest(Components Showable)
35−add_qml_test(Components ZoomableImage)
18+add_unity8_qmltest(Components ZoomableImage)
36−add_qml_test(Dash Dash)
19+add_unity8_qmltest(Dash Dash)
37−add_qml_test(Dash DashContent)
20+add_unity8_qmltest(Dash DashContent)
38−add_qml_test(Dash Card)
21+add_unity8_qmltest(Dash Card)
39−add_qml_benchmark(Dash CardBenchmark 1000)
22+add_unity8_qmlbenchmark(Dash CardBenchmark 1000)
40−add_qml_test(Dash CardTool)
23+add_unity8_qmltest(Dash CardTool)
41−add_qml_test(Dash GenericScopeView)
24+add_unity8_qmltest(Dash GenericScopeView)
42−add_qml_test(Dash PageHeader)
25+add_unity8_qmltest(Dash PageHeader)
43−add_qml_test(Dash PreviewListView)
26+add_unity8_qmltest(Dash PreviewListView)
44−add_qml_test(Dash/Previews Preview)
27+add_unity8_qmltest(Dash/Previews Preview)
45−add_qml_test(Dash/Previews PreviewActions)
28+add_unity8_qmltest(Dash/Previews PreviewActions)
46−add_qml_test(Dash/Previews PreviewAudioPlayback)
29+add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
47−add_qml_test(Dash/Previews PreviewExpandable)
30+add_unity8_qmltest(Dash/Previews PreviewExpandable)
48−add_qml_test(Dash/Previews PreviewHeader)
31+add_unity8_qmltest(Dash/Previews PreviewHeader)
49−add_qml_test(Dash/Previews PreviewImageGallery)
32+add_unity8_qmltest(Dash/Previews PreviewImageGallery)
50−add_qml_test(Dash/Previews PreviewPayments)
33+add_unity8_qmltest(Dash/Previews PreviewPayments)
51−add_qml_test(Dash/Previews PreviewProgress)
34+add_unity8_qmltest(Dash/Previews PreviewProgress)
52−add_qml_test(Dash/Previews PreviewRatingDisplay)
35+add_unity8_qmltest(Dash/Previews PreviewRatingDisplay)
53−add_qml_test(Dash/Previews PreviewRatingEdit)
36+add_unity8_qmltest(Dash/Previews PreviewRatingEdit)
54−add_qml_test(Dash/Previews PreviewRatingInput)
37+add_unity8_qmltest(Dash/Previews PreviewRatingInput)
55−add_qml_test(Dash/Previews PreviewTable)
38+add_unity8_qmltest(Dash/Previews PreviewTable)
56−add_qml_test(Dash/Previews PreviewTextSummary)
39+add_unity8_qmltest(Dash/Previews PreviewTextSummary)
57−add_qml_test(Dash/Previews PreviewVideoPlayback)
40+add_unity8_qmltest(Dash/Previews PreviewVideoPlayback)
58−add_qml_test(Dash/Previews PreviewWidgetFactory)
41+add_unity8_qmltest(Dash/Previews PreviewWidgetFactory)
59−add_qml_test(Dash/Previews PreviewZoomableImage)
42+add_unity8_qmltest(Dash/Previews PreviewZoomableImage)
60−add_qml_test(Dash/ScopeSettings ScopeSettingBoolean)
43+add_unity8_qmltest(Dash/ScopeSettings ScopeSettingBoolean)
61−add_qml_test(Dash/ScopeSettings ScopeSettingList)
44+add_unity8_qmltest(Dash/ScopeSettings ScopeSettingList)
62−add_qml_test(Dash/ScopeSettings ScopeSettingNumber)
45+add_unity8_qmltest(Dash/ScopeSettings ScopeSettingNumber)
63−add_qml_test(Dash/ScopeSettings ScopeSettingString)
46+add_unity8_qmltest(Dash/ScopeSettings ScopeSettingString)
64−add_qml_test(Dash/ScopeSettings ScopeSettingsWidgetFactory)
47+add_unity8_qmltest(Dash/ScopeSettings ScopeSettingsWidgetFactory)
65−add_qml_test(Greeter Clock)
48+add_unity8_qmltest(Greeter Clock)
66−add_qml_test(Greeter Greeter)
49+add_unity8_qmltest(Greeter Greeter LIGHTDM)
67−add_qml_test(Greeter Infographics)
50+add_unity8_qmltest(Greeter Infographics LIGHTDM)
68−add_qml_test(Greeter NarrowView)
51+add_unity8_qmltest(Greeter NarrowView LIGHTDM)
69−add_qml_test(Greeter WideView)
52+add_unity8_qmltest(Greeter WideView LIGHTDM)
70−add_qml_test(Launcher Launcher)
53+add_unity8_qmltest(Launcher Launcher)
71−add_qml_test(Notifications Notifications)
54+add_unity8_qmltest(Notifications Notifications)
72−add_qml_test(Notifications VisualSnapDecisionsQueue)
55+add_unity8_qmltest(Notifications VisualSnapDecisionsQueue)
73−add_qml_test(Notifications OptionToggle)
56+add_unity8_qmltest(Notifications OptionToggle)
74−add_qml_test(Notifications SwipeToAct)
57+add_unity8_qmltest(Notifications SwipeToAct)
75−add_qml_test(Panel ActiveCallHint)
58+add_unity8_qmltest(Panel ActiveCallHint)
76−add_qml_test(Panel IndicatorItem)
59+add_unity8_qmltest(Panel IndicatorItem)
77−add_qml_test(Panel IndicatorItemRow)
60+add_unity8_qmltest(Panel IndicatorItemRow)
78−add_qml_test(Panel IndicatorPage)
61+add_unity8_qmltest(Panel IndicatorPage)
79−add_qml_test(Panel IndicatorsBar)
62+add_unity8_qmltest(Panel IndicatorsBar)
80−add_qml_test(Panel IndicatorsMenu)
63+add_unity8_qmltest(Panel IndicatorsMenu)
81−add_qml_test(Panel MenuContent)
64+add_unity8_qmltest(Panel MenuContent)
82−add_qml_test(Panel Panel)
65+add_unity8_qmltest(Panel Panel)
83−add_qml_test(Panel/Indicators IndicatorsLight ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
66+add_unity8_qmltest(Panel/Indicators IndicatorsLight)
84−# These MenuItemFactory tests need the test/mocks/ to come before plugins/
67+add_unity8_qmltest(Panel/Indicators MenuItemFactory)
85−add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
86−add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
68+add_unity8_qmltest(Panel/Indicators MessageMenuItemFactory)
87−add_qml_test(Stages ApplicationWindow)
69+add_unity8_qmltest(Stages ApplicationWindow)
88−add_qml_test(Stages DesktopStage)
70+add_unity8_qmltest(Stages DesktopStage)
89−add_qml_test(Stages PhoneStage ENVIRONMENT)
71+add_unity8_qmltest(Stages PhoneStage)
90−add_qml_test(Stages SpreadDelegate ENVIRONMENT)
72+add_unity8_qmltest(Stages SpreadDelegate)
91−add_qml_test(Stages SurfaceContainer ENVIRONMENT)
73+add_unity8_qmltest(Stages SurfaceContainer)
92−add_qml_test(Stages SessionContainer ENVIRONMENT)
74+add_unity8_qmltest(Stages SessionContainer)
93−add_qml_test(Stages TabletStage)
75+add_unity8_qmltest(Stages TabletStage)
94−add_qml_test(Stages WindowMoveResizeArea)
76+add_unity8_qmltest(Stages WindowMoveResizeArea)
95−add_qml_test(Stages Splash)
77+add_unity8_qmltest(Stages Splash)
96−add_qml_test(Tutorial Tutorial)
78+add_unity8_qmltest(Tutorial Tutorial LIGHTDM)
97−add_qml_test(Wizard Wizard ENVIRONMENT "OXIDE_NO_SANDBOX=1")
79+add_unity8_qmltest(Wizard Wizard ENVIRONMENT "OXIDE_NO_SANDBOX=1")
80+add_unity8_qmlunittest(utils/Unity/Test UnityTest)
tests/qmltests/Components/CMakeLists.txt+4−10
@@ -16,19 +16,13 @@ add_executable(DragHandleTestExec tst_DragHandle.cpp)
16qt5_use_modules(DragHandleTestExec Test Core Qml Gui Quick)
16qt5_use_modules(DragHandleTestExec Test Core Qml Gui Quick)
17target_link_libraries(DragHandleTestExec UbuntuGesturesQml UbuntuGestures)
17target_link_libraries(DragHandleTestExec UbuntuGesturesQml UbuntuGestures)
18
18
19−add_binary_qml_test(DragHandle ${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures "" "")
19+add_unity8_uitest(DragHandle DragHandleTestExec ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures)
20−add_manual_qml_test(. DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_BINARY_DIR}/tests/utils/modules)
20+add_manual_qml_test(. DragHandle IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_BINARY_DIR}/tests/utils/modules)
21
21
22−########## tst_EdgeDragEvaluator
23−
24−include_directories(
25− ${CMAKE_SOURCE_DIR}/plugins/Ubuntu/Gestures
26− ${CMAKE_SOURCE_DIR}/libs/UbuntuGestures
27− ${CMAKE_CURRENT_BINARY_DIR}
28− )
29
22
23+########## tst_EdgeDragEvaluator
30add_executable(EdgeDragEvaluatorTestExec tst_EdgeDragEvaluator.cpp)
24add_executable(EdgeDragEvaluatorTestExec tst_EdgeDragEvaluator.cpp)
31qt5_use_modules(EdgeDragEvaluatorTestExec Test Core Qml Gui Quick)
25qt5_use_modules(EdgeDragEvaluatorTestExec Test Core Qml Gui Quick)
32target_link_libraries(EdgeDragEvaluatorTestExec UbuntuGesturesQml UbuntuGestures)
26target_link_libraries(EdgeDragEvaluatorTestExec UbuntuGesturesQml UbuntuGestures)
33
27
34−add_binary_qml_test(EdgeDragEvaluator ${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures "" "")
28+add_unity8_uitest(EdgeDragEvaluator EdgeDragEvaluatorTestExec ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures)
tests/qmltests/Dash/Previews/tst_PreviewHeader.qml+30
@@ -38,6 +38,22 @@ Rectangle {
38 "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}]
38 "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}]
39 }
39 }
40
40
41+ property var brokenheaderjson: {
42+ "title": "THE TITLE",
43+ "subtitle": "Something catchy",
44+ "mascot": "bad_path",
45+ "fallback": "",
46+ "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}]
47+ }
48+
49+ property var fallbackheaderjson: {
50+ "title": "THE TITLE",
51+ "subtitle": "Something catchy",
52+ "mascot": "bad_path2",
53+ "fallback": "../graphics/play_button.png",
54+ "attributes": [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}]
55+ }
56+
41 PreviewHeader {
57 PreviewHeader {
42 id: previewHeader
58 id: previewHeader
43 widgetData: headerjson
59 widgetData: headerjson
@@ -121,5 +137,19 @@ Rectangle {
121 compare(innerPreviewHeader.subtitle, "Something catchy");
137 compare(innerPreviewHeader.subtitle, "Something catchy");
122 compare(innerPreviewHeader.mascot.toString().slice(-24), "graphics/play_button.png");
138 compare(innerPreviewHeader.mascot.toString().slice(-24), "graphics/play_button.png");
123 }
139 }
140+
141+ function test_fallback() {
142+ previewHeader.widgetData = brokenheaderjson;
143+ tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
144+ var mascot = findChild(previewHeader, "mascotShape");
145+ compare(mascot.visible, false);
146+
147+ previewHeader.widgetData = {};
148+ previewHeader.widgetData = fallbackheaderjson;
149+ tryCompareFunction(function() { return findChild(previewHeader, "mascotShape") != null }, true);
150+ var mascot = findChild(previewHeader, "mascotShape");
151+ tryCompare(mascot, "visible", true);
152+ tryCompare(mascot.image, "status", Image.Ready);
153+ }
124 }
154 }
125}
155}
tests/qmltests/Dash/Previews/tst_PreviewImageGallery.qml+21−1
@@ -33,10 +33,21 @@ Rectangle {
33 "sources": [
33 "sources": [
34 "../../graphics/phone_background.jpg",
34 "../../graphics/phone_background.jpg",
35 "../../graphics/tablet_background.jpg",
35 "../../graphics/tablet_background.jpg",
36− "../../graphics/clock@18.png"
36+ "../../graphics/clock@18.png",
37+ "../../graphics/borked"
37 ]
38 ]
38 }
39 }
39
40
41+ property var sourcesModel1WithFallback: {
42+ "sources": [
43+ "../../graphics/phone_background.jpg",
44+ "../../graphics/tablet_background.jpg",
45+ "../../graphics/clock@18.png",
46+ "../../graphics/borked"
47+ ]
48+ , "fallback": "../../graphics/clock@18.png"
49+ }
50+
40 PreviewImageGallery {
51 PreviewImageGallery {
41 id: imageGallery
52 id: imageGallery
42 width: parent.width
53 width: parent.width
@@ -103,5 +114,14 @@ Rectangle {
103 tryCompare(overlayListView, "currentIndex", data.index);
114 tryCompare(overlayListView, "currentIndex", data.index);
104 verify(image.source === overlayListView.currentItem.source);
115 verify(image.source === overlayListView.currentItem.source);
105 }
116 }
117+
118+ function test_fallback() {
119+ var image3 = findChild(imageGallery, "previewImage3");
120+ tryCompare(image3, "state", "error");
121+ imageGallery.widgetData = sourcesModel0;
122+ imageGallery.widgetData = sourcesModel1WithFallback;
123+ image3 = findChild(imageGallery, "previewImage3");
124+ tryCompare(image3, "state", "ready");
125+ }
106 }
126 }
107}
127}
tests/qmltests/Dash/Previews/tst_PreviewZoomableImage.qml+27−6
@@ -26,7 +26,7 @@ Rectangle {
26 color: "lightgrey"
26 color: "lightgrey"
27
27
28 property var widgetData0: {
28 property var widgetData0: {
29− "source": Qt.resolvedUrl("../artwork/checkers.png"),
29+ "source": "../../graphics/phone_background.jpg",
30 "zoomable": false
30 "zoomable": false
31 }
31 }
32
32
@@ -34,21 +34,35 @@ Rectangle {
34 "source": ""
34 "source": ""
35 }
35 }
36
36
37− PreviewZoomableImage {
37+ property var widgetData2: {
38− id: zoomableImage
38+ "source": "fadsasf",
39+ "fallback": "../../graphics/phone_background.jpg"
40+ }
41+
42+ Loader {
43+ id: loader
39 anchors.centerIn: parent
44 anchors.centerIn: parent
45+ sourceComponent: PreviewZoomableImage {
40− widgetData: widgetData0
46+ widgetData: widgetData0
47+ }
41 }
48 }
42
49
50+ property alias zoomableImage: loader.item
51+
43 UT.UnityTestCase {
52 UT.UnityTestCase {
44 name: "PreviewZoomableImageTest"
53 name: "PreviewZoomableImageTest"
45 when: windowShown
54 when: windowShown
46
55
47− property Item lazyImage: findChild(zoomableImage, "lazyImage");
56+ property Item lazyImage
48− property Item overlay: findChild(zoomableImage.rootItem, "overlay");
57+ property Item overlay
49
58
50 function init() {
59 function init() {
60+ // Use a loader so we start from scratch each time
61+ loader.active = false;
62+ loader.active = true;
63+ lazyImage = findChild(zoomableImage, "lazyImage");
51 waitForRendering(zoomableImage);
64 waitForRendering(zoomableImage);
65+ overlay = findChild(zoomableImage.rootItem, "overlay");
52 waitForRendering(overlay);
66 waitForRendering(overlay);
53 }
67 }
54
68
@@ -79,5 +93,12 @@ Rectangle {
79 mouseClick(overlayCloseButton);
93 mouseClick(overlayCloseButton);
80 tryCompare(overlay, "visible", false);
94 tryCompare(overlay, "visible", false);
81 }
95 }
96+
97+ function test_fallback() {
98+ zoomableImage.widgetData = widgetData2;
99+ waitForRendering(zoomableImage);
100+ waitForRendering(lazyImage);
101+ tryCompare(lazyImage, "state", "ready");
102+ }
82 }
103 }
83}
104}
tests/qmltests/Dash/tst_Card.qml+30
@@ -223,6 +223,7 @@ Rectangle {
223 property Item mascotImage: findChild(card, "mascotImage");
223 property Item mascotImage: findChild(card, "mascotImage");
224
224
225 function init() {
225 function init() {
226+ cardTool.components = Qt.binding(function() { return Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components']; });
226 loader.visible = true;
227 loader.visible = true;
227 }
228 }
228
229
@@ -423,6 +424,7 @@ Rectangle {
423 ];
424 ];
424 }
425 }
425
426
427+
426 function test_background(data) {
428 function test_background(data) {
427 selector.selectedIndex = data.index;
429 selector.selectedIndex = data.index;
428 waitForRendering(selector);
430 waitForRendering(selector);
@@ -453,6 +455,34 @@ Rectangle {
453 }
455 }
454 }
456 }
455
457
458+ function test_fallback() {
459+ selector.selectedIndex = 0;
460+ waitForRendering(card);
461+
462+ card.cardData["art"] = "somethingbroken";
463+ card.cardDataChanged();
464+ waitForRendering(card);
465+ tryCompare(art, "visible", false);
466+
467+ cardTool.components["art"]["fallback"] = Qt.resolvedUrl("artwork/emblem.png");
468+ cardTool.componentsChanged();
469+ card.cardData["art"] = "somethingbroken";
470+ card.cardDataChanged();
471+ waitForRendering(card);
472+ tryCompare(art, "visible", true);
473+
474+ card.cardData["mascot"] = "somethingbroken2";
475+ card.cardDataChanged();
476+ compare(mascotImage.image.status, Image.Error);
477+
478+ cardTool.components["mascot"] = {"fallback": Qt.resolvedUrl("artwork/emblem.png")};
479+ cardTool.componentsChanged();
480+ card.cardData["mascot"] = "somethingbroken2";
481+ card.cardDataChanged();
482+ waitForRendering(card);
483+ tryCompare(mascotImage.image, "status", Image.Ready);
484+ }
485+
456 function test_font_weights_data() {
486 function test_font_weights_data() {
457 return [
487 return [
458 { tag: "Title only", index: 8, weight: Font.Normal },
488 { tag: "Title only", index: 8, weight: Font.Normal },
tests/qmltests/Stages/tst_PhoneStage.qml+19
@@ -346,6 +346,25 @@ Item {
346 tryCompare(spreadView, "contentX", -spreadView.shift)
346 tryCompare(spreadView, "contentX", -spreadView.shift)
347 }
347 }
348
348
349+ function test_cantAccessPhoneStageWhileRightEdgeGesture() {
350+ var spreadView = findChild(phoneStage, "spreadView");
351+ var eventEaterArea = findChild(phoneStage, "eventEaterArea")
352+
353+ var startX = phoneStage.width - 2;
354+ var startY = phoneStage.height / 2;
355+ var endY = startY;
356+ var endX = phoneStage.width / 2;
357+
358+ touchFlick(phoneStage, startX, startY, endX, endY,
359+ true /* beginTouch */, false /* endTouch */, units.gu(10), 50);
360+
361+ compare(eventEaterArea.enabled, true);
362+
363+ touchRelease(phoneStage, endX, endY);
364+
365+ compare(eventEaterArea.enabled, false);
366+ }
367+
349 function test_leftEdge_data() {
368 function test_leftEdge_data() {
350 return [
369 return [
351 { tag: "normal", inSpread: false, leftEdgeDragWidth: units.gu(5), shouldMoveApp: true },
370 { tag: "normal", inSpread: false, leftEdgeDragWidth: units.gu(5), shouldMoveApp: true },
tests/qmltests/Stages/tst_WindowMoveResizeArea.qml+1
@@ -70,6 +70,7 @@ Item {
70 }
70 }
71
71
72 UT.UnityTestCase {
72 UT.UnityTestCase {
73+ name: "WindowMoveResizeArea"
73 when: windowShown
74 when: windowShown
74
75
75 function init() {
76 function init() {
tests/qmltests/tst_Shell.qml+14−17
@@ -83,7 +83,7 @@ Rectangle {
83 Shell {
83 Shell {
84 property string shellMode: "full-greeter" /* default */
84 property string shellMode: "full-greeter" /* default */
85
85
86− usageScenario: "phone"
86+ usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
87 orientation: Qt.PortraitOrientation
87 orientation: Qt.PortraitOrientation
88 primaryOrientation: Qt.PortraitOrientation
88 primaryOrientation: Qt.PortraitOrientation
89 nativeOrientation: Qt.PortraitOrientation
89 nativeOrientation: Qt.PortraitOrientation
@@ -151,14 +151,11 @@ Rectangle {
151 }
151 }
152 }
152 }
153 ListItem.ItemSelector {
153 ListItem.ItemSelector {
154− id: usageModeSelector
154+ id: usageScenarioSelector
155 anchors { left: parent.left; right: parent.right }
155 anchors { left: parent.left; right: parent.right }
156 activeFocusOnPress: false
156 activeFocusOnPress: false
157− text: "Usage mode"
157+ text: "Usage scenario"
158− model: ["Staged", "Windowed"]
158+ model: ["phone", "tablet", "desktop"]
159− onSelectedIndexChanged: {
160− GSettingsController.setUsageMode(model[selectedIndex]);
161− }
162 }
159 }
163 MouseTouchEmulationCheckbox {
160 MouseTouchEmulationCheckbox {
164 id: mouseEmulation
161 id: mouseEmulation
@@ -725,7 +722,7 @@ Rectangle {
725
722
726 tryCompare(webApp.session.surface, "activeFocus", true);
723 tryCompare(webApp.session.surface, "activeFocus", true);
727
724
728− GSettingsController.setUsageMode("Windowed");
725+ shell.usageScenario = "desktop";
729
726
730 // check that the desktop stage and window have been loaded
727 // check that the desktop stage and window have been loaded
731 {
728 {
@@ -735,7 +732,7 @@ Rectangle {
735
732
736 tryCompare(webApp.session.surface, "activeFocus", true);
733 tryCompare(webApp.session.surface, "activeFocus", true);
737
734
738− GSettingsController.setUsageMode("Staged");
735+ shell.usageScenario = "tablet";
739
736
740 // check that the tablet stage and app surface delegate have been loaded
737 // check that the tablet stage and app surface delegate have been loaded
741 {
738 {
@@ -1205,30 +1202,30 @@ Rectangle {
1205
1202
1206 function test_stageLoader_data() {
1203 function test_stageLoader_data() {
1207 return [
1204 return [
1208− {tag: "phone", source: "Stages/PhoneStage.qml", formFactor: "phone", usageMode: "Staged"},
1205+ {tag: "phone", source: "Stages/PhoneStage.qml", formFactor: "phone", usageScenario: "phone"},
1209− {tag: "tablet", source: "Stages/TabletStage.qml", formFactor: "tablet", usageMode: "Staged"},
1206+ {tag: "tablet", source: "Stages/TabletStage.qml", formFactor: "tablet", usageScenario: "tablet"},
1210− {tag: "desktop", source: "Stages/DesktopStage.qml", formFactor: "tablet", usageMode: "Windowed"}
1207+ {tag: "desktop", source: "Stages/DesktopStage.qml", formFactor: "tablet", usageScenario: "desktop"}
1211 ]
1208 ]
1212 }
1209 }
1213
1210
1214 function test_stageLoader(data) {
1211 function test_stageLoader(data) {
1215− GSettingsController.setUsageMode(data.usageMode);
1216 loadShell(data.formFactor);
1212 loadShell(data.formFactor);
1213+ shell.usageScenario = data.usageScenario;
1217 var stageLoader = findChild(shell, "applicationsDisplayLoader");
1214 var stageLoader = findChild(shell, "applicationsDisplayLoader");
1218 verify(String(stageLoader.source).indexOf(data.source) >= 0);
1215 verify(String(stageLoader.source).indexOf(data.source) >= 0);
1219 }
1216 }
1220
1217
1221 function test_launcherInverted_data() {
1218 function test_launcherInverted_data() {
1222 return [
1219 return [
1223− {tag: "phone", formFactor: "phone", usageMode: "Staged", launcherInverted: true},
1220+ {tag: "phone", formFactor: "phone", usageScenario: "phone", launcherInverted: true},
1224− {tag: "tablet", formFactor: "tablet", usageMode: "Staged", launcherInverted: true},
1221+ {tag: "tablet", formFactor: "tablet", usageScenario: "tablet", launcherInverted: true},
1225− {tag: "desktop", formFactor: "tablet", usageMode: "Windowed", launcherInverted: false}
1222+ {tag: "desktop", formFactor: "tablet", usageScenario: "desktop", launcherInverted: false}
1226 ]
1223 ]
1227 }
1224 }
1228
1225
1229 function test_launcherInverted(data) {
1226 function test_launcherInverted(data) {
1230− GSettingsController.setUsageMode(data.usageMode);
1231 loadShell(data.formFactor);
1227 loadShell(data.formFactor);
1228+ shell.usageScenario = data.usageScenario;
1232
1229
1233 var launcher = findChild(shell, "launcher");
1230 var launcher = findChild(shell, "launcher");
1234 compare(launcher.inverted, data.launcherInverted);
1231 compare(launcher.inverted, data.launcherInverted);
tests/qmltests/utils/Unity/Test/tst_UnityTest.qml+5−8
@@ -20,6 +20,8 @@ import QtTest 1.0
20import Unity.Test 0.1
20import Unity.Test 0.1
21
21
22TestCase {
22TestCase {
23+ name: "UnityTest"
24+
23 Rectangle {
25 Rectangle {
24 id: rect
26 id: rect
25 }
27 }
@@ -28,28 +30,23 @@ TestCase {
28 id: testObject
30 id: testObject
29 }
31 }
30
32
31− // Singletons need to be bound to a property and not-named-imported
32− // for them to be able to be properly passed back to C++.
33− // See https://bugreports.qt-project.org/browse/QTBUG-30730
34− property var util: Util
35−
36 function test_direct() {
33 function test_direct() {
37 compare(Util.isInstanceOf(rect, "QQuickRectangle"), true, "rect should be an instance of QQuickRectangle");
34 compare(Util.isInstanceOf(rect, "QQuickRectangle"), true, "rect should be an instance of QQuickRectangle");
38− compare(Util.isInstanceOf(util, "TestUtil"), true, "Util should be an instance of TestUtil");
35+ compare(Util.isInstanceOf(Util, "TestUtil"), true, "Util should be an instance of TestUtil");
39 compare(Util.isInstanceOf(testObject, "MockObjectForInstanceOfTestChild"), true, "testObject should be an instance of MockObjectForInstanceOfTestChild");
36 compare(Util.isInstanceOf(testObject, "MockObjectForInstanceOfTestChild"), true, "testObject should be an instance of MockObjectForInstanceOfTestChild");
40 }
37 }
41
38
42 function test_inherited() {
39 function test_inherited() {
43 compare(Util.isInstanceOf(rect, "QQuickItem"), true, "rect should be an instance of QQuickItem");
40 compare(Util.isInstanceOf(rect, "QQuickItem"), true, "rect should be an instance of QQuickItem");
44 compare(Util.isInstanceOf(rect, "QObject"), true, "rect should be an instance of QObject");
41 compare(Util.isInstanceOf(rect, "QObject"), true, "rect should be an instance of QObject");
45− compare(Util.isInstanceOf(util, "QObject"), true, "Util should be an instance of QObject");
42+ compare(Util.isInstanceOf(Util, "QObject"), true, "Util should be an instance of QObject");
46 compare(Util.isInstanceOf(testObject, "MockObjectForInstanceOfTest"), true, "testObject should be an instance of MockObjectForInstanceOfTest");
43 compare(Util.isInstanceOf(testObject, "MockObjectForInstanceOfTest"), true, "testObject should be an instance of MockObjectForInstanceOfTest");
47 compare(Util.isInstanceOf(testObject, "QQuickRectangle"), true, "testObject should be an instance of QQuickRectangle");
44 compare(Util.isInstanceOf(testObject, "QQuickRectangle"), true, "testObject should be an instance of QQuickRectangle");
48 }
45 }
49
46
50 function test_negative() {
47 function test_negative() {
51 compare(Util.isInstanceOf(rect, "QQuickMouseArea"), false, "rect should not be an instance of MouseArea");
48 compare(Util.isInstanceOf(rect, "QQuickMouseArea"), false, "rect should not be an instance of MouseArea");
52− compare(Util.isInstanceOf(util, "QQuickItem"), false, "Util should not be an instance of QQuickItem");
49+ compare(Util.isInstanceOf(Util, "QQuickItem"), false, "Util should not be an instance of QQuickItem");
53 }
50 }
54
51
55 function test_undefined() {
52 function test_undefined() {
tests/whitespace/CMakeLists.txt+1−1
@@ -2,4 +2,4 @@
2# Test that all source files, cmakefiles, etc. do not contain trailing whitespace.
2# Test that all source files, cmakefiles, etc. do not contain trailing whitespace.
3#
3#
4
4
5−add_test(whitespace ${CMAKE_CURRENT_SOURCE_DIR}/check_whitespace.py ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
5+add_test(Whitespace ${CMAKE_CURRENT_SOURCE_DIR}/check_whitespace.py ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})