1# Copyright (c) 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/config/features.gni")
15import("//build/test.gni")
16import("//foundation/resourceschedule/work_scheduler/workscheduler.gni")
17
18module_output_path = "work_scheduler/unittest"
19config("worksched_private_config") {
20  include_dirs = [
21    "${worksched_service_path}/zidl/include",
22    "${worksched_service_path}/native/include",
23  ]
24}
25
26ohos_unittest("WorkScheduleServiceTest") {
27  sanitize = {
28    cfi = true
29    cfi_cross_dso = true
30    debug = false
31  }
32  cflags_cc = [
33    "-Dprivate=public",
34    "-Dprotected=public",
35  ]
36  module_out_path = module_output_path
37  configs = [ ":worksched_private_config" ]
38  cflags = [
39    "-g",
40    "-O0",
41    "-Wno-unused-variable",
42    "-fno-omit-frame-pointer",
43  ]
44  sources = [
45    "src/conditions/network_listener_test.cpp",
46    "src/conditions/screen_listener_test.cpp",
47    "src/event_publisher_test.cpp",
48    "src/policy/app_data_clear_listener_test.cpp",
49    "src/policy/cpu_policy_test.cpp",
50    "src/watchdog_test.cpp",
51    "src/work_conn_manager_test.cpp",
52    "src/work_policy_manager_test.cpp",
53    "src/work_sched_config_test.cpp",
54    "src/work_sched_data_manager_test.cpp",
55    "src/work_status_test.cpp",
56    "src/workschedulerservice_test.cpp",
57    "src/zidl/work_scheduler_proxy_test.cpp",
58  ]
59
60  deps = [
61    "${worksched_frameworks_path}:workschedclient",
62    "${worksched_frameworks_path}/extension:workschedextension",
63    "${worksched_service_path}:workschedservice_static",
64    "${worksched_utils_path}:workschedutils",
65    "//third_party/jsoncpp",
66  ]
67
68  external_deps = [
69    "ability_base:want",
70    "ability_runtime:ability_manager",
71    "ability_runtime:app_manager",
72    "bundle_framework:appexecfwk_base",
73    "bundle_framework:appexecfwk_core",
74    "c_utils:utils",
75    "common_event_service:cesfwk_innerkits",
76    "eventhandler:libeventhandler",
77    "ffrt:libffrt",
78    "hilog:libhilog",
79    "hisysevent:libhisysevent",
80    "ipc:ipc_single",
81    "safwk:system_ability_fwk",
82    "samgr:samgr_proxy",
83  ]
84  defines = []
85  if (bundle_active_enable) {
86    external_deps += [ "device_usage_statistics:usagestatsinner" ]
87    defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ]
88  }
89  if (device_standby_enable) {
90    external_deps += [ "device_standby:standby_innerkits" ]
91    defines += [ "DEVICE_STANDBY_ENABLE" ]
92  }
93  if (resourceschedule_bgtaskmgr_enable) {
94    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
95    defines += [ "RESOURCESCHEDULE_BGTASKMGR_ENABLE" ]
96  }
97  if (powermgr_battery_manager_enable) {
98    external_deps += [ "battery_manager:batterysrv_client" ]
99    defines += [ "POWERMGR_BATTERY_MANAGER_ENABLE" ]
100  }
101  if (powermgr_thermal_manager_enable) {
102    external_deps += [ "thermal_manager:thermalsrv_client" ]
103    defines += [ "POWERMGR_THERMAL_MANAGER_ENABLE" ]
104  }
105  if (powermgr_power_manager_enable) {
106    external_deps += [ "power_manager:powermgr_client" ]
107    defines += [ "POWERMGR_POWER_MANAGER_ENABLE" ]
108  }
109  if (workscheduler_with_communication_netmanager_base_enable) {
110    defines += [ "COMMUNICATION_NETMANAGER_BASE_ENABLE" ]
111    external_deps += [ "netmanager_base:net_conn_manager_if" ]
112  }
113}
114
115group("unittest") {
116  testonly = true
117  deps = []
118  deps += [
119    # deps file
120    ":WorkScheduleServiceTest",
121  ]
122}
123