1# Copyright (c) 2021 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("//base/notification/common_event_service/event.gni")
15import("//build/test.gni")
16
17module_output_path = "common_event_service/tools"
18
19config("tools_cem_config_mock") {
20  include_dirs = [
21    "//third_party/googletest/googlemock/include",
22    "${tools_path}/test/mock",
23  ]
24}
25
26tools_cem_mock_sources = [
27  "${tools_path}/test/mock/mock_common_event_stub.cpp",
28  "${tools_path}/test/mock/mock_service_registry.cpp",
29]
30
31ohos_unittest("common_event_command_test") {
32  module_out_path = module_output_path
33
34  include_dirs = []
35
36  sources = [
37    "${tools_path}/cem/src/common_event_command.cpp",
38    "${tools_path}/cem/src/shell_command.cpp",
39    "common_event_command_test.cpp",
40  ]
41
42  configs = [ "${tools_path}/cem:tools_cem_config" ]
43
44  cflags = []
45  if (target_cpu == "arm") {
46    cflags += [ "-DBINDER_IPC_32BIT" ]
47  }
48
49  deps = [
50    "${ces_core_path}:cesfwk_core",
51    "${ces_native_path}:cesfwk_innerkits",
52    "//third_party/googletest:gmock_main",
53    "//third_party/googletest:gtest_main",
54  ]
55
56  external_deps = [
57    "ability_base:want",
58    "c_utils:utils",
59    "eventhandler:libeventhandler",
60    "hilog:libhilog",
61    "ipc:ipc_core",
62  ]
63}
64
65ohos_unittest("common_event_command_dump_test") {
66  module_out_path = module_output_path
67
68  include_dirs = []
69
70  sources = [
71    "${tools_path}/cem/src/common_event_command.cpp",
72    "${tools_path}/cem/src/shell_command.cpp",
73    "common_event_command_dump_test.cpp",
74  ]
75  sources += tools_cem_mock_sources
76
77  configs = [
78    "${tools_path}/cem:tools_cem_config",
79    ":tools_cem_config_mock",
80  ]
81
82  cflags = []
83  if (target_cpu == "arm") {
84    cflags += [ "-DBINDER_IPC_32BIT" ]
85  }
86
87  deps = [
88    "${ces_core_path}:cesfwk_core",
89    "${ces_native_path}:cesfwk_innerkits",
90    "//third_party/googletest:gmock_main",
91    "//third_party/googletest:gtest_main",
92  ]
93
94  external_deps = [
95    "ability_base:want",
96    "c_utils:utils",
97    "eventhandler:libeventhandler",
98    "hilog:libhilog",
99    "init:libbegetutil",
100    "ipc:ipc_core",
101    "samgr:samgr_proxy",
102  ]
103}
104
105ohos_unittest("common_event_command_publish_test") {
106  module_out_path = module_output_path
107
108  include_dirs = []
109
110  sources = [
111    "${tools_path}/cem/src/common_event_command.cpp",
112    "${tools_path}/cem/src/shell_command.cpp",
113    "common_event_command_publish_test.cpp",
114  ]
115  sources += tools_cem_mock_sources
116
117  configs = [
118    "${tools_path}/cem:tools_cem_config",
119    ":tools_cem_config_mock",
120  ]
121
122  cflags = []
123  if (target_cpu == "arm") {
124    cflags += [ "-DBINDER_IPC_32BIT" ]
125  }
126
127  deps = [
128    "${ces_core_path}:cesfwk_core",
129    "${ces_native_path}:cesfwk_innerkits",
130    "//third_party/googletest:gmock_main",
131    "//third_party/googletest:gtest_main",
132  ]
133
134  external_deps = [
135    "ability_base:want",
136    "c_utils:utils",
137    "eventhandler:libeventhandler",
138    "hilog:libhilog",
139    "init:libbegetutil",
140    "ipc:ipc_core",
141    "samgr:samgr_proxy",
142  ]
143}
144
145group("unittest") {
146  testonly = true
147
148  deps = [
149    ":common_event_command_dump_test",
150    ":common_event_command_publish_test",
151    ":common_event_command_test",
152  ]
153}
154