~thomas-voss/location-service/fix-1347887

« back to all changes in this revision

Viewing changes to tests/CMakeLists.txt

This MP consolidates multiple related changes together, with the goal of:

(1.) Make the service instance accessible via a cli. Useful for testing scenarios.
(2.) To cut down time-to-first-fix (ttff) by:
  (2.1) Leveraging SUPL and other supplementary data downloaded over ordinary data connections.
  (2.2) Enabling network-based positioning providers to acquire fast position estimates.

In more detail:

* Added tests for daemon and cli.
* Unified daemon and cli header and implementation files.
* Add a command-line interface to the service.
* Split up provider selection policy to rely on an interface ProviderEnumerator to ease in testing.
* Trimmed down on types.
* Removed connectivity API draft to prepare for simpler approach.
* Refactored includes.
* Added a configuration option to handle cell and wifi ID reporting.
* Add a mock for a connectivity API exposed to providers and reporters.
* Add units for connectivity api.
* Refactor cell class into namespace radio. Fixes: 1226204, 1248973, 1281817

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
find_package(Threads)
2
2
 
 
3
add_definitions(-DCORE_DBUS_ENABLE_GOOGLE_TEST_FIXTURE -DBOOST_ASIO_DISABLE_MOVE)
 
4
 
3
5
option(
4
6
    LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER 
5
7
    "Rely on dbus test runner to start a private session for testing purposes" 
11
13
    message(STATUS "Executing test suite under dbus-test-runner")
12
14
endif (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER)
13
15
 
 
16
# Build mongoose as static library to leverage in location reporter testing
 
17
add_library(mongoose mongoose.c)
 
18
 
14
19
# Build with system gmock and embedded gtest
15
20
set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory")
16
21
set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory")
17
22
set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")
18
23
 
19
24
add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
 
25
 
 
26
macro(LOCATION_SERVICE_ADD_TEST test_name src)
 
27
  add_executable(
 
28
    ${test_name}
 
29
    ${src})
 
30
 
 
31
  target_link_libraries(
 
32
    ${test_name}
 
33
 
 
34
    ubuntu-location-service
 
35
    ubuntu-location-service-connectivity
 
36
    ubuntu-location-service-daemon
 
37
 
 
38
    mongoose
 
39
 
 
40
    ${Boost_LIBRARIES}
 
41
    ${CMAKE_THREAD_LIBS_INIT}
 
42
 
 
43
    ${PROCESS_CPP_LIBRARIES}
 
44
 
 
45
    ${ARGN}
 
46
 
 
47
    gmock
 
48
 
 
49
    gtest
 
50
    gtest_main)
 
51
 
 
52
  add_test(${test_name} ${CMAKE_CURRENT_BINARY_DIR}/${test_name} --gtest_filter=*-*requires_hardware)
 
53
 
 
54
  # Address android's limit on cmdline length and distill ubuntu-location-service into uls
 
55
  install(
 
56
    TARGETS ${test_name}
 
57
    DESTINATION ${CMAKE_INSTALL_BINDIR}/uls-tests
 
58
  )
 
59
endmacro(LOCATION_SERVICE_ADD_TEST)
 
60
 
20
61
include_directories (
21
62
  ${CMAKE_SOURCE_DIR}/src/location_service
22
63
 
24
65
  ${GTEST_INCLUDE_DIR}
25
66
)
26
67
 
27
 
add_executable(
28
 
    acceptance_tests
29
 
    acceptance_tests.cpp
30
 
    test_main.cpp
31
 
)
32
 
 
33
 
add_executable(
34
 
    accuracy_tests
35
 
    accuracy_tests.cpp
36
 
    test_main.cpp
37
 
)
38
 
 
39
 
add_executable(
40
 
    controller_test
41
 
    controller_test.cpp
42
 
    test_main.cpp
43
 
)
44
 
 
45
 
add_executable(
46
 
    default_permission_manager_test
47
 
    default_permission_manager_test.cpp
48
 
    test_main.cpp
49
 
)
50
 
 
51
 
add_executable(
52
 
    dummy_provider_tests
53
 
    dummy_provider_tests.cpp
54
 
    test_main.cpp
55
 
)
56
 
 
57
 
add_executable(
58
 
    engine_test
59
 
    engine_test.cpp
60
 
    test_main.cpp
61
 
)
62
 
 
63
 
add_executable(
64
 
    position_test
65
 
    position_test.cpp
66
 
    test_main.cpp
67
 
)
68
 
 
69
 
add_executable(
70
 
    provider_selection_policy_test
71
 
    provider_selection_policy_test.cpp
72
 
    test_main.cpp
73
 
)
74
 
 
75
 
add_executable(
76
 
    heading_test
77
 
    heading_test.cpp
78
 
    test_main.cpp
79
 
)
80
 
 
81
 
add_executable(
82
 
    velocity_test
83
 
    velocity_test.cpp
84
 
    test_main.cpp
85
 
)
86
 
 
87
 
add_executable(
88
 
    wgs84_test
89
 
    wgs84_test.cpp
90
 
    test_main.cpp
91
 
)
92
 
 
93
 
add_executable(
94
 
    provider_test
95
 
    provider_test.cpp
96
 
    test_main.cpp
97
 
)
98
 
 
99
 
add_executable(
100
 
    provider_factory_test
101
 
    provider_factory_test.cpp
102
 
    test_main.cpp
103
 
)
104
 
 
105
 
target_link_libraries(
106
 
    default_permission_manager_test
107
 
    
108
 
    ubuntu-location-service
109
 
 
110
 
    ${CMAKE_THREAD_LIBS_INIT}
111
 
    ${Boost_LIBRARIES}
112
 
    ${DBUS_LIBRARIES}
113
 
    
114
 
    gtest
115
 
)
116
 
 
117
 
target_link_libraries(
118
 
    dummy_provider_tests
119
 
 
120
 
    ubuntu-location-service
121
 
 
122
 
    ${CMAKE_THREAD_LIBS_INIT}
123
 
    ${Boost_LIBRARIES}
124
 
    ${DBUS_LIBRARIES}
125
 
 
126
 
    gtest
127
 
)
128
 
 
129
 
target_link_libraries(
130
 
    engine_test
131
 
 
132
 
    ubuntu-location-service
133
 
 
134
 
    ${CMAKE_THREAD_LIBS_INIT}
135
 
    ${Boost_LIBRARIES}
136
 
    ${DBUS_LIBRARIES}
137
 
    
138
 
    gmock
139
 
    gtest
140
 
)
141
 
 
142
 
target_link_libraries(
143
 
    position_test
144
 
 
145
 
    ubuntu-location-service
146
 
    
147
 
    ${CMAKE_THREAD_LIBS_INIT}
148
 
    ${Boost_LIBRARIES}
149
 
    ${DBUS_LIBRARIES}
150
 
    
151
 
    gtest
152
 
)
153
 
 
154
 
target_link_libraries(
155
 
    provider_selection_policy_test
156
 
 
157
 
    ubuntu-location-service
158
 
    
159
 
    ${CMAKE_THREAD_LIBS_INIT}
160
 
    ${Boost_LIBRARIES}
161
 
    ${DBUS_LIBRARIES}
162
 
    
163
 
    gmock
164
 
    gtest
165
 
)
166
 
 
167
 
target_link_libraries(
168
 
    heading_test
169
 
    
170
 
    ubuntu-location-service
171
 
 
172
 
    ${CMAKE_THREAD_LIBS_INIT}
173
 
    ${Boost_LIBRARIES}
174
 
    ${DBUS_LIBRARIES}
175
 
    
176
 
    gtest
177
 
)
178
 
 
179
 
target_link_libraries(
180
 
    velocity_test
181
 
 
182
 
    ubuntu-location-service
183
 
 
184
 
    ${CMAKE_THREAD_LIBS_INIT}
185
 
    ${Boost_LIBRARIES}
186
 
    ${DBUS_LIBRARIES}
187
 
    
188
 
    gtest
189
 
)
190
 
 
191
 
target_link_libraries(
192
 
    wgs84_test
193
 
 
194
 
    ubuntu-location-service
195
 
 
196
 
    ${CMAKE_THREAD_LIBS_INIT}
197
 
    ${Boost_LIBRARIES}
198
 
    ${DBUS_LIBRARIES}
199
 
    
200
 
    gtest
201
 
)
202
 
 
203
 
target_link_libraries(
204
 
    provider_test
205
 
 
206
 
    ubuntu-location-service
207
 
 
208
 
    ${CMAKE_THREAD_LIBS_INIT}
209
 
    ${Boost_LIBRARIES}
210
 
    ${DBUS_LIBRARIES}
211
 
    
212
 
    gmock
213
 
    gtest
214
 
)
215
 
 
216
 
target_link_libraries(
217
 
    provider_factory_test
218
 
 
219
 
    ubuntu-location-service
220
 
 
221
 
    ${CMAKE_THREAD_LIBS_INIT}
222
 
    ${Boost_LIBRARIES}
223
 
    ${DBUS_LIBRARIES}
224
 
    
225
 
    gmock
226
 
    gtest
227
 
)
228
 
 
229
 
target_link_libraries(
230
 
    acceptance_tests
231
 
 
232
 
    ubuntu-location-service
233
 
 
234
 
    ${CMAKE_THREAD_LIBS_INIT}
235
 
    ${Boost_LIBRARIES}
236
 
    ${DBUS_LIBRARIES}
237
 
    gtest
238
 
)
239
 
 
240
 
target_link_libraries(
241
 
    accuracy_tests
242
 
 
243
 
    ubuntu-location-service
244
 
 
245
 
    ${CMAKE_THREAD_LIBS_INIT}
246
 
    ${Boost_LIBRARIES}
247
 
    ${DBUS_LIBRARIES}
248
 
    gtest
249
 
)
250
 
 
251
 
target_link_libraries(
252
 
    controller_test
253
 
 
254
 
    ubuntu-location-service
255
 
 
256
 
    ${CMAKE_THREAD_LIBS_INIT}
257
 
    ${Boost_LIBRARIES}
258
 
    ${DBUS_LIBRARIES}
259
 
 
260
 
    gmock
261
 
    gtest
262
 
)
263
 
 
264
 
if (LOCATION_SERVICE_ENABLE_GPS_PROVIDERS)
265
 
  add_executable(gps_provider_test gps_provider_test.cpp)
266
 
  target_link_libraries(
267
 
    gps_provider_test
268
 
 
269
 
    ubuntu-location-service
270
 
 
271
 
    ${CMAKE_THREAD_LIBS_INIT}
272
 
    ${Boost_LIBRARIES}
273
 
    ${DBUS_LIBRARIES}
274
 
    ubuntu_application_api
275
 
    gtest
276
 
    gtest_main
277
 
  )
278
 
  add_test(gps_provider_test gps_provider_test)
279
 
endif(LOCATION_SERVICE_ENABLE_GPS_PROVIDERS)
 
68
LOCATION_SERVICE_ADD_TEST(acceptance_tests acceptance_tests.cpp)
 
69
LOCATION_SERVICE_ADD_TEST(connectivity_manager_test connectivity_manager_test.cpp)
 
70
LOCATION_SERVICE_ADD_TEST(controller_test controller_test.cpp)
 
71
LOCATION_SERVICE_ADD_TEST(criteria_test criteria_test.cpp)
 
72
LOCATION_SERVICE_ADD_TEST(daemon_and_cli_tests daemon_and_cli_tests.cpp)
 
73
LOCATION_SERVICE_ADD_TEST(default_permission_manager_test default_permission_manager_test.cpp)
 
74
LOCATION_SERVICE_ADD_TEST(engine_test engine_test.cpp)
 
75
LOCATION_SERVICE_ADD_TEST(harvester_test harvester_test.cpp)
 
76
 
 
77
if (NET_CPP_FOUND AND JSONCPP_FOUND)
 
78
  LOCATION_SERVICE_ADD_TEST(ichnaea_reporter_test ichnaea_reporter_test.cpp)
 
79
endif()
 
80
 
 
81
LOCATION_SERVICE_ADD_TEST(position_test position_test.cpp)
 
82
LOCATION_SERVICE_ADD_TEST(provider_selection_policy_test provider_selection_policy_test.cpp)
 
83
LOCATION_SERVICE_ADD_TEST(provider_factory_test provider_factory_test.cpp)
 
84
LOCATION_SERVICE_ADD_TEST(provider_test provider_test.cpp)
 
85
LOCATION_SERVICE_ADD_TEST(wgs84_test wgs84_test.cpp)
 
86
 
 
87
# Provider-specific test-cases go here.
 
88
if (LOCATION_SERVICE_ENABLE_GPS_PROVIDER)
 
89
  include_directories(${CMAKE_SOURCE_DIR}/src/location_service)
 
90
  LOCATION_SERVICE_ADD_TEST(gps_provider_test gps_provider_test.cpp)
 
91
endif(LOCATION_SERVICE_ENABLE_GPS_PROVIDER)
280
92
 
281
93
if (LOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDERS)
282
94
  add_executable(geoclue_provider_test geoclue_provider_test.cpp)
287
99
 
288
100
    ${CMAKE_THREAD_LIBS_INIT}
289
101
    ${Boost_LIBRARIES}
290
 
    ${DBUS_LIBRARIES}
 
102
    ${PROCESS_CPP_LIBRARIES}
 
103
 
291
104
    gtest
292
105
    gtest_main
293
106
  )
