on bbbdccd help sign in
unity8/tests/CMakeLists.txt
135 lines 3.8 kB history raw
1include(QmlTest)
3# QML tests that do not require graphical capabilities.
4add_custom_target(unittests)
6# QML tests that require graphical capabilities.
7add_custom_target(uitests)
8add_custom_target(xvfbuitests)
10add_custom_target(alltests)
11add_dependencies(alltests unittests uitests)
13add_custom_target(xvfballtests)
14add_dependencies(xvfballtests unittests xvfbuitests)
16# Support libraries and plugins
17add_subdirectory(mocks)
18add_subdirectory(utils)
19add_subdirectory(uqmlscene)
21# Use our custom implementation of qmlscene and import dbus-test-runner
22add_executable(qmlscene ALIAS uqmlscene)
23import_executables(dbus-test-runner)
25set(UNITY_PLUGINPATH "${CMAKE_BINARY_DIR}/plugins" CACHE PATH "Path to pre-built unity8 plugin dir.")
26set(UNITY_MOCKPATH "${CMAKE_BINARY_DIR}/tests/mocks" CACHE PATH "Path to pre-built unity8 mock dir.")
28# Pre-built mocks have preference, pre-built plugins replace local build
29set(UNITY_IMPORT_PATHS
30 ${UNITY_MOCKPATH}
31 ${CMAKE_BINARY_DIR}/tests/mocks
32 ${CMAKE_BINARY_DIR}/tests/utils/modules
33 ${UNITY_PLUGINPATH}
35list(REMOVE_DUPLICATES UNITY_IMPORT_PATHS)
36set(UNITY_IMPORT_PATHS ${UNITY_IMPORT_PATHS} CACHE INTERNAL "")
38macro(unity8_parse_arguments)
39 cmake_parse_arguments(U8TEST
40 "${QMLTEST_OPTIONS};LIGHTDM"
41 "${QMLTEST_SINGLE}"
42 "${QMLTEST_MULTI}"
43 ${ARGN}
44 )
46 set(ld_paths)
47 if(U8TEST_LIGHTDM)
48 list(APPEND ld_paths
49 ${UNITY_MOCKPATH}/libusermetrics
50 ${UNITY_MOCKPATH}/IntegratedLightDM/liblightdm
51 )
52 endif()
54 if(ld_paths)
55 string(REPLACE ";" ":" ld_library_path "${ld_paths}")
56 set(ld_library_path LD_LIBRARY_PATH=${ld_library_path})
57 endif()
59 set(U8TEST_ARGN "${ARGN}")
60 list(REMOVE_ITEM U8TEST_ARGN LIGHTDM)
62 set(environment
63 UNITY_TESTING=1
64 LANGUAGE=C
65 LC_ALL=C.UTF-8
66 ${ld_library_path}
67 )
68endmacro()
71# add a non-graphical unit test
72# see QmlTest.cmake for additional options
73function(add_unity8_unittest COMPONENT_NAME TARGET)
74 unity8_parse_arguments(${ARGN})
75 add_executable_test(${COMPONENT_NAME} ${TARGET}
76 ADD_TEST
77 IMPORT_PATHS ${UNITY_IMPORT_PATHS}
78 TARGETS unittests
79 ${U8TEST_ARGN}
80 ENVIRONMENT ${environment}
81 QT_QPA_PLATFORM=minimal
82 ${U8TEST_ENVIRONMENT}
83 )
84endfunction()
86# add a graphical unit test
87function(add_unity8_uitest COMPONENT_NAME TARGET)
88 unity8_parse_arguments(${ARGN})
89 add_executable_test(${COMPONENT_NAME} ${TARGET}
90 IMPORT_PATHS ${UNITY_IMPORT_PATHS}
91 TARGETS uitests
92 ${U8TEST_ARGN}
93 ENVIRONMENT ${environment}
94 ${U8TEST_ENVIRONMENT}
95 )
96endfunction()
98# add a non-graphical qml unit test
99function(add_unity8_qmlunittest PATH COMPONENT_NAME)
100 unity8_parse_arguments(${ARGN})
101 add_qml_unittest(${PATH} ${COMPONENT_NAME}
102 ADD_TEST
103 IMPORT_PATHS ${UNITY_IMPORT_PATHS}
104 TARGET unittests
105 ${U8TEST_ARGN}
106 ENVIRONMENT ${environment}
107 QT_QPA_PLATFORM=minimal
108 ${U8TEST_ENVIRONMENT}
109 )
110endfunction()
112# add a graphical qml test
113function(add_unity8_qmltest PATH COMPONENT_NAME)
114 unity8_parse_arguments(${ARGN})
115 add_qml_test(${PATH} ${COMPONENT_NAME}
116 IMPORT_PATHS ${UNITY_IMPORT_PATHS}
117 TARGETS uitests
118 ${U8TEST_ARGN}
119 ENVIRONMENT ${environment}
120 ${U8TEST_ENVIRONMENT}
121 )
122endfunction()
124# add a graphical qml benchmark
125function(add_unity8_qmlbenchmark PATH COMPONENT_NAME ITERATIONS)
126 add_unity8_qmltest(${PATH} ${COMPONENT_NAME} ITERATIONS ${ITERATIONS} ${ARGN})
127endfunction()
130# Actual test definitions
131add_subdirectory(libs)
132add_subdirectory(plugins)
133add_subdirectory(qmltests)
134add_subdirectory(whitespace)
135add_subdirectory(imports)