# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//base/hiviewdfx/hiview/hiview.gni") import("//build/test.gni") module_output_path = "hiview/unified_collector" config("unittest_config") { visibility = [ ":*" ] include_dirs = [ ".", "$hiview_plugin/unified_collector/storage/include", "$hiview_plugin/unified_collector/power/include", ] cflags = [ "-D__UNITTEST__" ] } config("state_observer_config") { visibility = [ ":*" ] include_dirs = [ ".", "$hiview_framework/native/unified_collection/process/include", "$hiview_plugin/unified_collector/observer/include", ] cflags = [ "-D__UNITTEST__" ] } config("statetest_config") { visibility = [ ":*" ] include_dirs = [ ".", "mock/include", "$hiview_base/utility/include", "$hiview_plugin/unified_collector/app_trace/include", "$hiview_plugin/unified_collector/include", "$hiview_plugin/unified_collector/observer/include", "$hiview_plugin/unified_collector/storage/include", "$hiview_plugin/unified_collector/task/include", "$hiview_plugin/unified_collector/power/include", "$hiview_framework/native/unified_collection/collector/inner_include", "$hiview_framework/native/unified_collection/process/include", "$hiview_framework/native/unified_collection/decorator/include", "$hiview_base/event_report/include/", "$hiview_plugin/usage_event_report/include/", "$hiview_core/include/", "$hiview_core/param_update/include", "$hiview_root/include", "$hiview_base/include/", ] if (power_manager_enable) { include_dirs += [ "idl/include" ] } cflags = [ "-D__UNITTEST__" ] } ohos_unittest("CpuStorageTest") { module_out_path = module_output_path configs = [ ":unittest_config" ] sources = [ "cpu_storage_test.cpp" ] deps = [ "$hiview_base:hiviewbase_static_lib_for_tdd", "$hiview_core:hiview_core", "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility", "$hiview_plugin/unified_collector:unified_collector", ] external_deps = [ "ffrt:libffrt", "googletest:gmock", "googletest:gtest_main", "hilog:libhilog", "relational_store:native_rdb", ] if (power_manager_enable) { external_deps += [ "common_event_service:cesfwk_innerkits", "power_manager:powermgr_client", ] defines = [ "POWER_MANAGER_ENABLE" ] } } ohos_unittest("UCStateObserverTest") { module_out_path = module_output_path configs = [ ":state_observer_config" ] sources = [ "uc_state_observer_test.cpp" ] deps = [ "$hiview_base:hiviewbase_static_lib_for_tdd", "$hiview_plugin/unified_collector:unified_collector", ] external_deps = [ "ability_base:want", "ability_runtime:app_manager", "googletest:gtest_main", "hilog:libhilog", "ipc:ipc_single", "safwk:system_ability_fwk", ] } ohos_unittest("TraceStateChangeTest") { module_out_path = module_output_path configs = [ ":statetest_config" ] sources = [ "$hiview_base/app_caller_event.cpp", "$hiview_base/plugin.cpp", "$hiview_base/plugin_factory.cpp", "$hiview_base/utility/ash_memory_utils.cpp", "$hiview_base/utility/cjson_util.cpp", "$hiview_base/utility/common_utils.cpp", "$hiview_base/utility/dynamic_module.cpp", "$hiview_base/utility/file_util.cpp", "$hiview_base/utility/freeze_json_util.cpp", "$hiview_base/utility/hiview_db_util.cpp", "$hiview_base/utility/hiview_zip_util.cpp", "$hiview_base/utility/memory_util.cpp", "$hiview_base/utility/socket_util.cpp", "$hiview_base/utility/sql_util.cpp", "$hiview_base/utility/string_util.cpp", "$hiview_base/utility/thread_util.cpp", "$hiview_base/utility/time_util.cpp", "$hiview_framework/native/unified_collection/decorator/unified_collection_stat.cpp", "$hiview_plugin/unified_collector/app_trace/app_trace_context.cpp", "$hiview_plugin/unified_collector/observer/uc_app_state_observer.cpp", "$hiview_plugin/unified_collector/observer/uc_observer_mgr.cpp", "$hiview_plugin/unified_collector/observer/uc_render_state_observer.cpp", "$hiview_plugin/unified_collector/observer/uc_system_ability_listener.cpp", "$hiview_plugin/unified_collector/storage/cpu_storage.cpp", "$hiview_plugin/unified_collector/task/cpu_collection_task.cpp", "$hiview_plugin/unified_collector/task/cpu_perf_dump.cpp", "$hiview_plugin/unified_collector/unified_collector.cpp", "mock/mock_function_jumble.cpp", "mock/mock_parameter_ex.cpp", "trace_state_change_test.cpp", ] deps = [ "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_graphic", "$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility", ] external_deps = [ "ability_runtime:app_manager", "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_core", "cJSON:cjson", "c_utils:utils", "ffrt:libffrt", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_dump", "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_single", "jsoncpp:jsoncpp", "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", "zlib:shared_libz", ] }