1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "dm_radar_helper_test.h"
17
18 #include "dm_radar_helper.h"
19
20 namespace OHOS {
21 namespace DistributedHardware {
SetUp()22 void DmRadarHelperTest::SetUp()
23 {
24 }
25
TearDown()26 void DmRadarHelperTest::TearDown()
27 {
28 }
29
SetUpTestCase()30 void DmRadarHelperTest::SetUpTestCase()
31 {
32 }
33
TearDownTestCase()34 void DmRadarHelperTest::TearDownTestCase()
35 {
36 }
37
38 HWTEST_F(DmRadarHelperTest, ReportDiscoverRegCallback_001, testing::ext::TestSize.Level0)
39 {
40 struct RadarInfo info = { 0 };
41 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
42 bool res = DmRadarHelper::GetInstance().ReportDiscoverRegCallback(info);
43 EXPECT_EQ(res, true);
44 }
45
46 HWTEST_F(DmRadarHelperTest, ReportDiscoverRegCallback_002, testing::ext::TestSize.Level0)
47 {
48 struct RadarInfo info = { 0 };
49 info.stageRes = static_cast<int32_t>(StageRes::STAGE_CANCEL);
50 bool res = DmRadarHelper::GetInstance().ReportDiscoverRegCallback(info);
51 EXPECT_EQ(res, true);
52 }
53
54 HWTEST_F(DmRadarHelperTest, ReportDiscoverResCallback_001, testing::ext::TestSize.Level0)
55 {
56 struct RadarInfo info = { 0 };
57 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
58 bool res = DmRadarHelper::GetInstance().ReportDiscoverResCallback(info);
59 EXPECT_EQ(res, true);
60 }
61
62 HWTEST_F(DmRadarHelperTest, ReportDiscoverUserRes_001, testing::ext::TestSize.Level0)
63 {
64 struct RadarInfo info = { 0 };
65 info.stageRes = static_cast<int32_t>(StageRes::STAGE_CANCEL);
66 bool res = DmRadarHelper::GetInstance().ReportDiscoverUserRes(info);
67 EXPECT_EQ(res, true);
68 }
69 HWTEST_F(DmRadarHelperTest, ReportDiscoverUserRes_002, testing::ext::TestSize.Level0)
70 {
71 struct RadarInfo info = { 0 };
72 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
73 bool res = DmRadarHelper::GetInstance().ReportDiscoverUserRes(info);
74 EXPECT_EQ(res, true);
75 }
76 HWTEST_F(DmRadarHelperTest, ReportAuthStart_001, testing::ext::TestSize.Level0)
77 {
78 bool res = DmRadarHelper::GetInstance().ReportAuthStart("udid", "pkgname");
79 EXPECT_EQ(res, true);
80 }
81 HWTEST_F(DmRadarHelperTest, ReportAuthOpenSession_001, testing::ext::TestSize.Level0)
82 {
83 struct RadarInfo info = { 0 };
84 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
85 bool res = DmRadarHelper::GetInstance().ReportAuthOpenSession(info);
86 EXPECT_EQ(res, true);
87 }
88 HWTEST_F(DmRadarHelperTest, ReportAuthOpenSession_002, testing::ext::TestSize.Level0)
89 {
90 struct RadarInfo info = { 0 };
91 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
92 bool res = DmRadarHelper::GetInstance().ReportAuthOpenSession(info);
93 EXPECT_EQ(res, true);
94 }
95 HWTEST_F(DmRadarHelperTest, ReportAuthSessionOpenCb_001, testing::ext::TestSize.Level0)
96 {
97 struct RadarInfo info = { 0 };
98 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
99 bool res = DmRadarHelper::GetInstance().ReportAuthSessionOpenCb(info);
100 EXPECT_EQ(res, true);
101 }
102 HWTEST_F(DmRadarHelperTest, ReportAuthSendRequest_001, testing::ext::TestSize.Level0)
103 {
104 struct RadarInfo info = { 0 };
105 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
106 bool res = DmRadarHelper::GetInstance().ReportAuthSendRequest(info);
107 EXPECT_EQ(res, true);
108 }
109 HWTEST_F(DmRadarHelperTest, ReportAuthPullAuthBox_001, testing::ext::TestSize.Level0)
110 {
111 struct RadarInfo info = { 0 };
112 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
113 bool res = DmRadarHelper::GetInstance().ReportAuthPullAuthBox(info);
114 EXPECT_EQ(res, true);
115 }
116 HWTEST_F(DmRadarHelperTest, ReportAuthConfirmBox_001, testing::ext::TestSize.Level0)
117 {
118 struct RadarInfo info = { 0 };
119 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
120 bool res = DmRadarHelper::GetInstance().ReportAuthConfirmBox(info);
121 EXPECT_EQ(res, true);
122 }
123 HWTEST_F(DmRadarHelperTest, ReportAuthConfirmBox_002, testing::ext::TestSize.Level0)
124 {
125 struct RadarInfo info = { 0 };
126 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
127 bool res = DmRadarHelper::GetInstance().ReportAuthConfirmBox(info);
128 EXPECT_EQ(res, true);
129 }
130 HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroup_001, testing::ext::TestSize.Level0)
131 {
132 struct RadarInfo info = { 0 };
133 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
134 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroup(info);
135 EXPECT_EQ(res, true);
136 }
137 HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroup_002, testing::ext::TestSize.Level0)
138 {
139 struct RadarInfo info = { 0 };
140 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
141 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroup(info);
142 EXPECT_EQ(res, true);
143 }
144 HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroupCb_001, testing::ext::TestSize.Level0)
145 {
146 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
147 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroupCb("funcName", stageRes);
148 EXPECT_EQ(res, true);
149 }
150 HWTEST_F(DmRadarHelperTest, ReportAuthCreateGroupCb_002, testing::ext::TestSize.Level0)
151 {
152 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
153 bool res = DmRadarHelper::GetInstance().ReportAuthCreateGroupCb("funcName", stageRes);
154 EXPECT_EQ(res, true);
155 }
156 HWTEST_F(DmRadarHelperTest, ReportAuthPullPinBox_001, testing::ext::TestSize.Level0)
157 {
158 struct RadarInfo info = { 0 };
159 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
160 bool res = DmRadarHelper::GetInstance().ReportAuthPullPinBox(info);
161 EXPECT_EQ(res, true);
162 }
163 HWTEST_F(DmRadarHelperTest, ReportAuthInputPinBox_001, testing::ext::TestSize.Level0)
164 {
165 struct RadarInfo info = { 0 };
166 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
167 bool res = DmRadarHelper::GetInstance().ReportAuthInputPinBox(info);
168 EXPECT_EQ(res, true);
169 }
170 HWTEST_F(DmRadarHelperTest, ReportAuthInputPinBox_002, testing::ext::TestSize.Level0)
171 {
172 struct RadarInfo info = { 0 };
173 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
174 bool res = DmRadarHelper::GetInstance().ReportAuthInputPinBox(info);
175 EXPECT_EQ(res, true);
176 }
177 HWTEST_F(DmRadarHelperTest, ReportAuthAddGroup_001, testing::ext::TestSize.Level0)
178 {
179 struct RadarInfo info = { 0 };
180 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
181 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroup(info);
182 EXPECT_EQ(res, true);
183 }
184 HWTEST_F(DmRadarHelperTest, ReportAuthAddGroup_002, testing::ext::TestSize.Level0)
185 {
186 struct RadarInfo info = { 0 };
187 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
188 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroup(info);
189 EXPECT_EQ(res, true);
190 }
191 HWTEST_F(DmRadarHelperTest, ReportAuthAddGroupCb_001, testing::ext::TestSize.Level0)
192 {
193 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
194 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroupCb("func", stageRes);
195 EXPECT_EQ(res, true);
196 }
197 HWTEST_F(DmRadarHelperTest, ReportAuthAddGroupCb_002, testing::ext::TestSize.Level0)
198 {
199 struct RadarInfo info = { 0 };
200 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
201 bool res = DmRadarHelper::GetInstance().ReportAuthAddGroupCb("func", stageRes);
202 EXPECT_EQ(res, true);
203 }
204 HWTEST_F(DmRadarHelperTest, ReportNetworkOnline_001, testing::ext::TestSize.Level0)
205 {
206 struct RadarInfo info = { 0 };
207 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
208 bool res = DmRadarHelper::GetInstance().ReportNetworkOnline(info);
209 EXPECT_EQ(res, true);
210 }
211 HWTEST_F(DmRadarHelperTest, ReportNetworkOffline_001, testing::ext::TestSize.Level0)
212 {
213 struct RadarInfo info = { 0 };
214 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
215 bool res = DmRadarHelper::GetInstance().ReportNetworkOffline(info);
216 EXPECT_EQ(res, true);
217 }
218 HWTEST_F(DmRadarHelperTest, ReportDeleteTrustRelation_001, testing::ext::TestSize.Level0)
219 {
220 struct RadarInfo info = { 0 };
221 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
222 bool res = DmRadarHelper::GetInstance().ReportDeleteTrustRelation(info);
223 EXPECT_EQ(res, true);
224 }
225 HWTEST_F(DmRadarHelperTest, ReportGetTrustDeviceList_001, testing::ext::TestSize.Level0)
226 {
227 struct RadarInfo info = { 0 };
228 info.stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
229 bool res = DmRadarHelper::GetInstance().ReportGetTrustDeviceList(info);
230
231 int32_t stageRes = static_cast<int32_t>(StageRes::STAGE_SUCC);
232 std::string str = "test";
233 DmRadarHelper::GetInstance().ReportCreatePinHolder(str, 0, str, 0, stageRes);
234 DmRadarHelper::GetInstance().ReportDestroyPinHolder(str, str, 0, stageRes);
235
236 stageRes = static_cast<int32_t>(StageRes::STAGE_FAIL);
237 DmRadarHelper::GetInstance().ReportCreatePinHolder(str, 0, str, 0, stageRes);
238 DmRadarHelper::GetInstance().ReportDestroyPinHolder(str, str, 0, stageRes);
239
240 int32_t bizStage = static_cast<int32_t>(PinHolderStage::RECEIVE_DESTROY_PIN_HOLDER_MSG);
241 DmRadarHelper::GetInstance().ReportSendOrReceiveHolderMsg(bizStage, str, "");
242
243 bizStage = static_cast<int32_t>(PinHolderStage::RECEIVE_CREATE_PIN_HOLDER_MSG);
244 DmRadarHelper::GetInstance().ReportSendOrReceiveHolderMsg(bizStage, str, "");
245 EXPECT_EQ(res, true);
246 }
247 HWTEST_F(DmRadarHelperTest, ReportGetTrustDeviceList_002, testing::ext::TestSize.Level0)
248 {
249 struct RadarInfo info = { 0 };
250 info.stageRes = static_cast<int32_t>(StageRes::STAGE_IDLE);
251 bool res = DmRadarHelper::GetInstance().ReportGetTrustDeviceList(info);
252 EXPECT_EQ(res, true);
253 }
254 } // namespace DistributedHardware
255 } // namespace OHOS
256