1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
include(QmlTest)
# QML tests that do not require graphical capabilities.
add_custom_target(unittests)
# QML tests that require graphical capabilities.
add_custom_target(uitests)
add_custom_target(xvfbuitests)
add_custom_target(alltests)
add_dependencies(alltests unittests uitests)
add_custom_target(xvfballtests)
add_dependencies(xvfballtests unittests xvfbuitests)
# Support libraries and plugins
add_subdirectory(mocks)
add_subdirectory(utils)
add_subdirectory(uqmlscene)
# Use our custom implementation of qmlscene and import dbus-test-runner
add_executable(qmlscene ALIAS uqmlscene)
import_executables(dbus-test-runner)
set(UNITY_IMPORT_PATHS
${CMAKE_BINARY_DIR}/tests/mocks
${CMAKE_BINARY_DIR}/tests/utils/modules
${CMAKE_BINARY_DIR}/plugins
)
set(UNITY_IMPORT_PATHS ${UNITY_IMPORT_PATHS} CACHE INTERNAL "")
macro(unity8_parse_arguments)
cmake_parse_arguments(U8TEST
"${QMLTEST_OPTIONS};LIGHTDM"
"${QMLTEST_SINGLE}"
"${QMLTEST_MULTI}"
${ARGN}
)
set(ld_paths)
if(U8TEST_LIGHTDM)
list(APPEND ld_paths
${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics
${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm
)
endif()
if(ld_paths)
string(REPLACE ";" ":" ld_library_path "${ld_paths}")
set(ld_library_path LD_LIBRARY_PATH=${ld_library_path})
endif()
set(U8TEST_ARGN "${ARGN}")
list(REMOVE_ITEM U8TEST_ARGN LIGHTDM)
set(environment
UNITY_TESTING=1
LANGUAGE=C
LC_ALL=C.UTF-8
${ld_library_path}
)
endmacro()
# add a non-graphical unit test
# see QmlTest.cmake for additional options
function(add_unity8_unittest COMPONENT_NAME TARGET)
unity8_parse_arguments(${ARGN})
add_executable_test(${COMPONENT_NAME} ${TARGET}
ADD_TEST
IMPORT_PATHS ${UNITY_IMPORT_PATHS}
TARGETS unittests
${U8TEST_ARGN}
ENVIRONMENT ${environment}
QT_QPA_PLATFORM=minimal
${U8TEST_ENVIRONMENT}
)
endfunction()
# add a graphical unit test
function(add_unity8_uitest COMPONENT_NAME TARGET)
unity8_parse_arguments(${ARGN})
add_executable_test(${COMPONENT_NAME} ${TARGET}
IMPORT_PATHS ${UNITY_IMPORT_PATHS}
TARGETS uitests
${U8TEST_ARGN}
ENVIRONMENT ${environment}
${U8TEST_ENVIRONMENT}
)
endfunction()
# add a non-graphical qml unit test
function(add_unity8_qmlunittest PATH COMPONENT_NAME)
unity8_parse_arguments(${ARGN})
add_qml_unittest(${PATH} ${COMPONENT_NAME}
ADD_TEST
IMPORT_PATHS ${UNITY_IMPORT_PATHS}
TARGET unittests
${U8TEST_ARGN}
ENVIRONMENT ${environment}
QT_QPA_PLATFORM=minimal
${U8TEST_ENVIRONMENT}
)
endfunction()
# add a graphical qml test
function(add_unity8_qmltest PATH COMPONENT_NAME)
unity8_parse_arguments(${ARGN})
add_qml_test(${PATH} ${COMPONENT_NAME}
IMPORT_PATHS ${UNITY_IMPORT_PATHS}
TARGETS uitests
${U8TEST_ARGN}
ENVIRONMENT ${environment}
${U8TEST_ENVIRONMENT}
)
endfunction()
# add a graphical qml benchmark
function(add_unity8_qmlbenchmark PATH COMPONENT_NAME ITERATIONS)
add_unity8_qmltest(${PATH} ${COMPONENT_NAME} ITERATIONS ${ITERATIONS} ${ARGN})
endfunction()
# Actual test definitions
add_subdirectory(libs)
add_subdirectory(plugins)
add_subdirectory(qmltests)
add_subdirectory(whitespace)
|