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 "nci_ce_proxy.h"
19 #include "nfc_sdk_common.h"
20 
21 namespace OHOS {
22 namespace NFC {
23 namespace TEST {
24 using namespace testing::ext;
25 using namespace OHOS::NFC::NCI;
26 class NciCeProxyTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase()34 void NciCeProxyTest::SetUpTestCase()
35 {
36     std::cout << " SetUpTestCase NciCeProxyTest." << std::endl;
37 }
38 
TearDownTestCase()39 void NciCeProxyTest::TearDownTestCase()
40 {
41     std::cout << " TearDownTestCase NciCeProxyTest." << std::endl;
42 }
43 
SetUp()44 void NciCeProxyTest::SetUp()
45 {
46     std::cout << " SetUp NciCeProxyTest." << std::endl;
47 }
48 
TearDown()49 void NciCeProxyTest::TearDown()
50 {
51     std::cout << " TearDown NciCeProxyTest." << std::endl;
52 }
53 
54 /**
55  * @tc.name: SetCeHostListener001
56  * @tc.desc: Test NciCeProxyTest SetCeHostListener.
57  * @tc.type: FUNC
58  */
59 HWTEST_F(NciCeProxyTest, SetCeHostListener001, TestSize.Level1)
60 {
61     std::shared_ptr<NCI::INciCeInterface::ICeHostListener> listener = nullptr;
62     std::shared_ptr<NciCeProxy> nciCeProxy = std::make_shared<NciCeProxy>();
63     nciCeProxy->SetCeHostListener(listener);
64     bool computeRoutingParams = nciCeProxy->ComputeRoutingParams(static_cast<int>(KITS::DefaultPaymentType::TYPE_ESE));
65     ASSERT_TRUE(computeRoutingParams == true);
66 }
67 
68 /**
69  * @tc.name: ComputeRoutingParams001
70  * @tc.desc: Test NciCeProxyTest ComputeRoutingParams.
71  * @tc.type: FUNC
72  */
73 HWTEST_F(NciCeProxyTest, ComputeRoutingParams001, TestSize.Level1)
74 {
75     std::shared_ptr<NciCeProxy> nciCeProxy = std::make_shared<NciCeProxy>();
76     bool computeRoutingParams = nciCeProxy->ComputeRoutingParams(static_cast<int>(KITS::DefaultPaymentType::TYPE_ESE));
77     ASSERT_TRUE(computeRoutingParams == true);
78 }
79 
80 /**
81  * @tc.name: CommitRouting001
82  * @tc.desc: Test NciCeProxyTest CommitRouting.
83  * @tc.type: FUNC
84  */
85 HWTEST_F(NciCeProxyTest, CommitRouting001, TestSize.Level1)
86 {
87     std::shared_ptr<NciCeProxy> nciCeProxy = std::make_shared<NciCeProxy>();
88     bool commitRouting = nciCeProxy->CommitRouting();
89     ASSERT_TRUE(commitRouting == false);
90 }
91 
92 /**
93  * @tc.name: SendRawFrame001
94  * @tc.desc: Test NciCeProxyTest SendRawFrame.
95  * @tc.type: FUNC
96  */
97 HWTEST_F(NciCeProxyTest, SendRawFrame001, TestSize.Level1)
98 {
99     std::string hexCmdData = "123456";
100     std::shared_ptr<NciCeProxy> nciCeProxy = std::make_shared<NciCeProxy>();
101     bool sendRawFrame = nciCeProxy->SendRawFrame(hexCmdData);
102     ASSERT_TRUE(sendRawFrame == false);
103 }
104 
105 /**
106  * @tc.name: AddAidRouting001
107  * @tc.desc: Test NciCeProxyTest AddAidRouting.
108  * @tc.type: FUNC
109  */
110 HWTEST_F(NciCeProxyTest, AddAidRouting001, TestSize.Level1)
111 {
112     std::string aidStr = "";
113     int route = 0;
114     int aidInfo = 0;
115     int power = 0;
116     std::shared_ptr<NciCeProxy> nciCeProxy = std::make_shared<NciCeProxy>();
117     bool addAidRouting = nciCeProxy->AddAidRouting(aidStr, route, aidInfo, power);
118     ASSERT_TRUE(addAidRouting == false);
119 }
120 
121 /**
122  * @tc.name: NotifyDefaultPaymentType001
123  * @tc.desc: Test NciCeProxyTest NotifyDefaultPaymentType.
124  * @tc.type: FUNC
125  */
126 HWTEST_F(NciCeProxyTest, NotifyDefaultPaymentType001, TestSize.Level1)
127 {
128     std::shared_ptr<NciCeProxy> nciCeProxy = std::make_shared<NciCeProxy>();
129     int paymentType = static_cast<int>(KITS::DefaultPaymentType::TYPE_ESE);
130     nciCeProxy->NotifyDefaultPaymentType(paymentType);
131 }
132 }
133 }
134 }