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/ohos.gni") 15import("//build/test.gni") 16import("//foundation/arkui/ace_engine/ace_config.gni") 17 18pattern_test_output_path = "ace_engine/ace_engine/components" 19event_test_output_path = "ace_engine/ace_engine/events" 20base_test_output_path = "ace_engine/ace_engine/base" 21image_test_output_path = "ace_engine/Component-Image" 22basic_test_output_path = "ace_engine/ace_engine/basic" 23interface_test_output_path = "ace_engine/ace_engine/interfaces" 24adapter_test_output_path = "ace_engine/ace_engine/adapter" 25svg_test_output_path = "ace_engine/ace_engine/svg" 26bridge_test_output_path = "ace_engine/ace_engine/bridge" 27frameworks_test_output_path = "ace_engine/ace_engine/frameworks" 28 29template("ace_unittest") { 30 forward_variables_from(invoker, "*") 31 32 type = "components" 33 module_output = "components" 34 module_name = "ace_engine" 35 flutter_skia = false 36 render = false 37 ace_unittest_name = target_name 38 ace_unittest_config = [ "$ace_root/test/unittest:ace_unittest_config" ] 39 ace_external_deps = [ "googletest:gmock" ] 40 flutter_sources = [] 41 flutter_external_deps = [] 42 ace_unittest_deps = [] 43 include_dir = [] 44 45 # temporary support 46 if (defined(invoker.external_deps)) { 47 ace_external_deps += external_deps 48 } 49 50 if (defined(invoker.render)) { 51 render = invoker.render 52 } 53 54 if (defined(invoker.type)) { 55 type = invoker.type 56 } 57 58 if (defined(invoker.module_output)) { 59 module_output = invoker.module_output 60 } 61 62 if (defined(invoker.module_name)) { 63 module_name = invoker.module_name 64 } 65 66 if (defined(invoker.flutter_skia)) { 67 flutter_skia = invoker.flutter_skia 68 } 69 70 if (defined(invoker.extra_deps)) { 71 ace_unittest_deps += invoker.extra_deps 72 } 73 74 if (defined(invoker.include_dirs)) { 75 include_dir = invoker.include_dirs 76 } 77 78 # ---------------------------- temporary support 79 if (render) { 80 ace_external_deps += [ 81 "graphic_2d:librender_service_base", 82 "graphic_2d:librender_service_client", 83 ] 84 } 85 86 if (flutter_skia) { 87 flutter_external_deps = [ "eventhandler:libeventhandler" ] 88 } 89 90 # ---------------------------- 91 92 if (type == "components") { 93 ohos_unittest(ace_unittest_name) { 94 module_out_path = "ace_engine/${module_name}/${module_output}" 95 96 sources = [] 97 sources += invoker.sources 98 sources += flutter_sources 99 100 deps = ace_unittest_deps 101 deps += [ 102 "$ace_root/frameworks/core/components/theme:build_theme_code", 103 "$ace_root/test/unittest:ace_base", 104 "$ace_root/test/unittest:ace_components_base", 105 "$ace_root/test/unittest:ace_components_event", 106 "$ace_root/test/unittest:ace_components_gestures", 107 "$ace_root/test/unittest:ace_components_layout", 108 "$ace_root/test/unittest:ace_components_mock", 109 "$ace_root/test/unittest:ace_components_property", 110 "$ace_root/test/unittest:ace_components_render", 111 "$ace_root/test/unittest:ace_components_syntax", 112 "$ace_root/test/unittest:ace_core_animation", 113 "$ace_root/test/unittest:ace_core_extra", 114 ] 115 116 configs = [] 117 configs += ace_unittest_config 118 119 external_deps = [] 120 external_deps += ace_external_deps 121 external_deps += flutter_external_deps 122 } 123 } else if (type == "new") { 124 ohos_unittest(ace_unittest_name) { 125 module_out_path = "ace_engine/${module_name}/${module_output}" 126 if (ace_unittest_name == "display_sync_manager_test_ng") { 127 module_out_path = "ace_engine/Graphic_2d_LTPO_DisplaySync/${module_output}" 128 } else if (ace_unittest_name == "window_scene_test") { 129 module_out_path = "ace_engine/window_manager/${module_output}" 130 } 131 sources = [] 132 sources += invoker.sources 133 sources += flutter_sources 134 include_dirs = [] 135 include_dirs += include_dir 136 deps = ace_unittest_deps 137 deps += [ 138 "$ace_root/frameworks/core/components/theme:build_theme_code", 139 "$ace_root/test/unittest:ace_base", 140 "$ace_root/test/unittest:ace_components_base", 141 "$ace_root/test/unittest:ace_components_event", 142 "$ace_root/test/unittest:ace_components_gestures", 143 "$ace_root/test/unittest:ace_components_layout", 144 "$ace_root/test/unittest:ace_components_manager", 145 "$ace_root/test/unittest:ace_components_mock", 146 "$ace_root/test/unittest:ace_components_pattern", 147 "$ace_root/test/unittest:ace_components_property", 148 "$ace_root/test/unittest:ace_components_render", 149 "$ace_root/test/unittest:ace_components_syntax", 150 "$ace_root/test/unittest:ace_core_animation", 151 "$ace_root/test/unittest:ace_core_extra", 152 ] 153 if (defined(cflags)) { 154 cflags += [ "-fvisibility=hidden" ] 155 } else { 156 cflags = [ "-fvisibility=hidden" ] 157 } 158 configs = [] 159 configs = ace_unittest_config 160 161 if (defined(invoker.defines)) { 162 defines += invoker.defines 163 } 164 165 external_deps = [] 166 if (current_os == "ohos") { 167 external_deps = [ "c_utils:utils" ] 168 } 169 external_deps += ace_external_deps 170 external_deps += flutter_external_deps 171 } 172 } else if (type == "pipeline") { 173 ohos_unittest(ace_unittest_name) { 174 module_out_path = "ace_engine/${module_name}/${module_output}" 175 sources = [] 176 sources += invoker.sources 177 sources += flutter_sources 178 include_dirs = [] 179 include_dirs += include_dir 180 deps = ace_unittest_deps 181 deps += [ 182 "$ace_root/frameworks/core/components/theme:build_theme_code", 183 "$ace_root/test/unittest:ace_base", 184 "$ace_root/test/unittest:ace_components_base", 185 "$ace_root/test/unittest:ace_components_event", 186 "$ace_root/test/unittest:ace_components_gestures", 187 "$ace_root/test/unittest:ace_components_layout", 188 "$ace_root/test/unittest:ace_components_manager", 189 "$ace_root/test/unittest:ace_components_pattern", 190 "$ace_root/test/unittest:ace_components_property", 191 "$ace_root/test/unittest:ace_components_render", 192 "$ace_root/test/unittest:ace_components_syntax", 193 "$ace_root/test/unittest:ace_core_animation", 194 "$ace_root/test/unittest:ace_core_extra", 195 ] 196 197 configs = [] 198 configs = ace_unittest_config 199 200 external_deps = [] 201 external_deps += ace_external_deps 202 external_deps += flutter_external_deps 203 } 204 } else { 205 assert(false) 206 } 207} 208