• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-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/test.gni")
15import("../../../displaymgr.gni")
16
17module_output_path = "display_manager/display_manager"
18
19###############################################################################
20config("module_private_config") {
21  visibility = [ ":*" ]
22
23  include_dirs = [
24    "include",
25    "include/mock",
26    "mock/include",
27    "${displaymgr_inner_api}/native/include",
28    "${displaymgr_root_path}/utils/native/include",
29    "${displaymgr_service_zidl}/include",
30    "${displaymgr_utils_path}/native/include",
31  ]
32}
33
34deps_ex = [
35  "ability_base:want",
36  "ability_base:zuri",
37  "ability_runtime:ability_manager",
38  "c_utils:utils",
39  "hilog:libhilog",
40  "hisysevent:libhisysevent",
41  "ipc:ipc_core",
42  "power_manager:powermgr_client",
43  "power_manager:power_setting",
44  "safwk:system_ability_fwk",
45  "samgr:samgr_proxy",
46]
47
48##############################unittest##########################################
49ohos_unittest("unittest_display_mgr_service") {
50  module_out_path = module_output_path
51
52  defines += [ "GTEST" ]
53  sanitize = {
54    cfi = true
55    cfi_cross_dso = true
56    debug = false
57  }
58
59  sources = [
60    "mock/src/mock_display_power_mgr_proxy.cpp",
61    "mock/src/mock_display_remote_object.cpp",
62    "src/display_power_mgr_brightness_test.cpp",
63    "src/display_power_mgr_service_test.cpp",
64    "${displaymgr_root_path}/utils/native/src/display_xcollie.cpp",
65  ]
66
67  configs = [
68    "${displaymgr_utils_path}:utils_config",
69    ":module_private_config",
70    "${displaymgr_utils_path}:coverage_flags",
71    "${displaymgr_root_path}/service:displaymgr_public_config",
72  ]
73
74  deps = [
75    "${displaymgr_inner_api}:displaymgr",
76    "${displaymgr_root_path}/service:displaymgr_proxy",
77    "${displaymgr_root_path}/service:displaymgr_stub",
78  ]
79
80  external_deps = [
81    "ability_base:want",
82    "ability_base:zuri",
83    "ability_runtime:ability_manager",
84    "cJSON:cjson",
85    "c_utils:utils",
86    "data_share:datashare_consumer",
87    "googletest:gtest_main",
88    "hicollie:libhicollie",
89    "hilog:libhilog",
90    "ipc:ipc_core",
91    "power_manager:power_setting",
92    "power_manager:powermgr_client",
93    "safwk:system_ability_fwk",
94    "samgr:samgr_proxy",
95  ]
96}
97
98############################display_service_death_test#############################
99ohos_unittest("display_service_death_test") {
100  module_out_path = module_output_path
101
102  sanitize = {
103    cfi = true
104    cfi_cross_dso = true
105    debug = false
106  }
107
108  sources = [ "src/display_service_death_test.cpp" ]
109
110  configs = [
111    "${displaymgr_utils_path}:utils_config",
112    ":module_private_config",
113    "${displaymgr_utils_path}:coverage_flags",
114    "${displaymgr_root_path}/service:displaymgr_public_config",
115  ]
116
117  defines += [ "DISPLAY_SERVICE_DEATH_UT" ]
118
119  deps = [
120    "${displaymgr_inner_api}:displaymgr",
121    "${displaymgr_root_path}/service:displaymgr_proxy",
122    "${displaymgr_root_path}/service:displaymgr_stub",
123  ]
124
125  external_deps = [ "googletest:gtest_main" ]
126  external_deps += deps_ex
127}
128
129############################display_mock_parcel_test#############################
130ohos_unittest("display_mock_parcel_test") {
131  module_out_path = module_output_path
132
133  sanitize = {
134    cfi = true
135    cfi_cross_dso = true
136    debug = false
137  }
138
139  sources = [
140    "mock/src/mock_message_parcel.cpp",
141    "mock/src/mock_parcel.cpp",
142    "src/mock/display_mock_parcel_test.cpp",
143  ]
144
145  configs = [
146    "${displaymgr_utils_path}:utils_config",
147    ":module_private_config",
148    "${displaymgr_utils_path}:coverage_flags",
149    "${displaymgr_root_path}/service:displaymgr_public_config",
150  ]
151
152  deps = [
153    "${displaymgr_inner_api}:displaymgr",
154    "${displaymgr_root_path}/service:displaymgr_proxy",
155  ]
156  external_deps = [ "googletest:gtest_main" ]
157  external_deps += deps_ex
158}
159
160############################display_mock_test#############################
161ohos_unittest("display_mock_test") {
162  module_out_path = module_output_path
163
164  sanitize = {
165    cfi = true
166    cfi_cross_dso = true
167    debug = false
168  }
169
170  sources = [
171    "mock/src/mock_display_remote_object.cpp",
172    "mock/src/mock_message_parcel.cpp",
173    "mock/src/mock_parcel.cpp",
174    "src/mock/display_mock_test.cpp",
175  ]
176
177  configs = [
178    "${displaymgr_utils_path}:utils_config",
179    ":module_private_config",
180    "${displaymgr_utils_path}:coverage_flags",
181    "${displaymgr_root_path}/service:displaymgr_public_config",
182  ]
183
184  defines += [
185    "MOCK_READSTRING_DESCRIPTIR",
186    "MOCK_WRITE_INTERFACE_TOKEN_RETURN_TRUE",
187  ]
188
189  deps = [
190    "${displaymgr_inner_api}:displaymgr",
191    "${displaymgr_root_path}/service:displaymgr_proxy",
192  ]
193
194  external_deps = [ "googletest:gtest_main" ]
195  external_deps += deps_ex
196}
197
198############################display_mock_object_test#############################
199ohos_unittest("display_mock_object_test") {
200  module_out_path = module_output_path
201
202  sanitize = {
203    cfi = true
204    cfi_cross_dso = true
205    debug = false
206  }
207
208  sources = [
209    "mock/src/mock_display_remote_object.cpp",
210    "src/mock/display_mock_object_test.cpp",
211  ]
212
213  configs = [
214    "${displaymgr_utils_path}:utils_config",
215    ":module_private_config",
216    "${displaymgr_utils_path}:coverage_flags",
217    "${displaymgr_root_path}/service:displaymgr_public_config",
218  ]
219
220  deps = [
221    "${displaymgr_inner_api}:displaymgr",
222    "${displaymgr_root_path}/service:displaymgr_proxy",
223  ]
224
225  external_deps = [ "googletest:gtest_main" ]
226  external_deps += deps_ex
227}
228
229############################unittest_display_service_test#############################
230ohos_unittest("unittest_display_service_test") {
231  module_out_path = module_output_path
232
233  cflags = [
234    "-Dprivate=public",
235    "-Dprotected=public",
236  ]
237
238  sanitize = {
239    cfi = true
240    cfi_cross_dso = true
241    debug = false
242  }
243
244  sources = [
245    "src/display_service_test.cpp",
246    "${displaymgr_utils_path}/native/src/display_xcollie.cpp",
247    "${displaymgr_root_path}/service/native/src/display_auto_brightness.cpp",
248    "${displaymgr_root_path}/service/native/src/display_common_event_mgr.cpp",
249    "${displaymgr_root_path}/service/native/src/display_param_helper.cpp",
250    "${displaymgr_root_path}/service/native/src/display_power_mgr_service.cpp",
251    "${displaymgr_root_path}/service/native/src/display_setting_helper.cpp",
252    "${displaymgr_root_path}/service/native/src/display_system_ability.cpp",
253    "${displaymgr_root_path}/service/native/src/gradual_animator.cpp",
254    "${displaymgr_root_path}/service/native/src/screen_action.cpp",
255    "${displaymgr_root_path}/service/native/src/screen_controller.cpp",
256    "${displaymgr_root_path}/service/zidl/src/display_brightness_callback_proxy.cpp",
257    "${displaymgr_root_path}/service/zidl/src/display_power_callback_proxy.cpp",
258  ]
259
260  configs = [
261    "${displaymgr_utils_path}:utils_config",
262    ":module_private_config",
263    "${displaymgr_utils_path}:coverage_flags",
264    "${displaymgr_root_path}/service:displaymgr_private_config",
265    "${displaymgr_root_path}/service:displaymgr_public_config",
266  ]
267
268  deps = [
269    "${brightnessmgr_root_path}:brightness_manager",
270    "${displaymgr_inner_api}:displaymgr",
271    "${displaymgr_root_path}/service:displaymgrservice",
272    "${displaymgr_root_path}/service:displaymgr_stub",
273  ]
274
275  external_deps = [ "power_manager:power_permission" ]
276
277  external_deps += [
278    "ability_base:zuri",
279    "ability_runtime:ability_manager",
280    "cJSON:cjson",
281    "c_utils:utils",
282    "data_share:datashare_consumer",
283    "eventhandler:libeventhandler",
284    "ffrt:libffrt",
285    "googletest:gtest_main",
286    "graphic_2d:librender_service_base",
287    "hicollie:libhicollie",
288    "hilog:libhilog",
289    "image_framework:image_native",
290    "ipc:ipc_core",
291    "power_manager:power_ffrt",
292    "power_manager:power_setting",
293    "power_manager:power_sysparam",
294    "power_manager:powermgr_client",
295    "safwk:system_ability_fwk",
296    "samgr:samgr_proxy",
297    "skia:skia_canvaskit",
298    "window_manager:libdm_lite",
299  ]
300  external_deps += deps_ex
301
302  if (has_sensors_sensor_part) {
303    external_deps += [ "sensor:sensor_interface_native" ]
304    defines += [ "ENABLE_SENSOR_PART" ]
305  }
306  if (has_hiviewdfx_hisysevent_part) {
307    external_deps += [ "hisysevent:libhisysevent" ]
308  }
309}
310
311group("unittest") {
312  testonly = true
313  deps = [
314    ":display_mock_object_test",
315    ":display_mock_parcel_test",
316    ":display_mock_test",
317    ":display_service_death_test",
318    ":unittest_display_service_test",
319  ]
320}
321