1# Copyright (c) 2022-2025 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/ability_runtime/tools" 18 19ability_delegator_mock_sources = 20 [ "${ability_runtime_path}/tools/test/mock/mock_ability_manager_stub.cpp" ] 21 22config("tools_ability_delegator_config") { 23 include_dirs = [ 24 "${ability_runtime_path}/tools/test/mock", 25 "${ability_runtime_path}/tools/aa/include", 26 ] 27} 28 29ohos_unittest("ability_command_test") { 30 module_out_path = module_output_path 31 32 configs = [ ":tools_ability_delegator_config" ] 33 34 sources = [ "ability_command_test.cpp" ] 35 sources += ability_delegator_mock_sources 36 37 deps = [ 38 "${ability_runtime_path}/tools/aa:tools_aa_source_set", 39 "${ability_runtime_services_path}/abilitymgr:abilityms", 40 ] 41 42 external_deps = [ 43 "ability_base:configuration", 44 "bundle_framework:appexecfwk_base", 45 "googletest:gmock_main", 46 "googletest:gtest_main", 47 "hilog:libhilog", 48 "ipc:ipc_core", 49 ] 50} 51 52ohos_unittest("ability_command_second_test") { 53 module_out_path = module_output_path 54 55 configs = [ ":tools_ability_delegator_config" ] 56 57 sources = [ "ability_command_second_test.cpp" ] 58 sources += ability_delegator_mock_sources 59 60 cflags = [ 61 "-Dprivate=public", 62 "-Dprotected=public", 63 ] 64 65 deps = [ 66 "${ability_runtime_path}/tools/aa:tools_aa_source_set", 67 "${ability_runtime_services_path}/abilitymgr:abilityms", 68 ] 69 70 external_deps = [ 71 "ability_base:configuration", 72 "bundle_framework:appexecfwk_base", 73 "googletest:gmock_main", 74 "googletest:gtest_main", 75 "hilog:libhilog", 76 "ipc:ipc_core", 77 ] 78} 79 80ohos_unittest("test_observer_test") { 81 module_out_path = module_output_path 82 83 configs = [ ":tools_ability_delegator_config" ] 84 85 sources = [ "test_observer_test.cpp" ] 86 sources += ability_delegator_mock_sources 87 88 deps = [ 89 "${ability_runtime_path}/tools/aa:tools_aa_source_set", 90 "${ability_runtime_services_path}/abilitymgr:abilityms", 91 ] 92 93 external_deps = [ 94 "ability_base:configuration", 95 "bundle_framework:appexecfwk_base", 96 "googletest:gmock_main", 97 "googletest:gtest_main", 98 "hilog:libhilog", 99 "ipc:ipc_core", 100 ] 101} 102 103ohos_unittest("test_observer_proxy_test") { 104 module_out_path = module_output_path 105 106 sources = [ "test_observer_proxy_test.cpp" ] 107 108 deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] 109 110 external_deps = [ 111 "googletest:gmock_main", 112 "googletest:gtest_main", 113 "hilog:libhilog", 114 "ipc:ipc_core", 115 ] 116} 117 118ohos_unittest("test_observer_stub_test") { 119 module_out_path = module_output_path 120 121 sources = [ 122 "mock_test_observer_stub.cpp", 123 "test_observer_stub_test.cpp", 124 ] 125 126 deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] 127 128 external_deps = [ 129 "googletest:gmock_main", 130 "googletest:gtest_main", 131 "hilog:libhilog", 132 "ipc:ipc_core", 133 ] 134} 135 136ohos_unittest("shell_command_result_test") { 137 module_out_path = module_output_path 138 139 sources = [ "shell_command_result_test.cpp" ] 140 141 configs = [ ":tools_ability_delegator_config" ] 142 143 deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] 144 145 external_deps = [ 146 "ability_base:configuration", 147 "bundle_framework:appexecfwk_base", 148 "googletest:gmock_main", 149 "googletest:gtest_main", 150 "hilog:libhilog", 151 "ipc:ipc_core", 152 ] 153} 154 155print("accessibility_enable = ", accessibility_enable) 156if (accessibility_enable) { 157 ohos_unittest("shell_command_executor_test") { 158 module_out_path = module_output_path 159 160 sources = [ "shell_command_executor_test.cpp" ] 161 162 configs = [ ":tools_ability_delegator_config" ] 163 164 deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] 165 166 external_deps = [ 167 "ability_base:configuration", 168 "accessibility:accessibility_common", 169 "accessibility:accessibilityclient", 170 "accessibility:accessibilityconfig", 171 "bundle_framework:appexecfwk_base", 172 "eventhandler:libeventhandler", 173 "googletest:gmock_main", 174 "googletest:gtest_main", 175 "hilog:libhilog", 176 "ipc:ipc_core", 177 ] 178 } 179 ohos_unittest("accessibility_ability_command_test") { 180 module_out_path = module_output_path 181 182 symlink_target_name = [ "ability_tool" ] 183 184 include_dirs = [] 185 186 configs = [ ":tools_ability_delegator_config" ] 187 188 sources = [ 189 "${ability_runtime_path}/tools/aa/src/accessibility_ability_command.cpp", 190 "${ability_runtime_path}/tools/aa/src/accessibility_ability_utils.cpp", 191 "accessibility_ability_command_first_test.cpp", 192 "accessibility_ability_command_second_test.cpp", 193 "mock_accessibility_config.cpp", 194 ] 195 196 deps = [ "${ability_runtime_path}/tools/aa:tools_aa_source_set" ] 197 198 external_deps = [ 199 "ability_base:configuration", 200 "access_token:libaccesstoken_sdk", 201 "access_token:libnativetoken", 202 "access_token:libtoken_setproc", 203 "accessibility:accessibility_common", 204 "accessibility:accessibilityclient", 205 "accessibility:accessibilityconfig", 206 "bundle_framework:appexecfwk_base", 207 "cJSON:cjson", 208 "googletest:gtest_main", 209 "hilog:libhilog", 210 "ipc:ipc_core", 211 "selinux_adapter:librestorecon", 212 ] 213 } 214} 215group("unittest") { 216 testonly = true 217 218 deps = [ 219 ":ability_command_second_test", 220 ":ability_command_test", 221 ":shell_command_result_test", 222 ":test_observer_proxy_test", 223 ":test_observer_stub_test", 224 ":test_observer_test", 225 ] 226 if (accessibility_enable) { 227 deps += [ 228 ":accessibility_ability_command_test", 229 ":shell_command_executor_test", 230 ] 231 } 232} 233