aboutsummaryrefslogtreecommitdiff
path: root/tests/CMakeLists.txt
blob: cf84c55efd3331584a80ecef509fb15b4ad8ca59 (plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
if (FLAVOUR_GTK3)
    # libayatana-indicator3.so
    set (ayatana_indicator_gtkver "ayatana-indicator3")
else()
    # libayatana-indicator.so
    set (ayatana_indicator_gtkver "ayatana-indicator")
endif()

find_program(DBUS_TEST_RUNNER dbus-test-runner)

function(add_test_library_by_name name)
  set (TEST_LIBRARY_NAME ${name})
  add_library("${TEST_LIBRARY_NAME}" SHARED ${TEST_LIBRARY_NAME}.c)
  target_include_directories("${TEST_LIBRARY_NAME}" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS})
  target_include_directories("${TEST_LIBRARY_NAME}" PUBLIC "${CMAKE_SOURCE_DIR}/src")
  target_link_libraries("${TEST_LIBRARY_NAME}" ${PROJECT_DEPS_LIBRARIES} -l${ayatana_indicator_gtkver})
  target_link_directories("${TEST_LIBRARY_NAME}" PUBLIC "${CMAKE_BINARY_DIR}/src")
  add_dependencies("${TEST_LIBRARY_NAME}" "${ayatana_indicator_gtkver}")
endfunction()

function(add_test_executable_by_name name)
  set (TEST_EXECUTABLE_NAME ${name})
  add_executable("${TEST_EXECUTABLE_NAME}" ${TEST_EXECUTABLE_NAME}.c)
  target_compile_definitions("${TEST_EXECUTABLE_NAME}" PUBLIC BUILD_DIR="${CMAKE_CURRENT_BINARY_DIR}")
  target_compile_definitions("${TEST_EXECUTABLE_NAME}" PUBLIC SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
  target_include_directories("${TEST_EXECUTABLE_NAME}" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS})
  target_include_directories("${TEST_EXECUTABLE_NAME}" PUBLIC "${CMAKE_SOURCE_DIR}/src")
  target_link_libraries("${TEST_EXECUTABLE_NAME}" ${PROJECT_DEPS_LIBRARIES} -l${ayatana_indicator_gtkver})
  target_link_directories("${TEST_EXECUTABLE_NAME}" PUBLIC "${CMAKE_BINARY_DIR}/src")
  add_dependencies("${TEST_EXECUTABLE_NAME}" "${ayatana_indicator_gtkver}")
endfunction()

add_test_library_by_name(dummy-indicator-blank)
add_test_library_by_name(dummy-indicator-entry-func)
add_test_library_by_name(dummy-indicator-null)
add_test_library_by_name(dummy-indicator-signaler)
add_test_library_by_name(dummy-indicator-simple)
add_test_library_by_name(dummy-indicator-visible)

# session.conf
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/session.conf.in" "${CMAKE_CURRENT_BINARY_DIR}/session.conf" @ONLY)

# service-manager-connect.service
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/service-manager-connect.service.in" "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect.service" @ONLY)

# service-manager-connect
add_test_executable_by_name(service-manager-connect)

# service-manager-connect-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-tester"
    DEPENDS "service-manager-connect"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-tester"
    COMMAND
    echo "${DBUS_TEST_RUNNER} --dbus-config ${CMAKE_CURRENT_BINARY_DIR}/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect" >> "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-tester"
)
add_test("service-manager-connect-tester" "service-manager-connect-tester")

# service-manager-connect-service
add_test_executable_by_name(service-manager-connect-service)

# service-manager-no-connect
add_test_executable_by_name(service-manager-no-connect)

# service-manager-no-connect-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/service-manager-no-connect-tester"
    DEPENDS "service-manager-no-connect"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/service-manager-no-connect-tester"
    COMMAND
    echo "${DBUS_TEST_RUNNER} --dbus-config /usr/share/dbus-test-runner/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/service-manager-no-connect" >> "${CMAKE_CURRENT_BINARY_DIR}/service-manager-no-connect-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/service-manager-no-connect-tester"
)
add_test("service-manager-no-connect-tester" "service-manager-no-connect-tester")

