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: OnDefaultPaymentServiceChange001
124 * @tc.desc: Test CeServiceTest OnDefaultPaymentServiceChange.
125 * @tc.type: FUNC
126 */
127 HWTEST_F(CeServiceTest, OnDefaultPaymentServiceChange001, TestSize.Level1)
128 {
129 std::shared_ptr<NfcService> nfcService = nullptr;
130 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
131 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
132 ceService->Initialize();
133 sptr<KITS::IHceCmdCallback> callback = nullptr;
134 std::string type = "";
135 Security::AccessToken::AccessTokenID callerToken = 0;
136 ceService->OnDefaultPaymentServiceChange();
137 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
138 ASSERT_TRUE(regHceCmdCallback == false);
139 }
140
141 /**
142 * @tc.name: OnAppAddOrChangeOrRemove001
143 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
144 * @tc.type: FUNC
145 */
146 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove001, TestSize.Level1)
147 {
148 std::shared_ptr<NfcService> nfcService = nullptr;
149 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
150 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
151 ceService->Initialize();
152 std::shared_ptr<EventFwk::CommonEventData> data = nullptr;
153 sptr<KITS::IHceCmdCallback> callback = nullptr;
154 std::string type = "";
155 Security::AccessToken::AccessTokenID callerToken = 0;
156 ceService->OnAppAddOrChangeOrRemove(data);
157 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
158 ASSERT_TRUE(regHceCmdCallback == false);
159 }
160
161 /**
162 * @tc.name: OnAppAddOrChangeOrRemove002
163 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
164 * @tc.type: FUNC
165 */
166 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove002, TestSize.Level1)
167 {
168 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
169 nfcService->Initialize();
170 std::weak_ptr<CeService> ceService = nfcService->GetCeService();
171 ceService.lock()->Initialize();
172 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
173 sptr<KITS::IHceCmdCallback> callback = nullptr;
174 std::string type = "";
175 Security::AccessToken::AccessTokenID callerToken = 0;
176 ceService.lock()->OnAppAddOrChangeOrRemove(data);
177 bool regHceCmdCallback = ceService.lock()->RegHceCmdCallback(callback, type, callerToken);
178 ASSERT_TRUE(regHceCmdCallback == false);
179 }
180
181 /**
182 * @tc.name: OnAppAddOrChangeOrRemove003
183 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
184 * @tc.type: FUNC
185 */
186 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove003, TestSize.Level1)
187 {
188 std::shared_ptr<NfcService> nfcService = nullptr;
189 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
190 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
191 ceService->Initialize();
192 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
193 AAFwk::Want want;
194 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
195 data->SetWant(want);
196 ceService->OnAppAddOrChangeOrRemove(data);
197 }
198
199 /**
200 * @tc.name: OnAppAddOrChangeOrRemove004
201 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
202 * @tc.type: FUNC
203 */
204 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove004, TestSize.Level1)
205 {
206 std::shared_ptr<NfcService> nfcService = nullptr;
207 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
208 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
209 ceService->Initialize();
210 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
211 AAFwk::Want want;
212 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED);
213 data->SetWant(want);
214 ceService->OnAppAddOrChangeOrRemove(data);
215 }
216
217 /**
218 * @tc.name: OnAppAddOrChangeOrRemove005
219 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
220 * @tc.type: FUNC
221 */
222 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove005, TestSize.Level1)
223 {
224 std::shared_ptr<NfcService> nfcService = nullptr;
225 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
226 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
227 ceService->Initialize();
228 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
229 AAFwk::Want want;
230 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED);
231 data->SetWant(want);
232 ceService->OnAppAddOrChangeOrRemove(data);
233 }
234
235 /**
236 * @tc.name: OnAppAddOrChangeOrRemove006
237 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
238 * @tc.type: FUNC
239 */
240 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove006, TestSize.Level1)
241 {
242 std::shared_ptr<NfcService> nfcService = nullptr;
243 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
244 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
245 ceService->Initialize();
246 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
247 AAFwk::Want want;
248 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_USER_PRESENT);
249 data->SetWant(want);
250 ceService->OnAppAddOrChangeOrRemove(data);
251 }
252
253 /**
254 * @tc.name: OnAppAddOrChangeOrRemove007
255 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
256 * @tc.type: FUNC
257 */
258 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove007, TestSize.Level1)
259 {
260 std::shared_ptr<NfcService> nfcService = nullptr;
261 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
262 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
263 ceService->Initialize();
264 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
265 AAFwk::Want want;
266 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
267 ElementName element("123", "456", "789");
268 want.SetElement(element);
269 data->SetWant(want);
270 ceService->OnAppAddOrChangeOrRemove(data);
271 }
272
273 /**
274 * @tc.name: OnAppAddOrChangeOrRemove008
275 * @tc.desc: Test CeServiceTest OnAppAddOrChangeOrRemove.
276 * @tc.type: FUNC
277 */
278 HWTEST_F(CeServiceTest, OnAppAddOrChangeOrRemove008, TestSize.Level1)
279 {
280 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
281 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
282 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
283 ceService->Initialize();
284 std::shared_ptr<EventFwk::CommonEventData> data = std::make_shared<EventFwk::CommonEventData>();
285 AAFwk::Want want;
286 want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
287 ElementName element("123", "456", "789");
288 want.SetElement(element);
289 data->SetWant(want);
290 ceService->OnAppAddOrChangeOrRemove(data);
291 }
292
293 /**
294 * @tc.name: ConfigRoutingAndCommit001
295 * @tc.desc: Test CeServiceTest ConfigRoutingAndCommit.
296 * @tc.type: FUNC
297 */
298 HWTEST_F(CeServiceTest, ConfigRoutingAndCommit001, TestSize.Level1)
299 {
300 std::shared_ptr<NfcService> nfcService = nullptr;
301 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
302 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
303 ceService->Initialize();
304 sptr<KITS::IHceCmdCallback> callback = nullptr;
305 std::string type = "";
306 Security::AccessToken::AccessTokenID callerToken = 0;
307 ceService->ConfigRoutingAndCommit();
308 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
309 ASSERT_TRUE(regHceCmdCallback == false);
310 }
311
312 /**
313 * @tc.name: ConfigRoutingAndCommit002
314 * @tc.desc: Test CeServiceTest ConfigRoutingAndCommit.
315 * @tc.type: FUNC
316 */
317 HWTEST_F(CeServiceTest, ConfigRoutingAndCommit002, TestSize.Level1)
318 {
319 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
320 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
321 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
322 ceService->Initialize();
323 sptr<KITS::IHceCmdCallback> callback = nullptr;
324 std::string type = "";
325 Security::AccessToken::AccessTokenID callerToken = 0;
326 ceService->ConfigRoutingAndCommit();
327 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
328 ASSERT_TRUE(regHceCmdCallback == false);
329 }
330
331 /**
332 * @tc.name: HandleFieldDeactivated001
333 * @tc.desc: Test CeServiceTest HandleFieldDeactivated.
334 * @tc.type: FUNC
335 */
336 HWTEST_F(CeServiceTest, HandleFieldDeactivated001, TestSize.Level1)
337 {
338 std::shared_ptr<NfcService> nfcService = nullptr;
339 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
340 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
341 ceService->Initialize();
342 sptr<KITS::IHceCmdCallback> callback = nullptr;
343 std::string type = "";
344 Security::AccessToken::AccessTokenID callerToken = 0;
345 ceService->HandleFieldDeactivated();
346 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
347 ASSERT_TRUE(regHceCmdCallback == false);
348 }
349
350 /**
351 * @tc.name: OnCardEmulationData001
352 * @tc.desc: Test CeServiceTest OnCardEmulationData.
353 * @tc.type: FUNC
354 */
355 HWTEST_F(CeServiceTest, OnCardEmulationData001, TestSize.Level1)
356 {
357 std::shared_ptr<NfcService> nfcService = nullptr;
358 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
359 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
360 ceService->Initialize();
361 std::vector<uint8_t> data;
362 sptr<KITS::IHceCmdCallback> callback = nullptr;
363 std::string type = "";
364 Security::AccessToken::AccessTokenID callerToken = 0;
365 ceService->OnCardEmulationData(data);
366 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
367 ASSERT_TRUE(regHceCmdCallback == false);
368 }
369
370 /**
371 * @tc.name: OnCardEmulationData002
372 * @tc.desc: Test CeServiceTest OnCardEmulationData.
373 * @tc.type: FUNC
374 */
375 HWTEST_F(CeServiceTest, OnCardEmulationData002, TestSize.Level1)
376 {
377 std::shared_ptr<NfcService> nfcService = nullptr;
378 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
379 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
380 std::vector<uint8_t> data;
381 sptr<KITS::IHceCmdCallback> callback = nullptr;
382 std::string type = "";
383 Security::AccessToken::AccessTokenID callerToken = 0;
384 ceService->OnCardEmulationData(data);
385 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
386 ASSERT_TRUE(regHceCmdCallback == false);
387 }
388
389 /**
390 * @tc.name: OnCardEmulationActivated001
391 * @tc.desc: Test CeServiceTest OnCardEmulationActivated.
392 * @tc.type: FUNC
393 */
394 HWTEST_F(CeServiceTest, OnCardEmulationActivated001, TestSize.Level1)
395 {
396 std::shared_ptr<NfcService> nfcService = nullptr;
397 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
398 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
399 ceService->Initialize();
400 sptr<KITS::IHceCmdCallback> callback = nullptr;
401 std::string type = "";
402 Security::AccessToken::AccessTokenID callerToken = 0;
403 ceService->OnCardEmulationActivated();
404 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
405 ASSERT_TRUE(regHceCmdCallback == false);
406 }
407
408 /**
409 * @tc.name: OnCardEmulationActivated002
410 * @tc.desc: Test CeServiceTest OnCardEmulationActivated.
411 * @tc.type: FUNC
412 */
413 HWTEST_F(CeServiceTest, OnCardEmulationActivated002, TestSize.Level1)
414 {
415 std::shared_ptr<NfcService> nfcService = nullptr;
416 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
417 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
418 sptr<KITS::IHceCmdCallback> callback = nullptr;
419 std::string type = "";
420 Security::AccessToken::AccessTokenID callerToken = 0;
421 ceService->OnCardEmulationActivated();
422 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
423 ASSERT_TRUE(regHceCmdCallback == false);
424 }
425
426 /**
427 * @tc.name: OnCardEmulationDeactivated001
428 * @tc.desc: Test CeServiceTest OnCardEmulationDeactivated.
429 * @tc.type: FUNC
430 */
431 HWTEST_F(CeServiceTest, OnCardEmulationDeactivated001, TestSize.Level1)
432 {
433 std::shared_ptr<NfcService> nfcService = nullptr;
434 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
435 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
436 ceService->Initialize();
437 sptr<KITS::IHceCmdCallback> callback = nullptr;
438 std::string type = "";
439 Security::AccessToken::AccessTokenID callerToken = 0;
440 ceService->OnCardEmulationDeactivated();
441 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
442 ASSERT_TRUE(regHceCmdCallback == false);
443 }
444
445 /**
446 * @tc.name: OnCardEmulationDeactivated002
447 * @tc.desc: Test CeServiceTest OnCardEmulationDeactivated.
448 * @tc.type: FUNC
449 */
450 HWTEST_F(CeServiceTest, OnCardEmulationDeactivated002, TestSize.Level1)
451 {
452 std::shared_ptr<NfcService> nfcService = nullptr;
453 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
454 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
455 sptr<KITS::IHceCmdCallback> callback = nullptr;
456 std::string type = "";
457 Security::AccessToken::AccessTokenID callerToken = 0;
458 ceService->OnCardEmulationDeactivated();
459 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
460 ASSERT_TRUE(regHceCmdCallback == false);
461 }
462
463 /**
464 * @tc.name: PublishFieldOnOrOffCommonEvent001
465 * @tc.desc: Test CeServiceTest PublishFieldOnOrOffCommonEvent.
466 * @tc.type: FUNC
467 */
468 HWTEST_F(CeServiceTest, PublishFieldOnOrOffCommonEvent001, 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 ceService->Initialize();
474 bool isFieldOn = false;
475 sptr<KITS::IHceCmdCallback> callback = nullptr;
476 std::string type = "";
477 Security::AccessToken::AccessTokenID callerToken = 0;
478 ceService->PublishFieldOnOrOffCommonEvent(isFieldOn);
479 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
480 ASSERT_TRUE(regHceCmdCallback == false);
481 }
482
483 /**
484 * @tc.name: PublishFieldOnOrOffCommonEvent002
485 * @tc.desc: Test CeServiceTest PublishFieldOnOrOffCommonEvent.
486 * @tc.type: FUNC
487 */
488 HWTEST_F(CeServiceTest, PublishFieldOnOrOffCommonEvent002, TestSize.Level1)
489 {
490 std::shared_ptr<NfcService> nfcService = nullptr;
491 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
492 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
493 ceService->Initialize();
494 bool isFieldOn = true;
495 sptr<KITS::IHceCmdCallback> callback = nullptr;
496 std::string type = "";
497 Security::AccessToken::AccessTokenID callerToken = 0;
498 ceService->PublishFieldOnOrOffCommonEvent(isFieldOn);
499 bool regHceCmdCallback = ceService->RegHceCmdCallback(callback, type, callerToken);
500 ASSERT_TRUE(regHceCmdCallback == false);
501 }
502
503 /**
504 * @tc.name: UnRegHceCmdCallback001
505 * @tc.desc: Test CeServiceTest UnRegHceCmdCallback.
506 * @tc.type: FUNC
507 */
508 HWTEST_F(CeServiceTest, UnRegHceCmdCallback001, TestSize.Level1)
509 {
510 std::shared_ptr<NfcService> nfcService = nullptr;
511 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
512 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
513 ceService->Initialize();
514 const std::string type = "";
515 Security::AccessToken::AccessTokenID callerToken = 0;
516 bool unRegHceCmdCallback = ceService->UnRegHceCmdCallback(type, callerToken);
517 ASSERT_TRUE(unRegHceCmdCallback == false);
518 }
519
520 /**
521 * @tc.name: UnRegAllCallback001
522 * @tc.desc: Test CeServiceTest UnRegAllCallback.
523 * @tc.type: FUNC
524 */
525 HWTEST_F(CeServiceTest, UnRegAllCallback001, TestSize.Level1)
526 {
527 std::shared_ptr<NfcService> nfcService = nullptr;
528 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
529 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
530 ceService->Initialize();
531 Security::AccessToken::AccessTokenID callerToken = 0;
532 bool unRegAllCallback = ceService->UnRegAllCallback(callerToken);
533 ASSERT_TRUE(unRegAllCallback == false);
534 }
535
536 /**
537 * @tc.name: UnRegAllCallback002
538 * @tc.desc: Test CeServiceTest UnRegAllCallback.
539 * @tc.type: FUNC
540 */
541 HWTEST_F(CeServiceTest, UnRegAllCallback002, TestSize.Level1)
542 {
543 std::shared_ptr<NfcService> nfcService = nullptr;
544 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
545 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
546 Security::AccessToken::AccessTokenID callerToken = 0;
547 bool unRegAllCallback = ceService->UnRegAllCallback(callerToken);
548 ASSERT_TRUE(unRegAllCallback == false);
549 }
550
551 /**
552 * @tc.name: HandleFieldActivated001
553 * @tc.desc: Test CeServiceTest HandleFieldActivated.
554 * @tc.type: FUNC
555 */
556 HWTEST_F(CeServiceTest, HandleFieldActivated001, TestSize.Level1)
557 {
558 std::shared_ptr<NfcService> nfcService = nullptr;
559 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
560 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
561 ceService->Initialize();
562 Security::AccessToken::AccessTokenID callerToken = 0;
563 ceService->HandleFieldActivated();
564 bool unRegAllCallback = ceService->UnRegAllCallback(callerToken);
565 ASSERT_TRUE(unRegAllCallback == false);
566 }
567
568 /**
569 * @tc.name: HandleWhenRemoteDie001
570 * @tc.desc: Test CeServiceTest HandleWhenRemoteDie.
571 * @tc.type: FUNC
572 */
573 HWTEST_F(CeServiceTest, HandleWhenRemoteDie001, TestSize.Level1)
574 {
575 std::shared_ptr<NfcService> nfcService = nullptr;
576 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
577 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
578 ceService->Initialize();
579 Security::AccessToken::AccessTokenID callerToken = 0;
580 bool res = ceService->HandleWhenRemoteDie(callerToken);
581 ASSERT_TRUE(res == false);
582 }
583
584 /**
585 * @tc.name: SearchElementByAid001
586 * @tc.desc: Test CeServiceTest SearchElementByAid.
587 * @tc.type: FUNC
588 */
589 HWTEST_F(CeServiceTest, SearchElementByAid001, TestSize.Level1)
590 {
591 std::shared_ptr<NfcService> nfcService = nullptr;
592 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
593 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
594 ceService->Initialize();
595 std::string aid = "";
596 ElementName aidElement;
597 ceService->SearchElementByAid(aid, aidElement);
598 }
599
600 /**
601 * @tc.name: SearchElementByAid002
602 * @tc.desc: Test CeServiceTest SearchElementByAid.
603 * @tc.type: FUNC
604 */
605 HWTEST_F(CeServiceTest, SearchElementByAid002, TestSize.Level1)
606 {
607 std::shared_ptr<NfcService> nfcService = nullptr;
608 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
609 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
610 ceService->Initialize();
611 std::string aid = "123";
612 ElementName aidElement;
613 ceService->SearchElementByAid(aid, aidElement);
614 }
615
616 /**
617 * @tc.name: StartHce001
618 * @tc.desc: Test CeServiceTest StartHce.
619 * @tc.type: FUNC
620 */
621 HWTEST_F(CeServiceTest, StartHce001, TestSize.Level1)
622 {
623 std::shared_ptr<NfcService> nfcService = nullptr;
624 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
625 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
626 ElementName element;
627 std::vector<std::string> aids;
628 bool res = ceService->StartHce(element, aids);
629 ASSERT_TRUE(!res);
630 }
631
632 /**
633 * @tc.name: StartHce002
634 * @tc.desc: Test CeServiceTest StartHce.
635 * @tc.type: FUNC
636 */
637 HWTEST_F(CeServiceTest, StartHce002, TestSize.Level1)
638 {
639 std::shared_ptr<NfcService> nfcService = std::make_shared<NfcService>();
640 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
641 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
642 ElementName element;
643 std::vector<std::string> aids;
644 bool res = ceService->StartHce(element, aids);
645 ASSERT_TRUE(!res);
646 }
647
648 /**
649 * @tc.name: GetDefaultPaymentType001
650 * @tc.desc: Test CeServiceTest GetDefaultPaymentType.
651 * @tc.type: FUNC
652 */
653 HWTEST_F(CeServiceTest, GetDefaultPaymentType001, TestSize.Level1)
654 {
655 std::shared_ptr<NfcService> nfcService = nullptr;
656 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
657 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
658 KITS::DefaultPaymentType res = ceService->GetDefaultPaymentType();
659 ASSERT_TRUE(res == KITS::DefaultPaymentType::TYPE_EMPTY);
660 }
661
662 /**
663 * @tc.name: HandleDataShareReady001
664 * @tc.desc: Test CeServiceTest HandleDataShareReady.
665 * @tc.type: FUNC
666 */
667 HWTEST_F(CeServiceTest, HandleDataShareReady001, TestSize.Level1)
668 {
669 std::shared_ptr<NfcService> nfcService = nullptr;
670 std::shared_ptr<NCI::INciCeInterface> nciCeProxy = nullptr;
671 std::shared_ptr<CeService> ceService = std::make_shared<CeService>(nfcService, nciCeProxy);
672 ASSERT_TRUE(ceService != nullptr);
673 ceService->HandleDataShareReady();
674 }
675 }
676 }
677 }