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