297
110
    add_test(geoclue_provider_test ${CMAKE_CURRENT_BINARY_DIR}/geoclue_provider_test)
298
111
  endif (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER)
299
112
endif (LOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDERS)
300
 
 
301
 
if (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER)
302
 
  add_test(acceptance_tests ${DBUS_TEST_RUNNER_EXECUTABLE} --task=${CMAKE_CURRENT_BINARY_DIR}/acceptance_tests)
303
 
else (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER)
304
 
  add_test(acceptance_tests ${CMAKE_CURRENT_BINARY_DIR}/acceptance_tests)
305
 
endif (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER)
306
 
 
307
 
add_test(provider_test provider_test)
308
 
add_test(accuracy_tests accuracy_tests)
309
 
add_test(controller_test controller_test)
310
 
add_test(default_permission_manager_test default_permission_manager_test)
311
 
add_test(engine_test engine_test)
312
 
add_test(position_test position_test)
313
 
add_test(provider_factory_test provider_factory_test)
314
 
add_test(provider_selection_policy_test provider_selection_policy_test)
315
 
add_test(heading_test heading_test)
316
 
add_test(velocity_test velocity_test)
317
 
add_test(wgs84_test wgs84_test)
318
 
add_test(dummy_provider_tests dummy_provider_tests)