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 if (time_service_hidumper_able) { 35 defines = [ "HIDUMPER_ENABLE" ] 36 } 37} 38 39module_output_path = "time_service/time/native" 40 41ohos_unittest("TimeServiceTimeTest") { 42 module_out_path = module_output_path 43 44 sources = [ "src/time_service_time_test.cpp" ] 45 46 configs = [ ":module_private_config" ] 47 48 deps = [ 49 "${api_path}:time_client", 50 "${time_service_path}:time_system_ability_static", 51 ] 52 branch_protector_ret = "pac_ret" 53 sanitize = { 54 cfi = true 55 cfi_cross_dso = true 56 debug = false 57 } 58 defines = [] 59 if (!is_emulator && time_service_set_auto_reboot) { 60 defines += [ "SET_AUTO_REBOOT_ENABLE" ] 61 } 62 external_deps = [ 63 "ability_base:want", 64 "ability_runtime:runtime", 65 "ability_runtime:wantagent_innerkits", 66 "access_token:libaccesstoken_sdk", 67 "access_token:libnativetoken", 68 "access_token:libtoken_setproc", 69 "cJSON:cjson", 70 "c_utils:utils", 71 "common_event_service:cesfwk_innerkits", 72 "googletest:gtest_main", 73 "hilog:libhilog", 74 "init:libbegetutil", 75 "ipc:ipc_single", 76 "power_manager:powermgr_client", 77 "safwk:system_ability_fwk", 78 "samgr:samgr_proxy", 79 ] 80 if (time_service_rdb_enable) { 81 defines += [ "RDB_ENABLE" ] 82 external_deps += [ 83 "relational_store:native_dataability", 84 "relational_store:native_rdb", 85 ] 86 } 87 if (time_service_multi_account) { 88 defines += [ "MULTI_ACCOUNT_ENABLE" ] 89 external_deps += [ "os_account:os_account_innerkits" ] 90 } 91} 92 93ohos_unittest("TimeServiceTimerTest") { 94 module_out_path = module_output_path 95 96 sources = [ "src/time_service_timer_test.cpp" ] 97 98 configs = [ ":module_private_config" ] 99 100 deps = [ 101 "${api_path}:time_client", 102 "${time_service_path}:time_system_ability_static", 103 ] 104 branch_protector_ret = "pac_ret" 105 sanitize = { 106 cfi = true 107 cfi_cross_dso = true 108 debug = false 109 } 110 defines = [] 111 if (!is_emulator && time_service_set_auto_reboot) { 112 defines += [ "SET_AUTO_REBOOT_ENABLE" ] 113 } 114 external_deps = [ 115 "ability_base:want", 116 "ability_runtime:runtime", 117 "ability_runtime:wantagent_innerkits", 118 "access_token:libaccesstoken_sdk", 119 "access_token:libnativetoken", 120 "access_token:libtoken_setproc", 121 "cJSON:cjson", 122 "c_utils:utils", 123 "common_event_service:cesfwk_innerkits", 124 "googletest:gtest_main", 125 "hilog:libhilog", 126 "init:libbegetutil", 127 "ipc:ipc_single", 128 "power_manager:powermgr_client", 129 "safwk:system_ability_fwk", 130 "samgr:samgr_proxy", 131 ] 132 if (time_service_rdb_enable) { 133 defines += [ "RDB_ENABLE" ] 134 external_deps += [ 135 "relational_store:native_dataability", 136 "relational_store:native_rdb", 137 ] 138 } 139 if (time_service_multi_account) { 140 defines += [ "MULTI_ACCOUNT_ENABLE" ] 141 external_deps += [ "os_account:os_account_innerkits" ] 142 } 143} 144 145ohos_unittest("TimeClientTest") { 146 module_out_path = module_output_path 147 148 sources = [ "src/time_client_test.cpp" ] 149 150 configs = [ ":module_private_config" ] 151 152 deps = [ 153 "${api_path}:time_client", 154 "${time_service_path}:time_system_ability_static", 155 ] 156 branch_protector_ret = "pac_ret" 157 sanitize = { 158 cfi = true 159 cfi_cross_dso = true 160 debug = false 161 } 162 external_deps = [ 163 "ability_base:want", 164 "ability_runtime:runtime", 165 "ability_runtime:wantagent_innerkits", 166 "access_token:libaccesstoken_sdk", 167 "access_token:libnativetoken", 168 "access_token:libtoken_setproc", 169 "cJSON:cjson", 170 "c_utils:utils", 171 "googletest:gtest_main", 172 "hilog:libhilog", 173 "init:libbegetutil", 174 "ipc:ipc_single", 175 "power_manager:powermgr_client", 176 "safwk:system_ability_fwk", 177 "samgr:samgr_proxy", 178 ] 179} 180 181ohos_unittest("TimeDfxTest") { 182 module_out_path = module_output_path 183 184 sources = [ "src/time_dfx_test.cpp" ] 185 186 configs = [ ":module_private_config" ] 187 188 deps = [ 189 "${api_path}:time_client", 190 "${time_service_path}:time_system_ability_static", 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 "bundle_framework:appexecfwk_core", 206 "cJSON:cjson", 207 "c_utils:utils", 208 "googletest:gtest_main", 209 "hilog:libhilog", 210 "init:libbegetutil", 211 "ipc:ipc_single", 212 "power_manager:powermgr_client", 213 "safwk:system_ability_fwk", 214 "samgr:samgr_proxy", 215 ] 216} 217 218ohos_unittest("TimePermissionTest") { 219 module_out_path = module_output_path 220 221 sources = [ "src/time_permission_test.cpp" ] 222 223 configs = [ ":module_private_config" ] 224 225 deps = [ 226 "${time_utils_path}:time_utils", 227 ] 228 branch_protector_ret = "pac_ret" 229 sanitize = { 230 cfi = true 231 cfi_cross_dso = true 232 debug = false 233 } 234 external_deps = [ 235 "ability_base:want", 236 "ability_runtime:runtime", 237 "ability_runtime:wantagent_innerkits", 238 "c_utils:utils", 239 "googletest:gtest_main", 240 "hilog:libhilog", 241 "ipc:ipc_single", 242 "safwk:system_ability_fwk", 243 "samgr:samgr_proxy", 244 ] 245} 246 247ohos_unittest("TimeProxyTest") { 248 module_out_path = module_output_path 249 250 sources = [ "src/time_proxy_test.cpp" ] 251 252 configs = [ ":module_private_config" ] 253 254 deps = [ 255 "${api_path}:time_client", 256 "${time_service_path}:time_system_ability_static", 257 ] 258 branch_protector_ret = "pac_ret" 259 sanitize = { 260 cfi = true 261 cfi_cross_dso = true 262 debug = false 263 } 264 external_deps = [ 265 "ability_base:want", 266 "ability_runtime:runtime", 267 "ability_runtime:wantagent_innerkits", 268 "access_token:libaccesstoken_sdk", 269 "access_token:libnativetoken", 270 "access_token:libtoken_setproc", 271 "c_utils:utils", 272 "common_event_service:cesfwk_innerkits", 273 "googletest:gtest_main", 274 "hilog:libhilog", 275 "init:libbegetutil", 276 "ipc:ipc_single", 277 "safwk:system_ability_fwk", 278 "samgr:samgr_proxy", 279 ] 280} 281 282group("unittest") { 283 testonly = true 284 285 deps = [ 286 ":TimeClientTest", 287 ":TimeDfxTest", 288 ":TimePermissionTest", 289 ":TimeProxyTest", 290 ":TimeServiceTimeTest", 291 ":TimeServiceTimerTest", 292 ] 293} 294