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