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 #include <gtest/gtest.h>
16 #include <thread>
17
18 #include "ce_service.h"
19
20 namespace OHOS {
21 namespace NFC {
22 namespace TEST {
23 using namespace testing::ext;
24 using namespace OHOS::NFC;
25 class CeServiceTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp();
30 void TearDown();
31 };
32
SetUpTestCase()33 void CeServiceTest::SetUpTestCase()
34 {
35 std::cout << " SetUpTestCase CeServiceTest." << std::endl;
36 }
37
TearDownTestCase()38 void CeServiceTest::TearDownTestCase()
39 {
40 std::cout << " TearDownTestCase CeServiceTest." << std::endl;
41 }
42
SetUp()43 void CeServiceTest::SetUp()
44 {
45 std::cout << " SetUp CeServiceTest." << std::endl;
46 }
47
TearDown()48 void CeServiceTest::TearDown()
49 {
50 std::cout << " TearDown CeServiceTest." << std::endl;
51 }
52
53 /**
54 * @tc.name: RegHceCmdCallback001
55 * @tc.desc: Test CeServiceTest RegHceCmdCallback.
56 * @tc.type: FUNC
57 */
58 HWTEST_F(CeServiceTest, RegHceCmdCallback001, TestSize.Level1)
59 {
60 std::shared_ptr<NfcService> nfcService = nullptr;
61 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
62 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
63 ceService->Initialize();
64 const sptr<KITS::IHceCmdCallback> callback = nullptr;
65 const std::string type = "";
66 Security::AccessToken::AccessTokenID callerToken = 0;
67 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
68 ASSERT_TRUE(regHceCmdCallback == false);
69 }
70
71 /**
72 * @tc.name: SendHostApduData001
73 * @tc.desc: Test CeServiceTest SendHostApduData.
74 * @tc.type: FUNC
75 */
76 HWTEST_F(CeServiceTest, SendHostApduData001, TestSize.Level1)
77 {
78 std::shared_ptr<NfcService> nfcService = nullptr;
79 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
80 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
81 ceService->Initialize();
82 std::string hexCmdData = "";
83 bool raw = false;
84 std::string hexRespData = "";
85 Security::AccessToken::AccessTokenID callerToken = 0;
86 bool sendHostApduData = ceService->SendHostApduData(hexCmdData, raw, hexRespData, callerToken);
87 ASSERT_TRUE(sendHostApduData == false);
88 }
89
90 /**
91 * @tc.name: SendHostApduData002
92 * @tc.desc: Test CeServiceTest SendHostApduData.
93 * @tc.type: FUNC
94 */
95 HWTEST_F(CeServiceTest, SendHostApduData002, TestSize.Level1)
96 {
97 std::shared_ptr<NfcService> nfcService = nullptr;
98 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
99 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
100 std::string hexCmdData = "";
101 bool raw = false;
102 std::string hexRespData = "";
103 Security::AccessToken::AccessTokenID callerToken = 0;
104 bool sendHostApduData = ceService->SendHostApduData(hexCmdData, raw, hexRespData, callerToken);
105 ASSERT_TRUE(sendHostApduData == false);
106 }
107
108 /**
109 * @tc.name: InitConfigAidRouting001
110 * @tc.desc: Test CeServiceTest InitConfigAidRouting.
111 * @tc.type: FUNC
112 */
113 HWTEST_F(CeServiceTest, InitConfigAidRouting001, TestSize.Level1)
114 {
115 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
116 nfcService->Initialize();
117 std::weak_ptr<CeService> ceService = nfcService->GetCeService();
118 bool ret = ceService.lock()->InitConfigAidRouting(true);
119 ASSERT_TRUE(ret);
120 }
121
122 /**
123 * @tc.name: InitConfigAidRouting002
124 * @tc.desc: Test CeServiceTest InitConfigAidRouting.
125 * @tc.type: FUNC
126 */
127 HWTEST_F(CeServiceTest, InitConfigAidRouting002, TestSize.Level1)
128 {
129 std::shared_ptr<NfcService> nfcService;
130 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
131 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
132 bool ret = ceService->InitConfigAidRouting(true);
133 ASSERT_TRUE(!ret);
134 }
135
136 /**
137 * @tc.name: InitConfigAidRouting003
138 * @tc.desc: Test CeServiceTest InitConfigAidRouting.
139 * @tc.type: FUNC
140 */
141 HWTEST_F(CeServiceTest, InitConfigAidRouting003, TestSize.Level1)
142 {
143 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
144 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
145 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
146 nfcService->Initialize();
147 bool ret = ceService->InitConfigAidRouting(true);
148 ASSERT_TRUE(!ret);
149 }
150
151 /**
152 * @tc.name: OnDefaultPaymentServiceChange001
153 * @tc.desc: Test CeServiceTest OnDefaultPaymentServiceChange.
154 * @tc.type: FUNC
155 */
156 HWTEST_F(CeServiceTest, OnDefaultPaymentServiceChange001, TestSize.Level1)
157 {
158 std::shared_ptr<NfcService> nfcService = nullptr;
159 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
160 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
161 ceService->Initialize();
162 sptr<KITS::IHceCmdCallback> callback = nullptr;
163 std::string type = "";
164 Security::AccessToken::AccessTokenID callerToken = 0;
165 ceService->OnDefaultPaymentServiceChange();
166 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
167 ASSERT_TRUE(regHceCmdCallback == false);
168 }
169
170 /**
171 * @tc.name: OnAppAddOrChangeOrRemove001
172 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
173 * @tc.type: FUNC
174 */
175 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove001, TestSize.Level1)
176 {
177 std::shared_ptr<NfcService> nfcService = nullptr;
178 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
179 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
180 ceService->Initialize();
181 std::shared_ptr<EventFwk::CommonEventData> data = nullptr;
182 sptr<KITS::IHceCmdCallback> callback = nullptr;
183 std::string type = "";
184 Security::AccessToken::AccessTokenID callerToken = 0;
185 ceService->OnAppAddOrChangeOrRemove(data);
186 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
187 ASSERT_TRUE(regHceCmdCallback == false);
188 }
189
190 /**
191 * @tc.name: OnAppAddOrChangeOrRemove002
192 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
193 * @tc.type: FUNC
194 */
195 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove002, TestSize.Level1)
196 {
197 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
198 nfcService->Initialize();
199 std::weak_ptr<CeService> ceService = nfcService->GetCeService();
200 ceService.lock()->Initialize();
201 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
202 sptr<KITS::IHceCmdCallback> callback = nullptr;
203 std::string type = "";
204 Security::AccessToken::AccessTokenID callerToken = 0;
205 ceService.lock()->OnAppAddOrChangeOrRemove(data);
206 bool regHceCmdCallback = ceService.lock()->RegHceCmdCallback(callback, type, callerToken);
207 ASSERT_TRUE(regHceCmdCallback == false);
208 }
209
210 /**
211 * @tc.name: OnAppAddOrChangeOrRemove003
212 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
213 * @tc.type: FUNC
214 */
215 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove003, TestSize.Level1)
216 {
217 std::shared_ptr<NfcService> nfcService = nullptr;
218 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
219 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
220 ceService->Initialize();
221 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
222 AAFwk::Want want;
223 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
224 data->SetWant(want);
225 ceService->OnAppAddOrChangeOrRemove(data);
226 ASSERT_TRUE(ceService != nullptr);
227 }
228
229 /**
230 * @tc.name: OnAppAddOrChangeOrRemove004
231 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
232 * @tc.type: FUNC
233 */
234 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove004, TestSize.Level1)
235 {
236 std::shared_ptr<NfcService> nfcService = nullptr;
237 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
238 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
239 ceService->Initialize();
240 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
241 AAFwk::Want want;
242 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED);
243 data->SetWant(want);
244 ceService->OnAppAddOrChangeOrRemove(data);
245 ASSERT_TRUE(ceService != nullptr);
246 }
247
248 /**
249 * @tc.name: OnAppAddOrChangeOrRemove005
250 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
251 * @tc.type: FUNC
252 */
253 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove005, TestSize.Level1)
254 {
255 std::shared_ptr<NfcService> nfcService = nullptr;
256 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
257 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
258 ceService->Initialize();
259 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
260 AAFwk::Want want;
261 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED);
262 data->SetWant(want);
263 ceService->OnAppAddOrChangeOrRemove(data);
264 ASSERT_TRUE(ceService != nullptr);
265 }
266
267 /**
268 * @tc.name: OnAppAddOrChangeOrRemove006
269 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
270 * @tc.type: FUNC
271 */
272 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove006, TestSize.Level1)
273 {
274 std::shared_ptr<NfcService> nfcService = nullptr;
275 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
276 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
277 ceService->Initialize();
278 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
279 AAFwk::Want want;
280 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_USER_PRESENT);
281 data->SetWant(want);
282 ceService->OnAppAddOrChangeOrRemove(data);
283 ASSERT_TRUE(ceService != nullptr);
284 }
285
286 /**
287 * @tc.name: OnAppAddOrChangeOrRemove007
288 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
289 * @tc.type: FUNC
290 */
291 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove007, TestSize.Level1)
292 {
293 std::shared_ptr<NfcService> nfcService = nullptr;
294 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
295 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
296 ceService->Initialize();
297 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
298 AAFwk::Want want;
299 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
300 ElementName element("123", "456", "789");
301 want.SetElement(element);
302 data->SetWant(want);
303 ceService->OnAppAddOrChangeOrRemove(data);
304 ASSERT_TRUE(ceService != nullptr);
305 }
306
307 /**
308 * @tc.name: OnAppAddOrChangeOrRemove008
309 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
310 * @tc.type: FUNC
311 */
312 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove008, TestSize.Level1)
313 {
314 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
315 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
316 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
317 ceService->Initialize();
318 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
319 AAFwk::Want want;
320 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
321 ElementName element("123", "456", "789");
322 want.SetElement(element);
323 data->SetWant(want);
324 ceService->OnAppAddOrChangeOrRemove(data);
325 ASSERT_TRUE(ceService != nullptr);
326 }
327
328 /**
329 * @tc.name: ConfigRoutingAndCommit001
330 * @tc.desc: Test CeServiceTest ConfigRoutingAndCommit.
331 * @tc.type: FUNC
332 */
333 HWTEST_F(CeServiceTest, ConfigRoutingAndCommit001, TestSize.Level1)
334 {
335 std::shared_ptr<NfcService> nfcService = nullptr;
336 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
337 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
338 ceService->Initialize();
339 sptr<KITS::IHceCmdCallback> callback = nullptr;
340 std::string type = "";
341 Security::AccessToken::AccessTokenID callerToken = 0;
342 ceService->ConfigRoutingAndCommit();
343 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
344 ASSERT_TRUE(regHceCmdCallback == false);
345 }
346
347 /**
348 * @tc.name: ConfigRoutingAndCommit002
349 * @tc.desc: Test CeServiceTest ConfigRoutingAndCommit.
350 * @tc.type: FUNC
351 */
352 HWTEST_F(CeServiceTest, ConfigRoutingAndCommit002, TestSize.Level1)
353 {
354 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
355 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
356 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
357 ceService->Initialize();
358 sptr<KITS::IHceCmdCallback> callback = nullptr;
359 std::string type = "";
360 Security::AccessToken::AccessTokenID callerToken = 0;
361 ceService->ConfigRoutingAndCommit();
362 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
363 ASSERT_TRUE(regHceCmdCallback == false);
364 }
365
366 /**
367 * @tc.name: HandleFieldDeactivated001
368 * @tc.desc: Test CeServiceTest HandleFieldDeactivated.
369 * @tc.type: FUNC
370 */
371 HWTEST_F(CeServiceTest, HandleFieldDeactivated001, TestSize.Level1)
372 {
373 std::shared_ptr<NfcService> nfcService = nullptr;
374 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
375 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
376 ceService->Initialize();
377 sptr<KITS::IHceCmdCallback> callback = nullptr;
378 std::string type = "";
379 Security::AccessToken::AccessTokenID callerToken = 0;
380 ceService->HandleFieldDeactivated();
381 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
382 ASSERT_TRUE(regHceCmdCallback == false);
383 }
384
385 /**
386 * @tc.name: HandleFieldDeactivated002
387 * @tc.desc: Test CeServiceTest HandleFieldDeactivated.
388 * @tc.type: FUNC
389 */
390 HWTEST_F(CeServiceTest, HandleFieldDeactivated002, TestSize.Level1)
391 {
392 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
393 nfcService->Initialize();
394 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
395 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
396 ceService->Initialize();
397 sptr<KITS::IHceCmdCallback> callback = nullptr;
398 std::string type = "";
399 Security::AccessToken::AccessTokenID callerToken = 0;
400 ceService->HandleFieldDeactivated();
401 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
402 ASSERT_TRUE(regHceCmdCallback == false);
403 }
404
405 /**
406 * @tc.name: OnCardEmulationData001
407 * @tc.desc: Test CeServiceTest OnCardEmulationData.
408 * @tc.type: FUNC
409 */
410 HWTEST_F(CeServiceTest, OnCardEmulationData001, TestSize.Level1)
411 {
412 std::shared_ptr<NfcService> nfcService = nullptr;
413 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
414 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
415 ceService->Initialize();
416 std::vector<uint8_t> data;
417 sptr<KITS::IHceCmdCallback> callback = nullptr;
418 std::string type = "";
419 Security::AccessToken::AccessTokenID callerToken = 0;
420 ceService->OnCardEmulationData(data);
421 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
422 ASSERT_TRUE(regHceCmdCallback == false);
423 }
424
425 /**
426 * @tc.name: OnCardEmulationData002
427 * @tc.desc: Test CeServiceTest OnCardEmulationData.
428 * @tc.type: FUNC
429 */
430 HWTEST_F(CeServiceTest, OnCardEmulationData002, TestSize.Level1)
431 {
432 std::shared_ptr<NfcService> nfcService = nullptr;
433 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
434 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
435 std::vector<uint8_t> data;
436 sptr<KITS::IHceCmdCallback> callback = nullptr;
437 std::string type = "";
438 Security::AccessToken::AccessTokenID callerToken = 0;
439 ceService->OnCardEmulationData(data);
440 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
441 ASSERT_TRUE(regHceCmdCallback == false);
442 }
443
444 /**
445 * @tc.name: OnCardEmulationActivated001
446 * @tc.desc: Test CeServiceTest OnCardEmulationActivated.
447 * @tc.type: FUNC
448 */
449 HWTEST_F(CeServiceTest, OnCardEmulationActivated001, TestSize.Level1)
450 {
451 std::shared_ptr<NfcService> nfcService = nullptr;
452 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
453 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
454 ceService->Initialize();
455 sptr<KITS::IHceCmdCallback> callback = nullptr;
456 std::string type = "";
457 Security::AccessToken::AccessTokenID callerToken = 0;
458 ceService->OnCardEmulationActivated();
459 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
460 ASSERT_TRUE(regHceCmdCallback == false);
461 }
462
463 /**
464 * @tc.name: OnCardEmulationActivated002
465 * @tc.desc: Test CeServiceTest OnCardEmulationActivated.
466 * @tc.type: FUNC
467 */
468 HWTEST_F(CeServiceTest, OnCardEmulationActivated002, TestSize.Level1)
469 {
470 std::shared_ptr<NfcService> nfcService = nullptr;
471 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
472 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
473 sptr<KITS::IHceCmdCallback> callback = nullptr;
474 std::string type = "";
475 Security::AccessToken::AccessTokenID callerToken = 0;
476 ceService->OnCardEmulationActivated();
477 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
478 ASSERT_TRUE(regHceCmdCallback == false);
479 }
480
481 /**
482 * @tc.name: OnCardEmulationDeactivated001
483 * @tc.desc: Test CeServiceTest OnCardEmulationDeactivated.
484 * @tc.type: FUNC
485 */
486 HWTEST_F(CeServiceTest, OnCardEmulationDeactivated001, TestSize.Level1)
487 {
488 std::shared_ptr<NfcService> nfcService = nullptr;
489 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
490 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
491 ceService->Initialize();
492 sptr<KITS::IHceCmdCallback> callback = nullptr;
493 std::string type = "";
494 Security::AccessToken::AccessTokenID callerToken = 0;
495 ceService->OnCardEmulationDeactivated();
496 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
497 ASSERT_TRUE(regHceCmdCallback == false);
498 }
499
500 /**
501 * @tc.name: OnCardEmulationDeactivated002
502 * @tc.desc: Test CeServiceTest OnCardEmulationDeactivated.
503 * @tc.type: FUNC
504 */
505 HWTEST_F(CeServiceTest, OnCardEmulationDeactivated002, TestSize.Level1)
506 {
507 std::shared_ptr<NfcService> nfcService = nullptr;
508 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
509 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
510 sptr<KITS::IHceCmdCallback> callback = nullptr;
511 std::string type = "";
512 Security::AccessToken::AccessTokenID callerToken = 0;
513 ceService->OnCardEmulationDeactivated();
514 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
515 ASSERT_TRUE(regHceCmdCallback == false);
516 }
517
518 /**
519 * @tc.name: PublishFieldOnOrOffCommonEvent001
520 * @tc.desc: Test CeServiceTest PublishFieldOnOrOffCommonEvent.
521 * @tc.type: FUNC
522 */
523 HWTEST_F(CeServiceTest, PublishFieldOnOrOffCommonEvent001, TestSize.Level1)
524 {
525 std::shared_ptr<NfcService> nfcService = nullptr;
526 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
527 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
528 ceService->Initialize();
529 bool isFieldOn = false;
530 sptr<KITS::IHceCmdCallback> callback = nullptr;
531 std::string type = "";
532 Security::AccessToken::AccessTokenID callerToken = 0;
533 ceService->PublishFieldOnOrOffCommonEvent(isFieldOn);
534 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
535 ASSERT_TRUE(regHceCmdCallback == false);
536 }
537
538 /**
539 * @tc.name: PublishFieldOnOrOffCommonEvent002
540 * @tc.desc: Test CeServiceTest PublishFieldOnOrOffCommonEvent.
541 * @tc.type: FUNC
542 */
543 HWTEST_F(CeServiceTest, PublishFieldOnOrOffCommonEvent002, TestSize.Level1)
544 {
545 std::shared_ptr<NfcService> nfcService = nullptr;
546 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
547 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
548 ceService->Initialize();
549 bool isFieldOn = true;
550 sptr<KITS::IHceCmdCallback> callback = nullptr;
551 std::string type = "";
552 Security::AccessToken::AccessTokenID callerToken = 0;
553 ceService->PublishFieldOnOrOffCommonEvent(isFieldOn);
554 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
555 ASSERT_TRUE(regHceCmdCallback == false);
556 }
557
558 /**
559 * @tc.name: UnRegHceCmdCallback001
560 * @tc.desc: Test CeServiceTest UnRegHceCmdCallback.
561 * @tc.type: FUNC
562 */
563 HWTEST_F(CeServiceTest, UnRegHceCmdCallback001, TestSize.Level1)
564 {
565 std::shared_ptr<NfcService> nfcService = nullptr;
566 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
567 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
568 ceService->Initialize();
569 const std::string type = "";
570 Security::AccessToken::AccessTokenID callerToken = 0;
571 bool unRegHceCmdCallback = ceService->UnRegHceCmdCallback(type, callerToken);
572 ASSERT_TRUE(unRegHceCmdCallback == false);
573 }
574
575 /**
576 * @tc.name: UnRegAllCallback001
577 * @tc.desc: Test CeServiceTest UnRegAllCallback.
578 * @tc.type: FUNC
579 */
580 HWTEST_F(CeServiceTest, UnRegAllCallback001, TestSize.Level1)
581 {
582 std::shared_ptr<NfcService> nfcService = nullptr;
583 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
584 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
585 ceService->Initialize();
586 Security::AccessToken::AccessTokenID callerToken = 0;
587 bool unRegAllCallback = ceService->UnRegAllCallback(callerToken);
588 ASSERT_TRUE(unRegAllCallback == false);
589 }
590
591 /**
592 * @tc.name: UnRegAllCallback002
593 * @tc.desc: Test CeServiceTest UnRegAllCallback.
594 * @tc.type: FUNC
595 */
596 HWTEST_F(CeServiceTest, UnRegAllCallback002, TestSize.Level1)
597 {
598 std::shared_ptr<NfcService> nfcService = nullptr;
599 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
600 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
601 Security::AccessToken::AccessTokenID callerToken = 0;
602 bool unRegAllCallback = ceService->UnRegAllCallback(callerToken);
603 ASSERT_TRUE(unRegAllCallback == false);
604 }
605
606 /**
607 * @tc.name: HandleFieldActivated001
608 * @tc.desc: Test CeServiceTest HandleFieldActivated.
609 * @tc.type: FUNC
610 */
611 HWTEST_F(CeServiceTest, HandleFieldActivated001, TestSize.Level1)
612 {
613 std::shared_ptr<NfcService> nfcService = nullptr;
614 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
615 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
616 ceService->Initialize();
617 Security::AccessToken::AccessTokenID callerToken = 0;
618 ceService->HandleFieldActivated();
619 bool unRegAllCallback = ceService->UnRegAllCallback(callerToken);
620 ASSERT_TRUE(unRegAllCallback == false);
621 }
622
623 /**
624 * @tc.name: HandleFieldActivated002
625 * @tc.desc: Test CeServiceTest HandleFieldActivated.
626 * @tc.type: FUNC
627 */
628 HWTEST_F(CeServiceTest, HandleFieldActivated002, TestSize.Level1)
629 {
630 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
631 nfcService->Initialize();
632 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
633 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
634 ceService->Initialize();
635 Security::AccessToken::AccessTokenID callerToken = 0;
636 ceService->HandleFieldActivated();
637 bool unRegAllCallback = ceService->UnRegAllCallback(callerToken);
638 ASSERT_TRUE(unRegAllCallback == false);
639 }
640
641 /**
642 * @tc.name: HandleWhenRemoteDie001
643 * @tc.desc: Test CeServiceTest HandleWhenRemoteDie.
644 * @tc.type: FUNC
645 */
646 HWTEST_F(CeServiceTest, HandleWhenRemoteDie001, TestSize.Level1)
647 {
648 std::shared_ptr<NfcService> nfcService = nullptr;
649 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
650 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
651 ceService->Initialize();
652 Security::AccessToken::AccessTokenID callerToken = 0;
653 bool res = ceService->HandleWhenRemoteDie(callerToken);
654 ASSERT_TRUE(res == false);
655 }
656
657 /**
658 * @tc.name: SearchElementByAid001
659 * @tc.desc: Test CeServiceTest SearchElementByAid.
660 * @tc.type: FUNC
661 */
662 HWTEST_F(CeServiceTest, SearchElementByAid001, TestSize.Level1)
663 {
664 std::shared_ptr<NfcService> nfcService = nullptr;
665 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
666 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
667 ceService->Initialize();
668 std::string aid = "";
669 ElementName aidElement;
670 ceService->SearchElementByAid(aid, aidElement);
671 ASSERT_TRUE(ceService != nullptr);
672 }
673
674 /**
675 * @tc.name: SearchElementByAid002
676 * @tc.desc: Test CeServiceTest SearchElementByAid.
677 * @tc.type: FUNC
678 */
679 HWTEST_F(CeServiceTest, SearchElementByAid002, TestSize.Level1)
680 {
681 std::shared_ptr<NfcService> nfcService = nullptr;
682 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
683 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
684 ceService->Initialize();
685 std::string aid = "123";
686 ElementName aidElement;
687 ceService->SearchElementByAid(aid, aidElement);
688 ASSERT_TRUE(ceService != nullptr);
689 }
690
691 /**
692 * @tc.name: StartHce001
693 * @tc.desc: Test CeServiceTest StartHce.
694 * @tc.type: FUNC
695 */
696 HWTEST_F(CeServiceTest, StartHce001, TestSize.Level1)
697 {
698 std::shared_ptr<NfcService> nfcService = nullptr;
699 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
700 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
701 ElementName element;
702 std::vector<std::string> aids;
703 bool res = ceService->StartHce(element, aids);
704 ASSERT_TRUE(!res);
705 }
706
707 /**
708 * @tc.name: StartHce002
709 * @tc.desc: Test CeServiceTest StartHce.
710 * @tc.type: FUNC
711 */
712 HWTEST_F(CeServiceTest, StartHce002, TestSize.Level1)
713 {
714 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
715 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
716 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
717 ElementName element;
718 std::vector<std::string> aids;
719 bool res = ceService->StartHce(element, aids);
720 ASSERT_TRUE(!res);
721 }
722
723 /**
724 * @tc.name: GetDefaultPaymentType001
725 * @tc.desc: Test CeServiceTest GetDefaultPaymentType.
726 * @tc.type: FUNC
727 */
728 HWTEST_F(CeServiceTest, GetDefaultPaymentType001, TestSize.Level1)
729 {
730 std::shared_ptr<NfcService> nfcService = nullptr;
731 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
732 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
733 ceService->GetDefaultPaymentType();
734 ASSERT_TRUE(ceService);
735 }
736
737 /**
738 * @tc.name: HandleDataShareReady001
739 * @tc.desc: Test CeServiceTest HandleDataShareReady.
740 * @tc.type: FUNC
741 */
742 HWTEST_F(CeServiceTest, HandleDataShareReady001, TestSize.Level1)
743 {
744 std::shared_ptr<NfcService> nfcService = nullptr;
745 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
746 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
747 ASSERT_TRUE(ceService != nullptr);
748 ceService->HandleDataShareReady();
749 }
750 }
751 }
752 }