# service-manager-nostart-connect
add_test_executable_by_name(service-manager-nostart-connect)

# service-manager-connect-nostart-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-nostart-tester"
    DEPENDS "service-manager-connect-service"
    DEPENDS "service-manager-nostart-connect"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-nostart-tester"
    COMMAND
    echo "${DBUS_TEST_RUNNER} --task ${CMAKE_CURRENT_BINARY_DIR}/service-manager-nostart-connect --task ${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-service" >> "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-nostart-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/service-manager-connect-nostart-tester"
)
add_test("service-manager-connect-nostart-tester" "service-manager-connect-nostart-tester")

# service-shutdown-timeout
add_test_executable_by_name(service-shutdown-timeout)

# service-shutdown-timeout-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/service-shutdown-timeout-tester"
    DEPENDS "service-shutdown-timeout"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/service-shutdown-timeout-tester"
    COMMAND
    echo "${DBUS_TEST_RUNNER} --dbus-config /usr/share/dbus-test-runner/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/service-shutdown-timeout" >> "${CMAKE_CURRENT_BINARY_DIR}/service-shutdown-timeout-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/service-shutdown-timeout-tester"
)
add_test("service-shutdown-timeout-tester" "service-shutdown-timeout-tester")

# service-version-bad.service
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/service-version-bad.service.in" "${CMAKE_CURRENT_BINARY_DIR}/service-version-bad.service" @ONLY)

# service-version-bad-service
add_test_executable_by_name(service-version-bad-service)

# service-version-good.service
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/service-version-good.service.in" "${CMAKE_CURRENT_BINARY_DIR}/service-version-good.service" @ONLY)

# service-version-good-service
add_test_executable_by_name(service-version-good-service)

# service-version-manager
add_test_executable_by_name(service-version-manager)

# service-version-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/service-version-tester"
    DEPENDS "service-shutdown-timeout"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/service-version-tester"
    COMMAND
    echo "${DBUS_TEST_RUNNER} --dbus-config ${CMAKE_CURRENT_BINARY_DIR}/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-manager" >> "${CMAKE_CURRENT_BINARY_DIR}/service-version-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/service-version-tester"
)
add_test("service-version-tester" "service-version-tester")

# service-version-multiwatch-manager
add_test_executable_by_name(service-version-multiwatch-manager)

# service-version-multiwatch-manager-impolite
add_test_executable_by_name(service-version-multiwatch-manager-impolite)

# service-version-multiwatch-service
add_test_executable_by_name(service-version-multiwatch-service)

# service-version-multiwatch-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-tester"
    DEPENDS "service-version-multiwatch-manager"
    DEPENDS "service-version-multiwatch-manager-impolite"
    DEPENDS "service-version-multiwatch-service"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-tester"
    COMMAND
    echo "${DBUS_TEST_RUNNER} --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-service --task-name Service --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager --task-name Manager1 --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager --task-name Manager2 --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager --task-name Manager3 --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager --task-name Manager4 --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager --task-name Manager5 --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager-impolite --task-name Impolite1 --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager-impolite --task-name Impolite2 --task ${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-manager-impolite --task-name Impolite3" >> "${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/service-version-multiwatch-tester"
)
add_test("service-version-multiwatch-tester" "service-version-multiwatch-tester")

# test-desktop-shortcuts
add_test_executable_by_name(test-desktop-shortcuts)

