1# Copyright (C) 2021-2023 Huawei Device Co., Ltd.
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("../../../time.gni")
16
17config("module_private_config") {
18  visibility = [ ":*" ]
19
20  include_dirs = [
21    "${api_path}/include",
22    "include",
23    "${time_utils_path}/native/include",
24    "${time_service_path}/time/include",
25    "${time_service_path}",
26    "${time_service_path}/dfx/include",
27    "${time_service_path}/ipc/stub",
28    "${time_service_path}/ipc/base",
29    "${time_service_path}/timer/include",
30  ]
31  cflags = [ "-fvisibility=hidden" ]
32  cflags_cc = [ "-fvisibility-inlines-hidden" ]
33}
34
35module_output_path = "time_service/native"
36
37ohos_unittest("TimeServiceTest") {
38  module_out_path = module_output_path
39
40  sources = [ "src/time_service_test.cpp" ]
41
42  configs = [ ":module_private_config" ]
43
44  deps = [
45    "${api_path}:time_client",
46    "${time_service_path}:time_system_ability_static",
47    "//third_party/googletest:gtest_main",
48  ]
49  branch_protector_ret = "pac_ret"
50  sanitize = {
51    cfi = true
52    cfi_cross_dso = true
53    debug = false
54  }
55  external_deps = [
56    "ability_base:want",
57    "ability_runtime:runtime",
58    "ability_runtime:wantagent_innerkits",
59    "access_token:libaccesstoken_sdk",
60    "access_token:libnativetoken",
61    "access_token:libtoken_setproc",
62    "c_utils:utils",
63    "common_event_service:cesfwk_innerkits",
64    "hilog:libhilog",
65    "init:libbegetutil",
66    "ipc:ipc_single",
67    "jsoncpp:jsoncpp",
68    "power_manager:powermgr_client",
69    "relational_store:native_dataability",
70    "relational_store:native_rdb",
71    "safwk:system_ability_fwk",
72    "samgr:samgr_proxy",
73  ]
74}
75
76ohos_unittest("TimeClientTest") {
77  module_out_path = module_output_path
78
79  sources = [ "src/time_client_test.cpp" ]
80
81  configs = [ ":module_private_config" ]
82
83  deps = [
84    "${api_path}:time_client",
85    "${time_service_path}:time_system_ability_static",
86    "//third_party/googletest:gtest_main",
87  ]
88  branch_protector_ret = "pac_ret"
89  sanitize = {
90    cfi = true
91    cfi_cross_dso = true
92    debug = false
93  }
94  external_deps = [
95    "ability_base:want",
96    "ability_runtime:runtime",
97    "ability_runtime:wantagent_innerkits",
98    "access_token:libaccesstoken_sdk",
99    "access_token:libnativetoken",
100    "access_token:libtoken_setproc",
101    "c_utils:utils",
102    "hilog:libhilog",
103    "init:libbegetutil",
104    "ipc:ipc_single",
105    "power_manager:powermgr_client",
106    "relational_store:native_dataability",
107    "relational_store:native_rdb",
108    "safwk:system_ability_fwk",
109    "samgr:samgr_proxy",
110  ]
111}
112
113ohos_unittest("TimeDfxTest") {
114  module_out_path = module_output_path
115
116  sources = [ "src/time_dfx_test.cpp" ]
117
118  configs = [ ":module_private_config" ]
119
120  deps = [
121    "${api_path}:time_client",
122    "${time_service_path}:time_system_ability_static",
123    "//third_party/googletest:gtest_main",
124  ]
125  branch_protector_ret = "pac_ret"
126  sanitize = {
127    cfi = true
128    cfi_cross_dso = true
129    debug = false
130  }
131  external_deps = [
132    "ability_base:want",
133    "ability_runtime:runtime",
134    "ability_runtime:wantagent_innerkits",
135    "access_token:libaccesstoken_sdk",
136    "access_token:libnativetoken",
137    "access_token:libtoken_setproc",
138    "bundle_framework:appexecfwk_core",
139    "c_utils:utils",
140    "hilog:libhilog",
141    "init:libbegetutil",
142    "ipc:ipc_single",
143    "power_manager:powermgr_client",
144    "relational_store:native_dataability",
145    "relational_store:native_rdb",
146    "safwk:system_ability_fwk",
147    "samgr:samgr_proxy",
148  ]
149}
150
151ohos_unittest("TimePermissionTest") {
152  module_out_path = module_output_path
153
154  sources = [ "src/time_permission_test.cpp" ]
155
156  configs = [ ":module_private_config" ]
157
158  deps = [
159    "${time_utils_path}:time_utils",
160    "//third_party/googletest:gtest_main",
161  ]
162  branch_protector_ret = "pac_ret"
163  sanitize = {
164    cfi = true
165    cfi_cross_dso = true
166    debug = false
167  }
168  external_deps = [
169    "ability_base:want",
170    "ability_runtime:runtime",
171    "ability_runtime:wantagent_innerkits",
172    "c_utils:utils",
173    "hilog:libhilog",
174    "ipc:ipc_single",
175    "safwk:system_ability_fwk",
176    "samgr:samgr_proxy",
177  ]
178}
179
180ohos_unittest("TimeProxyTest") {
181  module_out_path = module_output_path
182
183  sources = [ "src/time_proxy_test.cpp" ]
184
185  configs = [ ":module_private_config" ]
186
187  deps = [
188    "${api_path}:time_client",
189    "${time_service_path}:time_system_ability_static",
190    "//third_party/googletest:gtest_main",
191  ]
192  branch_protector_ret = "pac_ret"
193  sanitize = {
194    cfi = true
195    cfi_cross_dso = true
196    debug = false
197  }
198  external_deps = [
199    "ability_base:want",
200    "ability_runtime:runtime",
201    "ability_runtime:wantagent_innerkits",
202    "access_token:libaccesstoken_sdk",
203    "access_token:libnativetoken",
204    "access_token:libtoken_setproc",
205    "c_utils:utils",
206    "common_event_service:cesfwk_innerkits",
207    "hilog:libhilog",
208    "init:libbegetutil",
209    "ipc:ipc_single",
210    "safwk:system_ability_fwk",
211    "samgr:samgr_proxy",
212  ]
213}
214
215group("unittest") {
216  testonly = true
217
218  deps = [
219    ":TimeClientTest",
220    ":TimeDfxTest",
221    ":TimePermissionTest",
222    ":TimeProxyTest",
223    ":TimeServiceTest",
224  ]
225}
226