1# Copyright (c) 2024 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/graphic/graphic_2d/graphic_config.gni")
16
17module_output_path = "graphic/rosen_engine/render_service/drawable"
18
19group("unittest") {
20  testonly = true
21
22  deps = [ ":RSCanvasDrawingNodeDrawableTest" ]
23}
24
25###############################################################################
26config("drawable_test") {
27  include_dirs = [ "$graphic_2d_root/rosen/modules/render_service/core" ]
28}
29
30## Build RSCanvasDrawingNodeDrawableTest
31ohos_unittest("RSCanvasDrawingNodeDrawableTest") {
32  module_out_path = module_output_path
33  sources = [ "rs_canvas_drawing_node_drawable_test.cpp" ]
34  deps = [ ":rs_test_common" ]
35  external_deps = [
36    "c_utils:utils",
37    "hilog:libhilog",
38  ]
39  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
40    external_deps += [ "sensor:sensor_interface_native" ]
41  }
42}
43
44## Build RSDisplayNodeDrawableTest
45ohos_unittest("RSDisplayNodeDrawableTest") {
46  module_out_path = module_output_path
47  sources = [ "rs_display_node_drawable_test.cpp" ]
48  deps = [ ":rs_test_common" ]
49  external_deps = [
50    "c_utils:utils",
51    "hilog:libhilog",
52  ]
53  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
54    external_deps += [ "sensor:sensor_interface_native" ]
55  }
56}
57
58## Build RSNodeDrawableAdapter1Test
59ohos_unittest("RSNodeDrawableAdapter1Test") {
60  module_out_path = module_output_path
61  sources = [ "rs_node_drawable_adapter1_test.cpp" ]
62  deps = [ ":rs_test_common" ]
63  external_deps = [
64    "c_utils:utils",
65    "hilog:libhilog",
66  ]
67  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
68    external_deps += [ "sensor:sensor_interface_native" ]
69  }
70}
71
72## Build RSNodeDrawable1Test
73ohos_unittest("RSNodeDrawable1Test") {
74  module_out_path = module_output_path
75  sources = [ "rs_node_drawable1_test.cpp" ]
76  deps = [ ":rs_test_common" ]
77  external_deps = [
78    "c_utils:utils",
79    "hilog:libhilog",
80  ]
81}
82
83## Build RSDmaBufferSurfaceNodeDrawableTest
84ohos_unittest("RSDmaBufferSurfaceNodeDrawableTest") {
85  module_out_path = module_output_path
86  sources = [ "rs_dma_buffer_surface_node_drawable_test.cpp" ]
87  deps = [ ":rs_test_common" ]
88  external_deps = [
89    "c_utils:utils",
90    "hilog:libhilog",
91  ]
92  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
93    external_deps += [ "sensor:sensor_interface_native" ]
94  }
95}
96
97## Build RSCanvasNodeDrawableTest
98ohos_unittest("RSCanvasNodeDrawableTest") {
99  module_out_path = module_output_path
100  sources = [
101    "$graphic_2d_root/rosen/modules/render_service_base/src/pipeline/rs_canvas_render_node.cpp",
102    "rs_canvas_node_drawable_test.cpp",
103  ]
104  deps = [ ":rs_test_common" ]
105  external_deps = [
106    "c_utils:utils",
107    "hilog:libhilog",
108  ]
109}
110
111## Build rs_test_common.a {{{
112config("rs_test_common_public_config") {
113  include_dirs = [
114    "$graphic_2d_root/rosen/include",
115    "$graphic_2d_root/rosen/modules/hyper_graphic_manager/core/frame_rate_manager",
116    "$graphic_2d_root/rosen/modules/render_service/core",
117    "$graphic_2d_root/rosen/modules/render_service_client/core",
118    "$graphic_2d_root/rosen/modules/render_service_base/src",
119    "$graphic_2d_root/rosen/test/include",
120    "$memmgr_plugin_root/interface/innerkits/include",
121    "$memmgr_plugin_root/services/memmgrservice/include/memory_level_manager",
122    "$memmgr_root/interface/innerkits/include",
123    "$memmgr_root/services/memmgrservice/include/memory_level_manager",
124  ]
125
126  cflags = [
127    "-Wall",
128    "-Werror",
129    "-g3",
130    "-Dprivate=public",
131    "-Dprotected=public",
132  ]
133}
134
135## Build RSRenderAutoCacheTest
136ohos_unittest("RSRenderAutoCacheTest") {
137  module_out_path = module_output_path
138  sources = [ "rs_render_autocache_test.cpp" ]
139  deps = [ ":rs_test_common" ]
140  external_deps = [
141    "c_utils:utils",
142    "hilog:libhilog",
143  ]
144  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
145    external_deps += [ "sensor:sensor_interface_native" ]
146  }
147}
148
149## Build RSUIFirstRenderDrawableTest
150ohos_unittest("RSUIFirstRenderDrawableTest") {
151  module_out_path = module_output_path
152  sources = [ "rs_ui_first_render_drawable_test.cpp" ]
153  deps = [ ":rs_test_common" ]
154  external_deps = [
155    "c_utils:utils",
156    "hilog:libhilog",
157  ]
158  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
159    external_deps += [ "sensor:sensor_interface_native" ]
160  }
161}
162
163## Build RSRenderDrawableTest
164ohos_unittest("RSRenderDrawableTest") {
165  module_out_path = module_output_path
166  sources = [ "rs_render_drawable_test.cpp" ]
167  deps = [ ":rs_test_common" ]
168  external_deps = [
169    "c_utils:utils",
170    "hilog:libhilog",
171  ]
172  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
173    external_deps += [ "sensor:sensor_interface_native" ]
174  }
175}
176
177ohos_static_library("rs_test_common") {
178  visibility = [ ":*" ]
179  testonly = true
180  defines = []
181  defines += gpu_defines
182  sources = [ "../pipeline/rs_test_util.cpp" ]
183  public_configs = [ ":rs_test_common_public_config" ]
184
185  public_deps = [
186    "$graphic_2d_root/rosen/modules/composer:libcomposer",
187    "$graphic_2d_root/rosen/modules/render_service:librender_service",
188    "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base",
189    "$graphic_2d_root/rosen/modules/render_service_client:librender_service_client",
190    "//third_party/googletest:gmock_main",
191    "//third_party/googletest:gtest_main",
192  ]
193
194  if (defined(use_rosen_drawing) && use_rosen_drawing) {
195    public_deps += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ]
196    defines += [ "USE_ROSEN_DRAWING" ]
197  }
198
199  external_deps = []
200
201  public_external_deps = [
202    "c_utils:utils",
203    "hilog:libhilog",
204    "init:libbegetutil",
205    "ipc:ipc_core",
206  ]
207  if (defined(global_parts_info) && defined(global_parts_info.sensors_sensor)) {
208    external_deps += [ "sensor:sensor_interface_native" ]
209  }
210
211  subsystem_name = "graphic"
212  part_name = "graphic_2d"
213}
214