1# Copyright (c) 2021-2022 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/test.gni")
15import("//foundation/ability/ability_runtime/ability_runtime.gni")
16
17module_output_path = "ability_runtime/appmgr"
18
19ohos_unittest("ams_mgr_scheduler_test") {
20  sanitize = {
21    cfi = true
22    cfi_cross_dso = true
23    debug = false
24    blocklist = "../../cfi_blocklist.txt"
25  }
26  branch_protector_ret = "pac_ret"
27  module_out_path = module_output_path
28  cflags_cc = []
29  include_dirs = [
30    "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
31    "${ability_runtime_services_path}/appmgr/include",
32    "${ability_runtime_test_path}/mock/mock_appmgr_service/include",
33    "${ability_runtime_test_path}/mock/mock_sa_call",
34    "${ability_runtime_test_path}/mock/services_appmgr_test/include",
35    "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include",
36    "mock/include",
37  ]
38
39  sources = [
40    "${ability_runtime_services_path}/appmgr/src/ams_mgr_scheduler.cpp",
41    "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_bundle_manager.cpp",
42    "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_overlay_manager.cpp",
43    "mock/src/mock_my_flag.cpp",
44    "mock/src/mock_permission_verification.cpp",
45  ]
46
47  sources += [ "ams_mgr_scheduler_test.cpp" ]
48
49  cflags = []
50  configs = [ "${ability_runtime_services_path}/appmgr:appmgr_config" ]
51  if (target_cpu == "arm") {
52    cflags += [ "-DBINDER_IPC_32BIT" ]
53  }
54  deps = [
55    "${ability_runtime_innerkits_path}/app_manager:app_manager",
56    "${ability_runtime_native_path}/appkit:appkit_manager_helper",
57    "${ability_runtime_native_path}/appkit:appkit_native",
58    "${ability_runtime_path}/utils/server/startup:startup_util",
59    "${ability_runtime_services_path}/appmgr:libappms",
60    "${ability_runtime_services_path}/common:app_util",
61    "${ability_runtime_services_path}/common:perm_verification",
62    "${ability_runtime_services_path}/common:task_handler_wrap",
63    "//third_party/googletest:gmock_main",
64    "//third_party/googletest:gtest_main",
65  ]
66
67  external_deps = [
68    "access_token:libaccesstoken_sdk",
69    "access_token:libnativetoken",
70    "access_token:libtoken_setproc",
71    "appspawn:appspawn_client",
72    "bundle_framework:appexecfwk_base",
73    "bundle_framework:appexecfwk_core",
74    "c_utils:utils",
75    "ffrt:libffrt",
76    "hilog:libhilog",
77    "hitrace:hitrace_meter",
78    "init:libbeget_proxy",
79    "init:libbegetutil",
80    "ipc:ipc_core",
81    "napi:ace_napi",
82    "safwk:system_ability_fwk",
83    "samgr:samgr_proxy",
84  ]
85
86  defines = [ "AMS_LOG_TAG = \"AppMgrService\"" ]
87
88  if (ability_command_for_test) {
89    defines += [ "ABILITY_COMMAND_FOR_TEST" ]
90  }
91
92  if (ability_runtime_graphics) {
93    defines += [ "SUPPORT_GRAPHICS" ]
94    deps += []
95    external_deps += [
96      "i18n:intl_util",
97      "window_manager:libwm",
98    ]
99  }
100  cflags_cc = []
101  if (os_dlp_part_enabled) {
102    cflags_cc += [ "-DWITH_DLP" ]
103  }
104}
105
106group("unittest") {
107  testonly = true
108  deps = [ ":ams_mgr_scheduler_test" ]
109}
110