1# Copyright (c) 2021-2025 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("//base/hiviewdfx/hiappevent/hiappevent.gni") 15import("//build/test.gni") 16 17native_hiappevent_path = "//base/hiviewdfx/hiappevent/frameworks/native" 18native_module_output_path = "hiappevent/hiappevent" 19 20config("hiappevent_config_test") { 21 visibility = [ ":*" ] 22 23 include_dirs = [ 24 ".", 25 "//base/hiviewdfx/hiappevent/interfaces/native/kits/include", 26 "$native_hiappevent_path/libhiappevent/cleaner/include", 27 "$native_hiappevent_path/libhiappevent/include", 28 "$native_hiappevent_path/libhiappevent/observer/include", 29 "$native_hiappevent_path/ndk/include", 30 "$hiappevent_interfaces/native/kits/include", 31 ] 32} 33 34ohos_unittest("HiAppEventNativeTest") { 35 module_out_path = native_module_output_path 36 37 configs = [ ":hiappevent_config_test" ] 38 39 sources = [ "unittest/common/native/hiappevent_native_test.cpp" ] 40 41 deps = [ 42 "$native_hiappevent_path/libhiappevent:libhiappevent_base", 43 "$native_hiappevent_path/libhiappevent/utility:hiappevent_utility", 44 "$native_hiappevent_path/ndk:hiappevent_ndk", 45 "processor:test_processor", 46 ] 47 48 resource_config_file = "resource/ohos_test.xml" 49 50 external_deps = [ 51 "ability_runtime:app_context", 52 "googletest:gtest_main", 53 "hiappevent:hiappevent_innerapi", 54 ] 55} 56 57ohos_unittest("HiAppEventCacheTest") { 58 module_out_path = native_module_output_path 59 60 configs = [ ":hiappevent_config_test" ] 61 62 sources = [ "unittest/common/native/hiappevent_cache_test.cpp" ] 63 64 deps = [ 65 "$native_hiappevent_path/libhiappevent:libhiappevent_base", 66 "$native_hiappevent_path/libhiappevent/cache:hiappevent_cache", 67 "$native_hiappevent_path/libhiappevent/utility:hiappevent_utility", 68 "$native_hiappevent_path/ndk:hiappevent_ndk", 69 ] 70 71 external_deps = [ 72 "c_utils:utils", 73 "googletest:gtest_main", 74 "hilog:libhilog", 75 "relational_store:native_rdb", 76 ] 77} 78 79ohos_unittest("HiAppEventWatcherTest") { 80 module_out_path = native_module_output_path 81 82 configs = [ ":hiappevent_config_test" ] 83 84 sources = [ "unittest/common/native/hiappevent_watcher_test.cpp" ] 85 86 deps = [ 87 "$native_hiappevent_path/libhiappevent:libhiappevent_base", 88 "$native_hiappevent_path/libhiappevent/cache:hiappevent_cache", 89 "$native_hiappevent_path/libhiappevent/observer:hiappevent_observer", 90 ] 91 92 external_deps = [ 93 "c_utils:utils", 94 "ffrt:libffrt", 95 "googletest:gtest_main", 96 "hilog:libhilog", 97 "relational_store:native_rdb", 98 ] 99} 100 101ohos_unittest("HiAppEventInnerApiTest") { 102 module_out_path = native_module_output_path 103 104 configs = [ ":hiappevent_config_test" ] 105 106 sources = [ "unittest/common/native/hiappevent_inner_api_test.cpp" ] 107 108 deps = [ "$native_hiappevent_path/libhiappevent:libhiappevent_base" ] 109 110 external_deps = [ 111 "ability_runtime:app_context", 112 "ffrt:libffrt", 113 "googletest:gtest_main", 114 "hiappevent:hiappevent_innerapi", 115 ] 116} 117 118ohos_unittest("HiAppEventUserInfoTest") { 119 module_out_path = native_module_output_path 120 121 configs = [ ":hiappevent_config_test" ] 122 123 sources = [ "unittest/common/native/hiappevent_userinfo_test.cpp" ] 124 125 deps = [ 126 "$native_hiappevent_path/libhiappevent:libhiappevent_base", 127 "$native_hiappevent_path/libhiappevent/cache:hiappevent_cache", 128 ] 129 130 external_deps = [ 131 "c_utils:utils", 132 "googletest:gtest_main", 133 "hilog:libhilog", 134 "relational_store:native_rdb", 135 ] 136} 137 138ohos_unittest("HiAppEventAppEventTest") { 139 module_out_path = native_module_output_path 140 141 configs = [ ":hiappevent_config_test" ] 142 143 sources = [ "unittest/common/native/hiappevent_app_event_test.cpp" ] 144 145 deps = [ "$native_hiappevent_path/libhiappevent:libhiappevent_base" ] 146 147 external_deps = [ 148 "ability_runtime:app_context", 149 "googletest:gtest_main", 150 "hiappevent:hiappevent_innerapi", 151 ] 152} 153 154ohos_unittest("HiAppEventUtilityTest") { 155 module_out_path = native_module_output_path 156 157 configs = [ ":hiappevent_config_test" ] 158 159 sources = [ "unittest/common/native/hiappevent_utility_test.cpp" ] 160 161 deps = [ 162 "$native_hiappevent_path/libhiappevent:libhiappevent_base", 163 "$native_hiappevent_path/libhiappevent/utility:hiappevent_utility", 164 ] 165 166 external_deps = [ 167 "c_utils:utils", 168 "googletest:gtest_main", 169 "jsoncpp:jsoncpp", 170 ] 171} 172 173ohos_unittest("HiAppEventVerifyTest") { 174 module_out_path = native_module_output_path 175 176 configs = [ ":hiappevent_config_test" ] 177 178 sources = [ "unittest/common/native/hiappevent_verify_test.cpp" ] 179 180 deps = [ "$native_hiappevent_path/libhiappevent:libhiappevent_base" ] 181 182 external_deps = [ 183 "c_utils:utils", 184 "googletest:gtest_main", 185 ] 186} 187 188ohos_unittest("HiAppEventDfrResourceOverlimitMgrTest") { 189 module_out_path = native_module_output_path 190 191 configs = [ ":hiappevent_config_test" ] 192 193 sources = [ 194 "unittest/common/native/hiappevent_dfr_resource_overlimit_mgr_test.cpp", 195 "../frameworks/native/libhiappevent/dfr/resource_overlimit_mgr.cpp", 196 ] 197 198 deps = [ 199 "$native_hiappevent_path/libhiappevent:libhiappevent_base", 200 "$native_hiappevent_path/libhiappevent/utility:hiappevent_utility", 201 ] 202 203 external_deps = [ 204 "ability_runtime:app_context", 205 "c_utils:utils", 206 "googletest:gtest_main", 207 "googletest:gmock_main", 208 "hilog:libhilog", 209 ] 210} 211 212group("unittest") { 213 testonly = true 214 deps = [ 215 ":HiAppEventAppEventTest", 216 ":HiAppEventCacheTest", 217 ":HiAppEventInnerApiTest", 218 ":HiAppEventNativeTest", 219 ":HiAppEventUserInfoTest", 220 ":HiAppEventUtilityTest", 221 ":HiAppEventVerifyTest", 222 ":HiAppEventWatcherTest", 223 ":HiAppEventDfrResourceOverlimitMgrTest", 224 "unittest/common/napi:unittest", 225 ] 226} 227