• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2022 Huawei Device Co., Ltd.module_private_config
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/test.gni")
15import("../../../../batterystats.gni")
16
17module_output_path = "battery_statistics/battery_statistics"
18
19config("module_private_config") {
20  visibility = [ ":*" ]
21
22  include_dirs = [
23    "${batterystats_root_path}/test/unittest/include",
24    "${batterystats_root_path}/test/unittest/include/clienttest",
25    "${batterystats_service_native}/include",
26  ]
27}
28
29config("module_mock_private_config") {
30  include_dirs = [
31    "${batterystats_root_path}/test/unittest/include/clienttest/mock",
32    "${batterystats_root_path}/test/unittest/mock/include",
33    "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include/",
34    "//commonlibrary/c_utils/base/include/",
35  ]
36}
37
38deps_ex = [
39  "ability_base:base",
40  "ability_base:want",
41  "call_manager:tel_call_manager_api",
42  "common_event_service:cesfwk_innerkits",
43  "config_policy:configpolicy_util",
44  "c_utils:utils",
45  "display_manager:displaymgr",
46  "hisysevent:libhisysevent",
47  "hisysevent:libhisyseventmanager",
48  "hilog:libhilog",
49  "ipc:ipc_core",
50  "jsoncpp:jsoncpp",
51  "power_manager:powermgr_client",
52  "safwk:system_ability_fwk",
53  "samgr:samgr_proxy",
54]
55
56############################service_test#############################
57ohos_unittest("stats_service_test") {
58  module_out_path = module_output_path
59
60  sources = [ "stats_service_test.cpp" ]
61
62  configs = [
63    "${batterystats_utils_path}:batterystats_utils_config",
64    ":module_private_config",
65    "${batterystats_utils_path}:coverage_flags",
66  ]
67
68  deps = [
69    "${batterystats_service_path}:batterystats_service",
70    "${batterystats_service_path}:batterystats_stub",
71    "//third_party/googletest:gtest_main",
72  ]
73
74  external_deps = deps_ex
75}
76
77############################service_death_test#############################
78ohos_unittest("stats_service_death_test") {
79  module_out_path = module_output_path
80
81  sources = [
82    "${batterystats_root_path}/test/unittest/mock/source/mock_battery_stats_parser.cpp",
83    "stats_service_death_test.cpp",
84  ]
85
86  configs = [
87    ":module_private_config",
88    "${batterystats_utils_path}:coverage_flags",
89  ]
90
91  defines = [ "STATS_SERVICE_DEATH_UT" ]
92
93  deps = [
94    "${batterystats_inner_api}:batterystats_client",
95    "${batterystats_service_path}:batterystats_service",
96    "${batterystats_service_path}:batterystats_stub",
97    "${batterystats_utils_path}:batterystats_utils",
98    "//third_party/googletest:gtest_main",
99    "//third_party/jsoncpp:jsoncpp",
100  ]
101
102  external_deps = deps_ex
103}
104
105############################wifi_test#############################
106ohos_unittest("stats_wifi_test") {
107  module_out_path = module_output_path
108
109  sources = [
110    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
111    "stats_wifi_test.cpp",
112  ]
113
114  configs = [
115    "${batterystats_utils_path}:batterystats_utils_config",
116    ":module_private_config",
117    "${batterystats_utils_path}:coverage_flags",
118  ]
119
120  deps = [
121    "${batterystats_inner_api}:batterystats_client",
122    "${batterystats_service_path}:batterystats_service",
123    "${batterystats_utils_path}:batterystats_utils",
124    "//third_party/googletest:gtest_main",
125    "//third_party/jsoncpp:jsoncpp",
126  ]
127
128  external_deps = deps_ex
129  external_deps += [ "wifi:wifi_sdk" ]
130}
131
132############################camera_test#############################
133ohos_unittest("stats_camera_test") {
134  module_out_path = module_output_path
135
136  sources = [
137    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
138    "stats_camera_test.cpp",
139  ]
140
141  configs = [
142    "${batterystats_utils_path}:batterystats_utils_config",
143    ":module_private_config",
144    "${batterystats_utils_path}:coverage_flags",
145  ]
146
147  deps = [
148    "${batterystats_inner_api}:batterystats_client",
149    "${batterystats_service_path}:batterystats_service",
150    "${batterystats_utils_path}:batterystats_utils",
151    "//third_party/googletest:gtest_main",
152    "//third_party/jsoncpp:jsoncpp",
153  ]
154
155  external_deps = deps_ex
156}
157
158############################audio_test#############################
159ohos_unittest("stats_audio_test") {
160  module_out_path = module_output_path
161
162  sources = [
163    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
164    "stats_audio_test.cpp",
165  ]
166
167  configs = [
168    ":module_private_config",
169    "${batterystats_utils_path}:coverage_flags",
170  ]
171
172  deps = [
173    "${batterystats_inner_api}:batterystats_client",
174    "${batterystats_service_path}:batterystats_service",
175    "${batterystats_utils_path}:batterystats_utils",
176    "//third_party/googletest:gtest_main",
177    "//third_party/jsoncpp:jsoncpp",
178  ]
179
180  external_deps = deps_ex
181}
182
183############################powermgr_test#############################
184ohos_unittest("stats_powermgr_test") {
185  module_out_path = module_output_path
186
187  sources = [
188    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
189    "stats_powermgr_test.cpp",
190  ]
191
192  configs = [
193    "${batterystats_utils_path}:batterystats_utils_config",
194    ":module_private_config",
195    "${batterystats_utils_path}:coverage_flags",
196  ]
197
198  deps = [
199    "${batterystats_inner_api}:batterystats_client",
200    "${batterystats_service_path}:batterystats_service",
201    "${batterystats_utils_path}:batterystats_utils",
202    "//third_party/googletest:gtest_main",
203    "//third_party/jsoncpp:jsoncpp",
204  ]
205
206  external_deps = deps_ex
207}
208
209############################location_test#############################
210ohos_unittest("stats_location_test") {
211  module_out_path = module_output_path
212
213  sources = [
214    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
215    "stats_location_test.cpp",
216  ]
217
218  configs = [
219    "${batterystats_utils_path}:batterystats_utils_config",
220    ":module_private_config",
221    "${batterystats_utils_path}:coverage_flags",
222  ]
223
224  deps = [
225    "${batterystats_inner_api}:batterystats_client",
226    "${batterystats_service_path}:batterystats_service",
227    "${batterystats_utils_path}:batterystats_utils",
228    "//third_party/googletest:gtest_main",
229    "//third_party/jsoncpp:jsoncpp",
230  ]
231
232  external_deps = deps_ex
233}
234
235############################dump_test#############################
236ohos_unittest("stats_dump_test") {
237  module_out_path = module_output_path
238
239  sources = [ "stats_dump_test.cpp" ]
240
241  configs = [
242    "${batterystats_utils_path}:batterystats_utils_config",
243    ":module_private_config",
244    "${batterystats_utils_path}:coverage_flags",
245  ]
246
247  deps = [
248    "${batterystats_inner_api}:batterystats_client",
249    "${batterystats_service_path}:batterystats_service",
250    "${batterystats_utils_path}:batterystats_utils",
251    "//third_party/googletest:gtest_main",
252  ]
253
254  external_deps = deps_ex
255}
256
257############################display_test#############################
258ohos_unittest("stats_display_test") {
259  module_out_path = module_output_path
260
261  sources = [
262    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
263    "stats_display_test.cpp",
264  ]
265
266  configs = [
267    ":module_private_config",
268    "${batterystats_utils_path}:coverage_flags",
269  ]
270
271  deps = [
272    "${batterystats_inner_api}:batterystats_client",
273    "${batterystats_service_path}:batterystats_service",
274    "${batterystats_utils_path}:batterystats_utils",
275    "//third_party/googletest:gtest_main",
276    "//third_party/jsoncpp:jsoncpp",
277  ]
278
279  external_deps = deps_ex
280}
281
282############################phone_test#############################
283ohos_unittest("stats_phone_test") {
284  module_out_path = module_output_path
285
286  sources = [
287    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
288    "stats_phone_test.cpp",
289  ]
290
291  configs = [
292    ":module_private_config",
293    "${batterystats_utils_path}:coverage_flags",
294  ]
295
296  deps = [
297    "${batterystats_inner_api}:batterystats_client",
298    "${batterystats_service_path}:batterystats_service",
299    "${batterystats_utils_path}:batterystats_utils",
300    "//third_party/googletest:gtest_main",
301    "//third_party/jsoncpp:jsoncpp",
302  ]
303
304  external_deps = deps_ex
305}
306
307############################bluetooth_test#############################
308ohos_unittest("stats_bluetooth_test") {
309  module_out_path = module_output_path
310
311  sources = [
312    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
313    "stats_bluetooth_test.cpp",
314  ]
315
316  configs = [
317    ":module_private_config",
318    "${batterystats_utils_path}:coverage_flags",
319  ]
320
321  deps = [
322    "${batterystats_inner_api}:batterystats_client",
323    "${batterystats_service_path}:batterystats_service",
324    "${batterystats_utils_path}:batterystats_utils",
325    "//third_party/googletest:gtest_main",
326    "//third_party/jsoncpp:jsoncpp",
327  ]
328
329  external_deps = deps_ex
330  external_deps += [ "bluetooth:btframework" ]
331}
332
333############################alarm_test#############################
334ohos_unittest("stats_alarm_test") {
335  module_out_path = module_output_path
336
337  sources = [
338    "${batterystats_service_path}/native/src/battery_stats_parser.cpp",
339    "stats_alarm_test.cpp",
340  ]
341
342  configs = [
343    ":module_private_config",
344    "${batterystats_utils_path}:coverage_flags",
345  ]
346
347  deps = [
348    "${batterystats_inner_api}:batterystats_client",
349    "${batterystats_service_path}:batterystats_service",
350    "${batterystats_utils_path}:batterystats_utils",
351    "//third_party/googletest:gtest_main",
352    "//third_party/jsoncpp:jsoncpp",
353  ]
354
355  external_deps = deps_ex
356}
357
358############################util_test#############################
359ohos_unittest("stats_util_test") {
360  module_out_path = module_output_path
361
362  sources = [ "stats_util_test.cpp" ]
363
364  configs = [
365    "${batterystats_utils_path}:coverage_flags",
366    ":module_private_config",
367    "${batterystats_utils_path}:batterystats_utils_config",
368  ]
369
370  deps = [
371    "${batterystats_service_path}:batterystats_service",
372    "${batterystats_service_path}:batterystats_stub",
373    "${batterystats_utils_path}:batterystats_utils",
374    "//third_party/googletest:gtest_main",
375  ]
376
377  external_deps = deps_ex
378}
379
380############################client_test_mock_parcel#############################
381ohos_unittest("stats_client_test_mock_parcel") {
382  module_out_path = module_output_path
383
384  sources = [
385    "${batterystats_root_path}/test/unittest/mock/source/mock_message_parcel.cpp",
386    "${batterystats_root_path}/test/unittest/mock/source/mock_parcel.cpp",
387    "${batterystats_service_path}/zidl/src/battery_stats_proxy.cpp",
388    "mock/stats_client_test_mock_parcel.cpp",
389  ]
390
391  configs = [
392    ":module_mock_private_config",
393    ":module_private_config",
394    "${batterystats_utils_path}:coverage_flags",
395  ]
396
397  deps = [
398    "${batterystats_inner_api}:batterystats_client",
399    "${batterystats_service_path}:batterystats_service",
400    "${batterystats_utils_path}:batterystats_utils",
401    "//third_party/googletest:gtest_main",
402    "//third_party/jsoncpp:jsoncpp",
403  ]
404
405  external_deps = deps_ex
406}
407
408############################client_test_mock_object#############################
409ohos_unittest("stats_client_test_mock_object") {
410  module_out_path = module_output_path
411
412  sources = [
413    "${batterystats_root_path}/test/unittest/mock/source/mock_stats_remote_object.cpp",
414    "${batterystats_service_path}/zidl/src/battery_stats_proxy.cpp",
415    "mock/stats_client_test_mock_object.cpp",
416  ]
417
418  configs = [
419    ":module_mock_private_config",
420    ":module_private_config",
421    "${batterystats_utils_path}:coverage_flags",
422  ]
423
424  deps = [
425    "${batterystats_inner_api}:batterystats_client",
426    "${batterystats_service_path}:batterystats_service",
427    "${batterystats_utils_path}:batterystats_utils",
428    "//third_party/googletest:gtest_main",
429    "//third_party/jsoncpp:jsoncpp",
430  ]
431
432  external_deps = deps_ex
433}
434
435############################mock_peer_test#############################
436ohos_unittest("stats_client_test_mock_peer") {
437  module_out_path = module_output_path
438
439  sources = [
440    "${batterystats_root_path}/test/unittest/mock/source/mock_peer_holder.cpp",
441    "${batterystats_service_path}/zidl/src/battery_stats_proxy.cpp",
442    "mock/stats_client_test_mock_peer.cpp",
443  ]
444
445  configs = [
446    ":module_mock_private_config",
447    ":module_private_config",
448    "${batterystats_utils_path}:coverage_flags",
449  ]
450
451  deps = [
452    "${batterystats_inner_api}:batterystats_client",
453    "${batterystats_service_path}:batterystats_service",
454    "${batterystats_utils_path}:batterystats_utils",
455    "//third_party/googletest:gtest_main",
456    "//third_party/jsoncpp:jsoncpp",
457  ]
458
459  external_deps = deps_ex
460}
461group("unittest") {
462  testonly = true
463  deps = [
464    ":stats_alarm_test",
465    ":stats_audio_test",
466    ":stats_bluetooth_test",
467    ":stats_camera_test",
468    ":stats_client_test_mock_object",
469    ":stats_client_test_mock_parcel",
470    ":stats_client_test_mock_peer",
471    ":stats_display_test",
472    ":stats_dump_test",
473    ":stats_location_test",
474    ":stats_phone_test",
475    ":stats_powermgr_test",
476    ":stats_service_death_test",
477    ":stats_service_test",
478    ":stats_util_test",
479    ":stats_wifi_test",
480  ]
481}
482