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_nfcc_proxy.h"
19
20 namespace OHOS {
21 namespace NFC {
22 namespace TEST {
23 using namespace testing::ext;
24 using namespace OHOS::NFC::NCI;
25 class NciNfccProxyTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp();
30 void TearDown();
31 };
32
SetUpTestCase()33 void NciNfccProxyTest::SetUpTestCase()
34 {
35 std::cout << " SetUpTestCase NciNfccProxyTest." << std::endl;
36 }
37
TearDownTestCase()38 void NciNfccProxyTest::TearDownTestCase()
39 {
40 std::cout << " TearDownTestCase NciNfccProxyTest." << std::endl;
41 }
42
SetUp()43 void NciNfccProxyTest::SetUp()
44 {
45 std::cout << " SetUp NciNfccProxyTest." << std::endl;
46 }
47
TearDown()48 void NciNfccProxyTest::TearDown()
49 {
50 std::cout << " TearDown NciNfccProxyTest." << std::endl;
51 }
52
53 /**
54 * @tc.name: Deinitialize001
55 * @tc.desc: Test NciNfccProxyTest Deinitialize.
56 * @tc.type: FUNC
57 */
58 HWTEST_F(NciNfccProxyTest, Deinitialize001, TestSize.Level1)
59 {
60 std::shared_ptr<NciNfccProxy> nciNfccProxy = std::make_shared<NciNfccProxy>();
61 bool deinitialize = nciNfccProxy->Deinitialize();
62 ASSERT_TRUE(deinitialize == false);
63 }
64
65 /**
66 * @tc.name: EnableDiscovery001
67 * @tc.desc: Test NciNfccProxyTest EnableDiscovery.
68 * @tc.type: FUNC
69 */
70 HWTEST_F(NciNfccProxyTest, EnableDiscovery001, TestSize.Level1)
71 {
72 uint16_t techMask = 0;
73 bool enableReaderMode = false;
74 bool enableHostRouting = false;
75 bool restart = false;
76 std::shared_ptr<NciNfccProxy> nciNfccProxy = std::make_shared<NciNfccProxy>();
77 nciNfccProxy->EnableDiscovery(techMask, enableReaderMode, enableHostRouting, restart);
78 int getNciVersion = nciNfccProxy->GetNciVersion();
79 ASSERT_TRUE(getNciVersion == 0);
80 }
81
82 /**
83 * @tc.name: DisableDiscovery001
84 * @tc.desc: Test NciNfccProxyTest DisableDiscovery.
85 * @tc.type: FUNC
86 */
87 HWTEST_F(NciNfccProxyTest, DisableDiscovery001, TestSize.Level1)
88 {
89 std::shared_ptr<NciNfccProxy> nciNfccProxy = std::make_shared<NciNfccProxy>();
90 nciNfccProxy->DisableDiscovery();
91 int getNciVersion = nciNfccProxy->GetNciVersion();
92 ASSERT_TRUE(getNciVersion == 0);
93 }
94
95 /**
96 * @tc.name: SetScreenStatus001
97 * @tc.desc: Test NciNfccProxyTest SetScreenStatus.
98 * @tc.type: FUNC
99 */
100 HWTEST_F(NciNfccProxyTest, SetScreenStatus001, TestSize.Level1)
101 {
102 uint8_t screenStateMask = 0;
103 std::shared_ptr<NciNfccProxy> nciNfccProxy = std::make_shared<NciNfccProxy>();
104 bool setScreenStatus = nciNfccProxy->SetScreenStatus(screenStateMask);
105 ASSERT_TRUE(setScreenStatus == true);
106 }
107
108 /**
109 * @tc.name: GetNciVersion001
110 * @tc.desc: Test NciNfccProxyTest GetNciVersion.
111 * @tc.type: FUNC
112 */
113 HWTEST_F(NciNfccProxyTest, GetNciVersion001, TestSize.Level1)
114 {
115 std::shared_ptr<NciNfccProxy> nciNfccProxy = std::make_shared<NciNfccProxy>();
116 int getNciVersion = nciNfccProxy->GetNciVersion();
117 ASSERT_TRUE(getNciVersion == 0);
118 }
119
120 /**
121 * @tc.name: FactoryReset001
122 * @tc.desc: Test NciNfccProxyTest FactoryReset.
123 * @tc.type: FUNC
124 */
125 HWTEST_F(NciNfccProxyTest, FactoryReset001, TestSize.Level1)
126 {
127 std::shared_ptr<NciNfccProxy> nciNfccProxy = std::make_shared<NciNfccProxy>();
128 nciNfccProxy->FactoryReset();
129 int getNciVersion = nciNfccProxy->GetNciVersion();
130 ASSERT_TRUE(getNciVersion == 0);
131 }
132
133 /**
134 * @tc.name: Shutdown001
135 * @tc.desc: Test NciNfccProxyTest Shutdown.
136 * @tc.type: FUNC
137 */
138 HWTEST_F(NciNfccProxyTest, Shutdown001, TestSize.Level1)
139 {
140 std::shared_ptr<NciNfccProxy> nciNfccProxy = std::make_shared<NciNfccProxy>();
141 nciNfccProxy->Shutdown();
142 int getNciVersion = nciNfccProxy->GetNciVersion();
143 ASSERT_TRUE(getNciVersion == 0);
144 }
145 }
146 }
147 }