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 "isodep_card_handler.h"
19
20 namespace OHOS {
21 namespace NFC {
22 namespace TEST {
23 using namespace testing::ext;
24 using namespace OHOS::NFC::TAG;
25 class IsodepCardHandlerTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp();
30 void TearDown();
31 };
32
SetUpTestCase()33 void IsodepCardHandlerTest::SetUpTestCase()
34 {
35 std::cout << " SetUpTestCase IsodepCardHandlerTest." << std::endl;
36 }
37
TearDownTestCase()38 void IsodepCardHandlerTest::TearDownTestCase()
39 {
40 std::cout << " TearDownTestCase IsodepCardHandlerTest." << std::endl;
41 }
42
SetUp()43 void IsodepCardHandlerTest::SetUp()
44 {
45 std::cout << " SetUp IsodepCardHandlerTest." << std::endl;
46 }
47
TearDown()48 void IsodepCardHandlerTest::TearDown()
49 {
50 std::cout << " TearDown IsodepCardHandlerTest." << std::endl;
51 }
52
53 /**
54 * @tc.name: InitTransportCardInfo001
55 * @tc.desc: Test IsodepCardHandlerTest InitTransportCardInfo.
56 * @tc.type: FUNC
57 */
58 HWTEST_F(IsodepCardHandlerTest, InitTransportCardInfo001, TestSize.Level1)
59 {
60 std::shared_ptr<NCI::INciTagInterface> nciTagProxy = nullptr;
61 std::shared_ptr<IsodepCardHandler> isodepCardHandler = std::make_shared<IsodepCardHandler>(nciTagProxy);
62 isodepCardHandler->InitTransportCardInfo();
63 ASSERT_TRUE(isodepCardHandler != nullptr);
64 }
65
66 /**
67 * @tc.name: IsSupportedTransportCard001
68 * @tc.desc: Test IsodepCardHandlerTest IsSupportedTransportCard.
69 * @tc.type: FUNC
70 */
71 HWTEST_F(IsodepCardHandlerTest, IsSupportedTransportCard001, TestSize.Level1)
72 {
73 std::shared_ptr<NCI::INciTagInterface> nciTagProxy = nullptr;
74 uint32_t rfDiscId = 0;
75 uint8_t cardIndex = 0;
76 std::shared_ptr<IsodepCardHandler> isodepCardHandler = std::make_shared<IsodepCardHandler>(nciTagProxy);
77 bool res = isodepCardHandler->IsSupportedTransportCard(rfDiscId, cardIndex);
78 ASSERT_TRUE(!res);
79 }
80
81 /**
82 * @tc.name: GetBalance001
83 * @tc.desc: Test IsodepCardHandlerTest GetBalance.
84 * @tc.type: FUNC
85 */
86 HWTEST_F(IsodepCardHandlerTest, GetBalance001, TestSize.Level1)
87 {
88 std::shared_ptr<NCI::INciTagInterface> nciTagProxy = nullptr;
89 uint32_t rfDiscId = 0;
90 uint8_t cardIndex = 0;
91 int balance = 0;
92 std::shared_ptr<IsodepCardHandler> isodepCardHandler = std::make_shared<IsodepCardHandler>(nciTagProxy);
93 isodepCardHandler->GetBalance(rfDiscId, cardIndex, balance);
94 ASSERT_TRUE(isodepCardHandler != nullptr);
95 }
96
97 /**
98 * @tc.name: GetCardName001
99 * @tc.desc: Test IsodepCardHandlerTest GetCardName.
100 * @tc.type: FUNC
101 */
102 HWTEST_F(IsodepCardHandlerTest, GetCardName001, TestSize.Level1)
103 {
104 std::shared_ptr<NCI::INciTagInterface> nciTagProxy = nullptr;
105 uint8_t cardIndex = 0;
106 std::string cardName = "";
107 std::shared_ptr<IsodepCardHandler> isodepCardHandler = std::make_shared<IsodepCardHandler>(nciTagProxy);
108 isodepCardHandler->GetCardName(cardIndex, cardName);
109 ASSERT_TRUE(isodepCardHandler != nullptr);
110 }
111 } // namespace TEST
112 } // namespace NFC
113 } // namespace OHOS