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