1# Copyright (c) 2023-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/multimedia/player_framework/config.gni") 16 17config("screen_capture_test_config") { 18 visibility = [ ":*" ] 19 20 cflags = [ 21 "-std=c++17", 22 "-fno-rtti", 23 "-fno-exceptions", 24 "-Wall", 25 "-fno-common", 26 "-fstack-protector-strong", 27 "-Wshadow", 28 "-FPIC", 29 "-FS", 30 "-O2", 31 "-D_FORTIFY_SOURCE=2", 32 "-Wformat=2", 33 "-Wfloat-equal", 34 "-Wdate-time", 35 "-Werror", 36 "-Wimplicit-fallthrough", 37 "-Wsign-compare", 38 "-Dprivate=public", 39 "-Dprotected=public", 40 ] 41 42 include_dirs = [ 43 "./", 44 "./screen_capture_unittest/include", 45 "./capi/include", 46 "$MEDIA_PLAYER_ROOT_DIR/services/services/sa_media/ipc", 47 "$MEDIA_PLAYER_ROOT_DIR/services/services/sa_media/server", 48 "$MEDIA_PLAYER_ROOT_DIR/services/services/sa_media/server_manager", 49 "$MEDIA_PLAYER_ROOT_DIR/services/services/common", 50 "$MEDIA_PLAYER_ROOT_DIR/services/services/player/ipc", 51 "$MEDIA_PLAYER_ROOT_DIR/services/services/player/player_mem_manage", 52 "$MEDIA_PLAYER_ROOT_DIR/services/services/player/server", 53 "$MEDIA_PLAYER_ROOT_DIR/services/services/player/subscriber", 54 "$MEDIA_PLAYER_ROOT_DIR/services/services/media_data_source/ipc", 55 "$MEDIA_PLAYER_ROOT_DIR/services/services/media_data_source/server", 56 "$MEDIA_PLAYER_ROOT_DIR/services/services/monitor/client", 57 "$MEDIA_PLAYER_ROOT_DIR/services/services/monitor/ipc", 58 "$MEDIA_PLAYER_ROOT_DIR/services/services/monitor/server", 59 "$MEDIA_PLAYER_ROOT_DIR/services/services/recorder/ipc", 60 "$MEDIA_PLAYER_ROOT_DIR/services/services/recorder/server", 61 "$MEDIA_PLAYER_ROOT_DIR/services/services/avmetadatahelper/ipc", 62 "$MEDIA_PLAYER_ROOT_DIR/services/services/avmetadatahelper/server", 63 "avcodec/ipc", 64 "avcodec/server", 65 "avcodeclist/ipc", 66 "avcodeclist/server", 67 "$MEDIA_PLAYER_ROOT_DIR/services/services/recorder_profiles/ipc", 68 "$MEDIA_PLAYER_ROOT_DIR/services/services/recorder_profiles/server", 69 "$MEDIA_PLAYER_ROOT_DIR/services/services/screen_capture/server", 70 "$MEDIA_PLAYER_ROOT_DIR/services/services/screen_capture/ipc", 71 "$MEDIA_PLAYER_ROOT_DIR/services/services/screen_capture_monitor/server", 72 "$MEDIA_PLAYER_ROOT_DIR/services/services/screen_capture_monitor/ipc", 73 "$MEDIA_PLAYER_ROOT_DIR/services/services/transcoder/server", 74 "$MEDIA_PLAYER_ROOT_DIR/services/services/transcoder/ipc", 75 "$MEDIA_PLAYER_ROOT_DIR/services/services/observer", 76 "$MEDIA_PLAYER_ROOT_DIR/services/include", 77 "$MEDIA_PLAYER_ROOT_DIR/services/services/factory", 78 "$MEDIA_PLAYER_ROOT_DIR/services/services/engine_intf", 79 "$MEDIA_PLAYER_ROOT_DIR/services/utils/include", 80 "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", 81 "$MEDIA_PLAYER_ROOT_DIR/services/services/common", 82 "$MEDIA_PLAYER_ROOT_DIR/services/engine/common/recorder_profiles", 83 "$MEDIA_PLAYER_ROOT_DIR/test/unittest/common/include", 84 "$MEDIA_PLAYER_ROOT_DIR/test/unittest/screen_capture_test/screen_capture_service_function_unittest/server/include", 85 "$MEDIA_PLAYER_GRAPHIC_SURFACE/interfaces/inner_api/surface", 86 ] 87 88 defines = [] 89 defines += player_framework_defines 90 91 if (target_cpu == "arm") { 92 cflags += [ "-DBINDER_IPC_32BIT" ] 93 } 94} 95 96module_output_path = "player_framework/screen_capture" 97 98ohos_unittest("screen_capture_native_unit_test") { 99 module_out_path = module_output_path 100 include_dirs = [ 101 "./", 102 "./screen_capture_unittest/include", 103 "./native/include", 104 "$MEDIA_PLAYER_ROOT_DIR/test/unittest/common/include", 105 "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", 106 "$MEDIA_PLAYER_GRAPHIC_SURFACE/interfaces/inner_api/surface", 107 ] 108 109 sanitize = { 110 cfi = true 111 cfi_cross_dso = true 112 debug = false 113 } 114 115 cflags = [ 116 "-Wall", 117 "-Werror", 118 ] 119 120 if (player_framework_support_screen_capture) { 121 sources = [ 122 "native/screen_capture_mock_factory.cpp", 123 "native/src/screen_capture_native_mock.cpp", 124 "screen_capture_unittest/src/screen_capture_unit_test.cpp", 125 "screen_capture_unittest/src/screen_capture_unit_test_exclude.cpp", 126 "screen_capture_unittest/src/screen_capture_unit_test_state.cpp", 127 ] 128 } 129 130 external_deps = [ 131 "ability_base:base", 132 "ability_base:want", 133 "ability_base:zuri", 134 "ability_runtime:ability_context_native", 135 "ability_runtime:ability_manager", 136 "ability_runtime:abilitykit_native", 137 "ability_runtime:app_context", 138 "ability_runtime:app_manager", 139 "ability_runtime:data_ability_helper", 140 "ability_runtime:mission_info", 141 "access_token:libaccesstoken_sdk", 142 "access_token:libnativetoken_shared", 143 "access_token:libtokensetproc_shared", 144 "audio_framework:audio_client", 145 "av_codec:av_codec_client", 146 "c_utils:utils", 147 "graphic_2d:librender_service_base", 148 "graphic_surface:surface", 149 "hilog:libhilog", 150 "i18n:intl_util", 151 "player_framework:media_client", 152 "resource_management:global_resmgr", 153 "window_manager:libdm", 154 ] 155 156 resource_config_file = "../resources/ohos_test.xml" 157} 158 159################################################################################################################## 160 161ohos_unittest("screen_capture_capi_unit_test") { 162 module_out_path = module_output_path 163 include_dirs = [ 164 "./", 165 "./screen_capture_unittest/include", 166 "./capi/include", 167 "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c", 168 "$MEDIA_PLAYER_ROOT_DIR/test/unittest/common/include", 169 "$MEDIA_PLAYER_ROOT_DIR/frameworks/native/capi/common", 170 "$MEDIA_PLAYER_ROOT_DIR/interfaces/inner_api/native", 171 "$MEDIA_PLAYER_GRAPHIC_SURFACE/interfaces/inner_api/surface", 172 ] 173 174 sanitize = { 175 cfi = true 176 cfi_cross_dso = true 177 debug = false 178 } 179 180 cflags = [ 181 "-Wall", 182 "-Werror", 183 ] 184 185 if (player_framework_support_screen_capture) { 186 sources = [ 187 "capi/screen_capture_mock_factory.cpp", 188 "capi/src/screen_capture_capi_mock.cpp", 189 "screen_capture_unittest/src/screen_capture_unit_test.cpp", 190 "screen_capture_unittest/src/screen_capture_unit_test_exclude.cpp", 191 "screen_capture_unittest/src/screen_capture_unit_test_state.cpp", 192 ] 193 } 194 195 deps = [ "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c:native_avscreen_capture" ] 196 197 external_deps = [ 198 "ability_base:base", 199 "ability_base:want", 200 "ability_base:zuri", 201 "ability_runtime:ability_context_native", 202 "ability_runtime:ability_manager", 203 "ability_runtime:abilitykit_native", 204 "ability_runtime:app_context", 205 "ability_runtime:app_manager", 206 "ability_runtime:data_ability_helper", 207 "ability_runtime:mission_info", 208 "access_token:libaccesstoken_sdk", 209 "access_token:libnativetoken_shared", 210 "access_token:libtokensetproc_shared", 211 "audio_framework:audio_client", 212 "av_codec:av_codec_client", 213 "c_utils:utils", 214 "graphic_2d:librender_service_base", 215 "graphic_surface:surface", 216 "hilog:libhilog", 217 "i18n:intl_util", 218 "media_foundation:media_foundation", 219 "player_framework:media_client", 220 "resource_management:global_resmgr", 221 "window_manager:libdm", 222 ] 223 224 resource_config_file = "../resources/ohos_test.xml" 225} 226 227################################################################################################################## 228 229ohos_unittest("screen_capture_server_function_unit_test") { 230 module_out_path = module_output_path 231 stack_protector_ret = true 232 install_enable = true 233 234 sanitize = { 235 cfi = true 236 cfi_cross_dso = true 237 debug = false 238 } 239 240 public_deps = [ "$MEDIA_PLAYER_ROOT_DIR/services/services:media_service" ] 241 242 configs = [ 243 ":screen_capture_test_config", 244 "$MEDIA_PLAYER_ROOT_DIR/services/dfx:media_service_log_dfx_public_config", 245 ] 246 247 deps = [ 248 "$MEDIA_PLAYER_ROOT_DIR/interfaces/kits/c:native_avscreen_capture", 249 "$MEDIA_PLAYER_ROOT_DIR/services/dfx:media_service_dfx", 250 "$MEDIA_PLAYER_ROOT_DIR/services/dfx:media_service_log_dfx", 251 "$MEDIA_PLAYER_ROOT_DIR/services/utils:media_service_utils", 252 ] 253 254 if (player_framework_support_screen_capture) { 255 sources = [ 256 "screen_capture_service_function_unittest/server/src/audio_capturer_wrapper_function_unittest.cpp", 257 "screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest.cpp", 258 "screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest_multiInstance.cpp", 259 "screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest_recorder.cpp", 260 "screen_capture_service_function_unittest/server/src/screen_capture_server_function_unittest_voip.cpp", 261 ] 262 } 263 264 external_deps = [ 265 "ability_base:base", 266 "ability_base:want", 267 "ability_base:zuri", 268 "ability_runtime:ability_context_native", 269 "ability_runtime:ability_manager", 270 "ability_runtime:abilitykit_native", 271 "ability_runtime:app_context", 272 "ability_runtime:app_manager", 273 "ability_runtime:data_ability_helper", 274 "ability_runtime:mission_info", 275 "access_token:libaccesstoken_sdk", 276 "access_token:libnativetoken_shared", 277 "access_token:libprivacy_sdk", 278 "access_token:libtokensetproc_shared", 279 "audio_framework:audio_client", 280 "audio_framework:audio_foundation", 281 "av_codec:av_codec_client", 282 "c_utils:utils", 283 "call_manager:tel_call_manager_api", 284 "core_service:tel_core_service_api", 285 "distributed_notification_service:ans_innerkits", 286 "graphic_2d:librender_service_base", 287 "graphic_surface:surface", 288 "hilog:libhilog", 289 "hisysevent:libhisysevent", 290 "i18n:intl_util", 291 "ipc:ipc_single", 292 "media_foundation:media_foundation", 293 "os_account:os_account_innerkits", 294 "player_framework:media_client", 295 "qos_manager:qos", 296 "resource_management:global_resmgr", 297 "state_registry:tel_state_registry_api", 298 "window_manager:libdm", 299 ] 300 301 if (player_framework_support_power_manager) { 302 external_deps += [ "power_manager:powermgr_client" ] 303 } 304 305 if (player_framework_support_drm) { 306 external_deps += [ "drm_framework:drm_framework" ] 307 } 308 309 resource_config_file = "../resources/ohos_test.xml" 310} 311