1 /*
2 * Copyright (c) 2024 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 #include <gtest/gtest.h>
16 #include <thread>
17
18 #include "nfc_event_handler.h"
19 #include "nci_native_selector.h"
20
21 namespace OHOS {
22 namespace NFC {
23 namespace TAG {
24 namespace TEST {
25 using namespace testing::ext;
26 using namespace OHOS::NFC;
27 class NfcEventHandlerTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp();
32 void TearDown();
33 };
34
SetUpTestCase()35 void NfcEventHandlerTest::SetUpTestCase()
36 {
37 std::cout << " SetUpTestCase NfcEventHandlerTest." << std::endl;
38 }
39
TearDownTestCase()40 void NfcEventHandlerTest::TearDownTestCase()
41 {
42 std::cout << " TearDownTestCase NfcEventHandlerTest." << std::endl;
43 }
44
SetUp()45 void NfcEventHandlerTest::SetUp()
46 {
47 std::cout << " SetUp NfcEventHandlerTest." << std::endl;
48 }
49
TearDown()50 void NfcEventHandlerTest::TearDown()
51 {
52 std::cout << " TearDown NfcEventHandlerTest." << std::endl;
53 }
54
55 /**
56 * @tc.name: ProcessEvent001
57 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
58 * @tc.type: FUNC
59 */
60 HWTEST_F(NfcEventHandlerTest, ProcessEvent001, TestSize.Level1)
61 {
62 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
63 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
64 std::shared_ptr<TAG::TagDispatcher> tagDispatcher = std::make_shared<TAG::TagDispatcher>(service);
65 std::weak_ptr<CeService> ceService;
66 std::weak_ptr<NfcPollingManager> nfcPollingManager;
67 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
68 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
69 AppExecFwk::InnerEvent::Pointer event =
70 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_TAG_FOUND), 0);
71 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
72 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
73 nfcEventHandler->ProcessEvent(event);
74 }
75
76 /**
77 * @tc.name: ProcessEvent002
78 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
79 * @tc.type: FUNC
80 */
81 HWTEST_F(NfcEventHandlerTest, ProcessEvent002, TestSize.Level1)
82 {
83 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
84 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
85 std::shared_ptr<TAG::TagDispatcher> tagDispatcher = std::make_shared<TAG::TagDispatcher>(service);
86 std::weak_ptr<CeService> ceService;
87 std::weak_ptr<NfcPollingManager> nfcPollingManager;
88 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
89 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
90 AppExecFwk::InnerEvent::Pointer event =
91 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_TAG_DEBOUNCE), 0);
92 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
93 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
94 nfcEventHandler->ProcessEvent(event);
95 }
96
97 /**
98 * @tc.name: ProcessEvent003
99 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
100 * @tc.type: FUNC
101 */
102 HWTEST_F(NfcEventHandlerTest, ProcessEvent003, TestSize.Level1)
103 {
104 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
105 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
106 std::shared_ptr<TAG::TagDispatcher> tagDispatcher = std::make_shared<TAG::TagDispatcher>(service);
107 std::weak_ptr<CeService> ceService;
108 std::weak_ptr<NfcPollingManager> nfcPollingManager;
109 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
110 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
111 AppExecFwk::InnerEvent::Pointer event =
112 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_TAG_LOST), 0);
113 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
114 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
115 nfcEventHandler->ProcessEvent(event);
116 }
117
118 /**
119 * @tc.name: ProcessEvent004
120 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
121 * @tc.type: FUNC
122 */
123 HWTEST_F(NfcEventHandlerTest, ProcessEvent004, TestSize.Level1)
124 {
125 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
126 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
127 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
128 std::weak_ptr<CeService> ceService;
129 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
130 std::weak_ptr<NCI::INciTagInterface> nciTagProxy;
131 std::shared_ptr<NfcPollingManager> nfcPollingManager =
132 std::make_shared<NfcPollingManager>(service, nciNfccProxy, nciTagProxy);
133 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
134 AppExecFwk::InnerEvent::Pointer event =
135 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_SCREEN_CHANGED), 0);
136 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
137 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
138 nfcEventHandler->ProcessEvent(event);
139 }
140
141 /**
142 * @tc.name: ProcessEvent006
143 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
144 * @tc.type: FUNC
145 */
146 HWTEST_F(NfcEventHandlerTest, ProcessEvent006, TestSize.Level1)
147 {
148 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
149 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
150 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
151 std::weak_ptr<CeService> ceService;
152 std::weak_ptr<NfcPollingManager> nfcPollingManager;
153 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
154 AppExecFwk::InnerEvent::Pointer event =
155 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_COMMIT_ROUTING), 0);
156 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
157 std::weak_ptr<NCI::INciCeInterface> nciCeProxy;
158 std::shared_ptr<NfcRoutingManager> nfcRoutingManager =
159 std::make_shared<NfcRoutingManager>(nfcEventHandler, nciNfccProxy, nciCeProxy, service);
160 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
161 nfcEventHandler->ProcessEvent(event);
162 }
163
164 /**
165 * @tc.name: ProcessEvent007
166 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
167 * @tc.type: FUNC
168 */
169 HWTEST_F(NfcEventHandlerTest, ProcessEvent007, TestSize.Level1)
170 {
171 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
172 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
173 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
174 std::weak_ptr<CeService> ceService;
175 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
176 std::weak_ptr<NfcPollingManager> nfcPollingManager;
177 AppExecFwk::InnerEvent::Pointer event =
178 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_COMPUTE_ROUTING_PARAMS), 0);
179 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
180 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
181 std::shared_ptr<NfcRoutingManager> nfcRoutingManager =
182 std::make_shared<NfcRoutingManager>(nfcEventHandler, nciNfccProxy, nciCeProxy, service);
183 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
184 nfcEventHandler->ProcessEvent(event);
185 }
186
187 /**
188 * @tc.name: ProcessEvent008
189 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
190 * @tc.type: FUNC
191 */
192 HWTEST_F(NfcEventHandlerTest, ProcessEvent008, TestSize.Level1)
193 {
194 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
195 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
196 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
197 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
198 std::weak_ptr<NfcPollingManager> nfcPollingManager;
199 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
200 AppExecFwk::InnerEvent::Pointer event =
201 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_FIELD_ACTIVATED), 0);
202 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
203 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
204 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
205 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
206 nfcEventHandler->ProcessEvent(event);
207 }
208
209 /**
210 * @tc.name: ProcessEvent009
211 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
212 * @tc.type: FUNC
213 */
214 HWTEST_F(NfcEventHandlerTest, ProcessEvent009, TestSize.Level1)
215 {
216 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
217 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
218 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
219 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
220 std::weak_ptr<NfcPollingManager> nfcPollingManager;
221 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
222 AppExecFwk::InnerEvent::Pointer event =
223 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_FIELD_DEACTIVATED), 0);
224 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
225 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
226 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
227 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
228 nfcEventHandler->ProcessEvent(event);
229 }
230
231 /**
232 * @tc.name: ProcessEvent010
233 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
234 * @tc.type: FUNC
235 */
236 HWTEST_F(NfcEventHandlerTest, ProcessEvent010, TestSize.Level1)
237 {
238 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
239 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
240 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
241 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
242 std::weak_ptr<NfcPollingManager> nfcPollingManager;
243 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
244 AppExecFwk::InnerEvent::Pointer event =
245 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_NOTIFY_FIELD_ON), 0);
246 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
247 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
248 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
249 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
250 nfcEventHandler->ProcessEvent(event);
251 }
252
253 /**
254 * @tc.name: ProcessEvent011
255 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
256 * @tc.type: FUNC
257 */
258 HWTEST_F(NfcEventHandlerTest, ProcessEvent011, TestSize.Level1)
259 {
260 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
261 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
262 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
263 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
264 std::weak_ptr<NfcPollingManager> nfcPollingManager;
265 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
266 AppExecFwk::InnerEvent::Pointer event =
267 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_NOTIFY_FIELD_OFF), 0);
268 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
269 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
270 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
271 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
272 nfcEventHandler->ProcessEvent(event);
273 }
274
275 /**
276 * @tc.name: ProcessEvent012
277 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
278 * @tc.type: FUNC
279 */
280 HWTEST_F(NfcEventHandlerTest, ProcessEvent012, TestSize.Level1)
281 {
282 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
283 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
284 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
285 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
286 std::weak_ptr<NfcPollingManager> nfcPollingManager;
287 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
288 AppExecFwk::InnerEvent::Pointer event =
289 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_NOTIFY_FIELD_OFF_TIMEOUT), 0);
290 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
291 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
292 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
293 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
294 nfcEventHandler->ProcessEvent(event);
295 }
296
297 /**
298 * @tc.name: ProcessEvent013
299 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
300 * @tc.type: FUNC
301 */
302 HWTEST_F(NfcEventHandlerTest, ProcessEvent013, TestSize.Level1)
303 {
304 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
305 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
306 service->Initialize();
307 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
308 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
309 std::weak_ptr<NfcPollingManager> nfcPollingManager;
310 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
311 AppExecFwk::InnerEvent::Pointer event =
312 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_SHUTDOWN), 0);
313 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
314 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
315 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
316 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
317 nfcEventHandler->ProcessEvent(event);
318 }
319
320 /**
321 * @tc.name: ProcessEvent014
322 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
323 * @tc.type: FUNC
324 */
325 HWTEST_F(NfcEventHandlerTest, ProcessEvent014, TestSize.Level1)
326 {
327 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
328 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
329 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
330 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
331 std::weak_ptr<NfcPollingManager> nfcPollingManager;
332 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
333 AppExecFwk::InnerEvent::Pointer event =
334 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_DATA_SHARE_READY), 0);
335 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
336 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
337 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
338 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
339 nfcEventHandler->ProcessEvent(event);
340 }
341
342 /**
343 * @tc.name: ProcessEvent015
344 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
345 * @tc.type: FUNC
346 */
347 HWTEST_F(NfcEventHandlerTest, ProcessEvent015, TestSize.Level1)
348 {
349 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
350 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
351 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
352 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
353 std::weak_ptr<NfcPollingManager> nfcPollingManager;
354 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
355 AppExecFwk::InnerEvent::Pointer event =
356 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_VENDOR_EVENT),
357 static_cast<int64_t>(KITS::VENDOR_APP_INIT_DONE));
358 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
359 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
360 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
361 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
362 nfcEventHandler->ProcessEvent(event);
363 }
364
365 /**
366 * @tc.name: ProcessEvent016
367 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
368 * @tc.type: FUNC
369 */
370 HWTEST_F(NfcEventHandlerTest, ProcessEvent016, TestSize.Level1)
371 {
372 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
373 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
374 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
375 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
376 std::weak_ptr<NfcPollingManager> nfcPollingManager;
377 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
378 AppExecFwk::InnerEvent::Pointer event =
379 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_VENDOR_EVENT),
380 static_cast<int64_t>(KITS::VENDOR_APP_CHANGE));
381 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
382 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
383 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
384 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
385 nfcEventHandler->ProcessEvent(event);
386 }
387
388 /**
389 * @tc.name: ProcessEvent017
390 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
391 * @tc.type: FUNC
392 */
393 HWTEST_F(NfcEventHandlerTest, ProcessEvent017, TestSize.Level1)
394 {
395 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
396 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
397 std::weak_ptr<TAG::TagDispatcher> tagDispatcher;
398 std::weak_ptr<NfcRoutingManager> nfcRoutingManager;
399 std::weak_ptr<NfcPollingManager> nfcPollingManager;
400 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy;
401 AppExecFwk::InnerEvent::Pointer event =
402 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_VENDOR_EVENT), 0);
403 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
404 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = NCI::NciNativeSelector::GetInstance().GetNciCeInterface();
405 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(service, nciCeProxy);
406 nfcEventHandler->Intialize(tagDispatcher, ceService, nfcPollingManager, nfcRoutingManager, nciNfccProxy);
407 nfcEventHandler->ProcessEvent(event);
408 }
409
410 /**
411 * @tc.name: ProcessEvent018
412 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
413 * @tc.type: FUNC
414 */
415 HWTEST_F(NfcEventHandlerTest, ProcessEvent018, TestSize.Level1)
416 {
417 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
418 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
419 AppExecFwk::InnerEvent::Pointer event =
420 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_WIFI_ENABLE_TIMEOUT), 0);
421 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
422 nfcEventHandler->ProcessEvent(event);
423 }
424
425 /**
426 * @tc.name: ProcessEvent019
427 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
428 * @tc.type: FUNC
429 */
430 HWTEST_F(NfcEventHandlerTest, ProcessEvent019, TestSize.Level1)
431 {
432 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
433 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
434 AppExecFwk::InnerEvent::Pointer event =
435 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_WIFI_CONNECT_TIMEOUT), 0);
436 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
437 nfcEventHandler->ProcessEvent(event);
438 }
439
440 /**
441 * @tc.name: ProcessEvent020
442 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
443 * @tc.type: FUNC
444 */
445 HWTEST_F(NfcEventHandlerTest, ProcessEvent020, TestSize.Level1)
446 {
447 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
448 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
449 AppExecFwk::InnerEvent::Pointer event =
450 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_WIFI_ENABLED), 0);
451 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
452 nfcEventHandler->ProcessEvent(event);
453 }
454
455 /**
456 * @tc.name: ProcessEvent021
457 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
458 * @tc.type: FUNC
459 */
460 HWTEST_F(NfcEventHandlerTest, ProcessEvent021, TestSize.Level1)
461 {
462 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
463 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
464 AppExecFwk::InnerEvent::Pointer event =
465 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_WIFI_CONNECTED), 0);
466 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
467 nfcEventHandler->ProcessEvent(event);
468 }
469
470 /**
471 * @tc.name: ProcessEvent022
472 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
473 * @tc.type: FUNC
474 */
475 HWTEST_F(NfcEventHandlerTest, ProcessEvent022, TestSize.Level1)
476 {
477 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
478 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
479 AppExecFwk::InnerEvent::Pointer event =
480 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_WIFI_NTF_CLICKED), 0);
481 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
482 nfcEventHandler->ProcessEvent(event);
483 }
484
485 /**
486 * @tc.name: ProcessEvent023
487 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
488 * @tc.type: FUNC
489 */
490 HWTEST_F(NfcEventHandlerTest, ProcessEvent023, TestSize.Level1)
491 {
492 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
493 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
494 AppExecFwk::InnerEvent::Pointer event =
495 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_BT_ENABLE_TIMEOUT), 0);
496 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
497 nfcEventHandler->ProcessEvent(event);
498 }
499
500 /**
501 * @tc.name: ProcessEvent024
502 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
503 * @tc.type: FUNC
504 */
505 HWTEST_F(NfcEventHandlerTest, ProcessEvent024, TestSize.Level1)
506 {
507 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
508 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
509 AppExecFwk::InnerEvent::Pointer event =
510 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_BT_PAIR_TIMEOUT), 0);
511 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
512 nfcEventHandler->ProcessEvent(event);
513 }
514
515 /**
516 * @tc.name: ProcessEvent025
517 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
518 * @tc.type: FUNC
519 */
520 HWTEST_F(NfcEventHandlerTest, ProcessEvent025, TestSize.Level1)
521 {
522 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
523 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
524 AppExecFwk::InnerEvent::Pointer event =
525 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_BT_CONNECT_TIMEOUT), 0);
526 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
527 nfcEventHandler->ProcessEvent(event);
528 }
529
530 /**
531 * @tc.name: ProcessEvent026
532 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
533 * @tc.type: FUNC
534 */
535 HWTEST_F(NfcEventHandlerTest, ProcessEvent026, TestSize.Level1)
536 {
537 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
538 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
539 AppExecFwk::InnerEvent::Pointer event =
540 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_BT_ENABLED), 0);
541 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
542 nfcEventHandler->ProcessEvent(event);
543 }
544
545 /**
546 * @tc.name: ProcessEvent027
547 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
548 * @tc.type: FUNC
549 */
550 HWTEST_F(NfcEventHandlerTest, ProcessEvent027, TestSize.Level1)
551 {
552 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
553 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
554 AppExecFwk::InnerEvent::Pointer event =
555 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_BT_PAIR_STATUS_CHANGED), 0);
556 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
557 nfcEventHandler->ProcessEvent(event);
558 }
559
560 /**
561 * @tc.name: ProcessEvent028
562 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
563 * @tc.type: FUNC
564 */
565 HWTEST_F(NfcEventHandlerTest, ProcessEvent028, TestSize.Level1)
566 {
567 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
568 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
569 AppExecFwk::InnerEvent::Pointer event =
570 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_BT_CONNECT_STATUS_CHANGED), 0);
571 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
572 nfcEventHandler->ProcessEvent(event);
573 }
574
575 /**
576 * @tc.name: ProcessEvent029
577 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
578 * @tc.type: FUNC
579 */
580 HWTEST_F(NfcEventHandlerTest, ProcessEvent029, TestSize.Level1)
581 {
582 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
583 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
584 AppExecFwk::InnerEvent::Pointer event =
585 AppExecFwk::InnerEvent::Get(static_cast<uint32_t>(NfcCommonEvent::MSG_BT_NTF_CLICKED), 0);
586 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
587 nfcEventHandler->ProcessEvent(event);
588 }
589
590 /**
591 * @tc.name: ProcessEvent030
592 * @tc.desc: Test NfcEventHandlerTest ProcessEvent.
593 * @tc.type: FUNC
594 */
595 HWTEST_F(NfcEventHandlerTest, ProcessEvent030, TestSize.Level1)
596 {
597 std::shared_ptr<AppExecFwk::EventRunner> runner = nullptr;
598 std::shared_ptr<NfcService> service = std::make_shared<NfcService>();
599 AppExecFwk::InnerEvent::Pointer event =
600 AppExecFwk::InnerEvent::Get(-1, 0);
601 std::shared_ptr<NfcEventHandler> nfcEventHandler = std::make_shared<NfcEventHandler>(runner, service);
602 nfcEventHandler->ProcessEvent(event);
603 }
604 } // namespace TEST
605 } // namespace TAG
606 } // namespace NFC
607 } // namespace OHOS