# test-desktop-shortcuts-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test-desktop-shortcuts-tester"
    DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-desktop-shortcuts"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/bash" > "${CMAKE_CURRENT_BINARY_DIR}/test-desktop-shortcuts-tester"
    COMMAND
    echo ". ${CMAKE_CURRENT_SOURCE_DIR}/run-xvfb.sh" >> "${CMAKE_CURRENT_BINARY_DIR}/test-desktop-shortcuts-tester"
    COMMAND
    echo "gtester -k --verbose -o=${CMAKE_CURRENT_BINARY_DIR}/loader-check-results.xml ${CMAKE_CURRENT_BINARY_DIR}/test-desktop-shortcuts" >> "${CMAKE_CURRENT_BINARY_DIR}/test-desktop-shortcuts-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/test-desktop-shortcuts-tester"
)
add_test("test-desktop-shortcuts-tester" "test-desktop-shortcuts-tester")

if (FLAVOUR_GTK3 AND ENABLE_IDO)
  # test-indicator-ng
  add_test_executable_by_name(test-indicator-ng)

  # org.ayatana.indicator.test.service
  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/org.ayatana.indicator.test.service.in" "${CMAKE_CURRENT_BINARY_DIR}/org.ayatana.indicator.test.service" @ONLY)

  # test-indicator-ng-dbus-runner
  add_custom_command(
      OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-dbus-runner"
      DEPENDS "test-indicator-ng"
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      VERBATIM
      COMMAND
      echo "#!/bin/sh" > "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-dbus-runner"
      COMMAND
      echo "${DBUS_TEST_RUNNER} --dbus-config /usr/share/dbus-test-runner/session.conf --task ${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng" >> "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-dbus-runner"
      COMMAND
      chmod +x "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-dbus-runner"
  )

  # test-indicator-ng-tester
  add_custom_command(
      OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-tester"
      DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-dbus-runner"
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      VERBATIM
      COMMAND
      echo "#!/bin/bash" > "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-tester"
      COMMAND
      echo ". ${CMAKE_CURRENT_SOURCE_DIR}/run-xvfb.sh" >> "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-tester"
      COMMAND
      echo "gtester -k --verbose -o=${CMAKE_CURRENT_BINARY_DIR}/loader-check-results.xml ${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-dbus-runner" >> "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-tester"
      COMMAND
      chmod +x "${CMAKE_CURRENT_BINARY_DIR}/test-indicator-ng-tester"
  )
  add_test("test-indicator-ng-tester" "test-indicator-ng-tester")
endif(FLAVOUR_GTK3 AND ENABLE_IDO)

# test-loader
add_test_executable_by_name(test-loader)

# loader-tester
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/loader-tester"
    DEPENDS "test-loader"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    VERBATIM
    COMMAND
    echo "#!/bin/bash" > "${CMAKE_CURRENT_BINARY_DIR}/loader-tester"
    COMMAND
    echo ". ${CMAKE_CURRENT_SOURCE_DIR}/run-xvfb.sh" >> "${CMAKE_CURRENT_BINARY_DIR}/loader-tester"
    COMMAND
    echo "gtester -k --verbose -o=${CMAKE_CURRENT_BINARY_DIR}/loader-check-results.xml ${CMAKE_CURRENT_BINARY_DIR}/test-loader" >> "${CMAKE_CURRENT_BINARY_DIR}/loader-tester"
    COMMAND
    chmod +x "${CMAKE_CURRENT_BINARY_DIR}/loader-tester"
)
add_test("loader-tester" "loader-tester")

# indicator-test-service
add_executable("indicator-test-service" indicator-test-service.c)
target_include_directories("indicator-test-service" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS})
target_link_libraries("indicator-test-service" ${PROJECT_DEPS_LIBRARIES})

set (ALL_TESTERS
     "service-manager-connect-tester"
     "service-manager-no-connect-tester"
     "service-manager-connect-nostart-tester"
     "service-shutdown-timeout-tester"
     "service-version-tester"
     "service-version-multiwatch-tester"
     "test-desktop-shortcuts-tester"
     "loader-tester"
)

if (FLAVOUR_GTK3 AND ENABLE_IDO)
  set (ALL_TESTERS
       ${ALL_TESTERS}
       "test-indicator-ng-tester"
  )
endif()

add_custom_target("tests"
                  ALL
                  DEPENDS
                  ${ALL_TESTERS}
)