1# Copyright (c) 2024 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/hiview/hiview.gni")
15import("//build/test.gni")
16
17module_output_path = "hiview/unified_collector"
18
19config("unittest_config") {
20  visibility = [ ":*" ]
21
22  include_dirs = [
23    ".",
24    "$hiview_plugin/unified_collector/storage/include",
25    "$hiview_plugin/unified_collector/power/include",
26  ]
27
28  cflags = [ "-D__UNITTEST__" ]
29}
30
31config("state_observer_config") {
32  visibility = [ ":*" ]
33
34  include_dirs = [
35    ".",
36    "$hiview_framework/native/unified_collection/process/include",
37    "$hiview_plugin/unified_collector/observer/include",
38  ]
39
40  cflags = [ "-D__UNITTEST__" ]
41}
42
43config("statetest_config") {
44  visibility = [ ":*" ]
45
46  include_dirs = [
47    ".",
48    "mock/include",
49    "$hiview_base/utility/include",
50    "$hiview_plugin/unified_collector/app_trace/include",
51    "$hiview_plugin/unified_collector/include",
52    "$hiview_plugin/unified_collector/observer/include",
53    "$hiview_plugin/unified_collector/storage/include",
54    "$hiview_plugin/unified_collector/task/include",
55    "$hiview_plugin/unified_collector/power/include",
56    "$hiview_framework/native/unified_collection/collector/inner_include",
57    "$hiview_framework/native/unified_collection/process/include",
58    "$hiview_framework/native/unified_collection/decorator/include",
59    "$hiview_base/event_report/include/",
60    "$hiview_plugin/usage_event_report/include/",
61    "$hiview_core/include/",
62    "$hiview_core/param_update/include",
63    "$hiview_root/include",
64    "$hiview_base/include/",
65  ]
66
67  if (power_manager_enable) {
68    include_dirs += [ "idl/include" ]
69  }
70
71  cflags = [ "-D__UNITTEST__" ]
72}
73
74ohos_unittest("CpuStorageTest") {
75  module_out_path = module_output_path
76
77  configs = [ ":unittest_config" ]
78
79  sources = [ "cpu_storage_test.cpp" ]
80
81  deps = [
82    "$hiview_base:hiviewbase_static_lib_for_tdd",
83    "$hiview_core:hiview_core",
84    "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility",
85    "$hiview_plugin/unified_collector:unified_collector",
86  ]
87
88  external_deps = [
89    "ffrt:libffrt",
90    "googletest:gmock",
91    "googletest:gtest_main",
92    "hilog:libhilog",
93    "relational_store:native_rdb",
94  ]
95
96  if (power_manager_enable) {
97    external_deps += [
98      "common_event_service:cesfwk_innerkits",
99      "power_manager:powermgr_client",
100    ]
101    defines = [ "POWER_MANAGER_ENABLE" ]
102  }
103}
104
105ohos_unittest("UCStateObserverTest") {
106  module_out_path = module_output_path
107
108  configs = [ ":state_observer_config" ]
109
110  sources = [ "uc_state_observer_test.cpp" ]
111
112  deps = [
113    "$hiview_base:hiviewbase_static_lib_for_tdd",
114    "$hiview_plugin/unified_collector:unified_collector",
115  ]
116
117  external_deps = [
118    "ability_base:want",
119    "ability_runtime:app_manager",
120    "googletest:gtest_main",
121    "hilog:libhilog",
122    "ipc:ipc_single",
123    "safwk:system_ability_fwk",
124  ]
125}
126
127ohos_unittest("TraceStateChangeTest") {
128  module_out_path = module_output_path
129
130  configs = [ ":statetest_config" ]
131
132  sources = [
133    "$hiview_base/app_caller_event.cpp",
134    "$hiview_base/plugin.cpp",
135    "$hiview_base/plugin_factory.cpp",
136    "$hiview_base/utility/ash_memory_utils.cpp",
137    "$hiview_base/utility/cjson_util.cpp",
138    "$hiview_base/utility/common_utils.cpp",
139    "$hiview_base/utility/dynamic_module.cpp",
140    "$hiview_base/utility/file_util.cpp",
141    "$hiview_base/utility/freeze_json_util.cpp",
142    "$hiview_base/utility/hiview_db_util.cpp",
143    "$hiview_base/utility/hiview_zip_util.cpp",
144    "$hiview_base/utility/memory_util.cpp",
145    "$hiview_base/utility/socket_util.cpp",
146    "$hiview_base/utility/sql_util.cpp",
147    "$hiview_base/utility/string_util.cpp",
148    "$hiview_base/utility/thread_util.cpp",
149    "$hiview_base/utility/time_util.cpp",
150    "$hiview_framework/native/unified_collection/decorator/unified_collection_stat.cpp",
151    "$hiview_plugin/unified_collector/app_trace/app_trace_context.cpp",
152    "$hiview_plugin/unified_collector/observer/uc_app_state_observer.cpp",
153    "$hiview_plugin/unified_collector/observer/uc_observer_mgr.cpp",
154    "$hiview_plugin/unified_collector/observer/uc_render_state_observer.cpp",
155    "$hiview_plugin/unified_collector/observer/uc_system_ability_listener.cpp",
156    "$hiview_plugin/unified_collector/storage/cpu_storage.cpp",
157    "$hiview_plugin/unified_collector/task/cpu_collection_task.cpp",
158    "$hiview_plugin/unified_collector/task/cpu_perf_dump.cpp",
159    "$hiview_plugin/unified_collector/unified_collector.cpp",
160    "mock/mock_function_jumble.cpp",
161    "mock/mock_parameter_ex.cpp",
162    "trace_state_change_test.cpp",
163  ]
164
165  deps = [
166    "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_graphic",
167    "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility",
168  ]
169
170  external_deps = [
171    "ability_runtime:app_manager",
172    "access_token:libaccesstoken_sdk",
173    "bundle_framework:appexecfwk_core",
174    "cJSON:cjson",
175    "c_utils:utils",
176    "ffrt:libffrt",
177    "hilog:libhilog",
178    "hisysevent:libhisysevent",
179    "hitrace:hitrace_dump",
180    "init:libbeget_proxy",
181    "init:libbegetutil",
182    "ipc:ipc_single",
183    "jsoncpp:jsoncpp",
184    "relational_store:native_rdb",
185    "safwk:system_ability_fwk",
186    "samgr:samgr_proxy",
187    "zlib:shared_libz",
188  ]
189}
190