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/policy/memory_policy_test.cpp",
51    "src/policy/power_mode_policy_test.cpp",
52    "src/policy/thermal_policy_test.cpp",
53    "src/scheduler_bg_task_subscriber_test.cpp",
54    "src/watchdog_test.cpp",
55    "src/work_conn_manager_test.cpp",
56    "src/work_policy_manager_test.cpp",
57    "src/work_queue_test.cpp",
58    "src/work_status_test.cpp",
59    "src/workschedulerservice_test.cpp",
60    "src/zidl/work_scheduler_proxy_test.cpp",
61  ]
62
63  deps = [
64    "${worksched_frameworks_path}:workschedclient",
65    "${worksched_frameworks_path}/extension:workschedextension",
66    "${worksched_service_path}:workschedservice_static",
67    "${worksched_utils_path}:workschedutils",
68    "//third_party/jsoncpp",
69  ]
70
71  external_deps = [
72    "ability_base:want",
73    "ability_runtime:ability_manager",
74    "ability_runtime:app_manager",
75    "bundle_framework:appexecfwk_base",
76    "bundle_framework:appexecfwk_core",
77    "c_utils:utils",
78    "common_event_service:cesfwk_innerkits",
79    "eventhandler:libeventhandler",
80    "ffrt:libffrt",
81    "hilog:libhilog",
82    "hisysevent:libhisysevent",
83    "ipc:ipc_single",
84    "safwk:system_ability_fwk",
85    "samgr:samgr_proxy",
86  ]
87  defines = []
88  if (bundle_active_enable) {
89    external_deps += [ "device_usage_statistics:usagestatsinner" ]
90    defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ]
91  }
92  if (device_standby_enable) {
93    external_deps += [ "device_standby:standby_innerkits" ]
94    defines += [ "DEVICE_STANDBY_ENABLE" ]
95  }
96  if (resourceschedule_bgtaskmgr_enable) {
97    external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ]
98    defines += [ "RESOURCESCHEDULE_BGTASKMGR_ENABLE" ]
99  }
100  if (powermgr_battery_manager_enable) {
101    external_deps += [ "battery_manager:batterysrv_client" ]
102    defines += [ "POWERMGR_BATTERY_MANAGER_ENABLE" ]
103  }
104  if (powermgr_thermal_manager_enable) {
105    external_deps += [ "thermal_manager:thermalsrv_client" ]
106    defines += [ "POWERMGR_THERMAL_MANAGER_ENABLE" ]
107  }
108  if (powermgr_power_manager_enable) {
109    external_deps += [ "power_manager:powermgr_client" ]
110    defines += [ "POWERMGR_POWER_MANAGER_ENABLE" ]
111  }
112  if (workscheduler_with_communication_netmanager_base_enable) {
113    defines += [ "COMMUNICATION_NETMANAGER_BASE_ENABLE" ]
114    external_deps += [ "netmanager_base:net_conn_manager_if" ]
115  }
116}
117
118group("unittest") {
119  testonly = true
120  deps = []
121  deps += [
122    # deps file
123    ":WorkScheduleServiceTest",
124  ]
125}
126