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/components" 19event_test_output_path = "ace_engine/events" 20base_test_output_path = "ace_engine/base" 21image_test_output_path = "ace_engine/image" 22basic_test_output_path = "ace_engine/basic" 23interface_test_output_path = "ace_engine/interfaces" 24svg_test_output_path = "ace_engine/svg" 25 26template("ace_unittest") { 27 forward_variables_from(invoker, "*") 28 29 type = "components" 30 module_output = "components" 31 flutter_skia = false 32 render = false 33 ace_unittest_name = target_name 34 ace_unittest_config = [ "$ace_root/test/unittest:ace_unittest_config" ] 35 ace_external_deps = [] 36 flutter_sources = [] 37 flutter_external_deps = [] 38 ace_unittest_deps = [ "//third_party/googletest:gmock" ] 39 40 # temporary support 41 if (defined(invoker.external_deps)) { 42 ace_external_deps += external_deps 43 } 44 45 if (defined(invoker.render)) { 46 render = invoker.render 47 } 48 49 if (defined(invoker.type)) { 50 type = invoker.type 51 } 52 53 if (defined(invoker.module_output)) { 54 module_output = invoker.module_output 55 } 56 57 if (defined(invoker.flutter_skia)) { 58 flutter_skia = invoker.flutter_skia 59 } 60 61 if (defined(invoker.extra_deps)) { 62 ace_unittest_deps += invoker.extra_deps 63 } 64 65 # ---------------------------- temporary support 66 if (render) { 67 ace_unittest_deps += [ 68 "$graphic_2d_path/rosen/modules/render_service_base:librender_service_base", 69 "$graphic_2d_path/rosen/modules/render_service_client:librender_service_client", 70 ] 71 if (enable_graphic_text_gine) { 72 ace_external_deps += [ "graphic_2d:rosen_text" ] 73 } 74 } 75 76 if (flutter_skia) { 77 ace_unittest_deps += [ "$skia_root_new:skia_ohos" ] 78 flutter_external_deps = [ "eventhandler:libeventhandler" ] 79 } 80 81 # ---------------------------- 82 83 if (type == "components") { 84 ohos_unittest(ace_unittest_name) { 85 module_out_path = "ace_engine/${module_output}" 86 87 sources = [] 88 sources += invoker.sources 89 sources += flutter_sources 90 91 deps = ace_unittest_deps 92 deps += [ 93 "$ace_root/frameworks/core/components/theme:build_theme_code", 94 "$ace_root/test/unittest:ace_base", 95 "$ace_root/test/unittest:ace_components_base", 96 "$ace_root/test/unittest:ace_components_event", 97 "$ace_root/test/unittest:ace_components_gestures", 98 "$ace_root/test/unittest:ace_components_layout", 99 "$ace_root/test/unittest:ace_components_mock", 100 "$ace_root/test/unittest:ace_components_property", 101 "$ace_root/test/unittest:ace_components_render", 102 "$ace_root/test/unittest:ace_components_syntax", 103 "$ace_root/test/unittest:ace_core_animation", 104 "$ace_root/test/unittest:ace_core_extra", 105 ] 106 107 configs = [] 108 configs += ace_unittest_config 109 110 external_deps = [] 111 external_deps += ace_external_deps 112 external_deps += flutter_external_deps 113 } 114 } else if (type == "new") { 115 ohos_unittest(ace_unittest_name) { 116 module_out_path = "ace_engine/${module_output}" 117 sources = [] 118 sources += invoker.sources 119 sources += flutter_sources 120 121 deps = ace_unittest_deps 122 deps += [ 123 "$ace_root/frameworks/core/components/theme:build_theme_code", 124 "$ace_root/test/unittest:ace_base", 125 "$ace_root/test/unittest:ace_components_base", 126 "$ace_root/test/unittest:ace_components_event", 127 "$ace_root/test/unittest:ace_components_gestures", 128 "$ace_root/test/unittest:ace_components_layout", 129 "$ace_root/test/unittest:ace_components_manager", 130 "$ace_root/test/unittest:ace_components_mock", 131 "$ace_root/test/unittest:ace_components_pattern", 132 "$ace_root/test/unittest:ace_components_property", 133 "$ace_root/test/unittest:ace_components_render", 134 "$ace_root/test/unittest:ace_components_syntax", 135 "$ace_root/test/unittest:ace_core_animation", 136 "$ace_root/test/unittest:ace_core_extra", 137 ] 138 cflags = [ "-fvisibility=hidden" ] 139 configs = [] 140 configs = ace_unittest_config 141 142 external_deps = [] 143 external_deps += ace_external_deps 144 external_deps += flutter_external_deps 145 } 146 } else if (type == "pipeline") { 147 ohos_unittest(ace_unittest_name) { 148 module_out_path = "ace_engine/${module_output}" 149 sources = [] 150 sources += invoker.sources 151 sources += flutter_sources 152 153 deps = ace_unittest_deps 154 deps += [ 155 "$ace_root/frameworks/core/components/theme:build_theme_code", 156 "$ace_root/test/unittest:ace_base", 157 "$ace_root/test/unittest:ace_components_base", 158 "$ace_root/test/unittest:ace_components_event", 159 "$ace_root/test/unittest:ace_components_gestures", 160 "$ace_root/test/unittest:ace_components_layout", 161 "$ace_root/test/unittest:ace_components_manager", 162 "$ace_root/test/unittest:ace_components_pattern", 163 "$ace_root/test/unittest:ace_components_property", 164 "$ace_root/test/unittest:ace_components_render", 165 "$ace_root/test/unittest:ace_components_syntax", 166 "$ace_root/test/unittest:ace_core_animation", 167 "$ace_root/test/unittest:ace_core_extra", 168 ] 169 170 configs = [] 171 configs = ace_unittest_config 172 173 external_deps = [] 174 external_deps += ace_external_deps 175 external_deps += flutter_external_deps 176 } 177 } else { 178 assert(false) 179 } 180} 181