1 /*
2  * Copyright (C) 2022 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 
16 #include "pinauth_test.h"
17 #include <gtest/gtest.h>
18 #include <string>
19 #include "iam_logger.h"
20 #include "pinauth_register.h"
21 #include "i_inputer.h"
22 
23 #define LOG_TAG "PIN_AUTH_SDK"
24 
25 using namespace testing::ext;
26 namespace OHOS {
27 namespace UserIam {
28 namespace PinAuth {
29 class UseriamUtTest : public testing::Test {
30 public:
31     static void SetUpTestCase(void);
32 
33     static void TearDownTestCase(void);
34 
35     void SetUp();
36 
37     void TearDown();
38 };
39 class InputerUT : public IInputer {
40 public:
OnGetData(int32_t authSubType,std::vector<uint8_t> challenge,std::shared_ptr<IInputerData> inputerData)41     void OnGetData(
42         int32_t authSubType, std::vector<uint8_t> challenge, std::shared_ptr<IInputerData> inputerData) override {}
43     virtual ~InputerUT() = default;
44 };
45 
SetUpTestCase(void)46 void UseriamUtTest::SetUpTestCase(void)
47 {
48 }
49 
TearDownTestCase(void)50 void UseriamUtTest::TearDownTestCase(void)
51 {
52 }
53 
SetUp()54 void UseriamUtTest::SetUp()
55 {
56 }
57 
TearDown()58 void UseriamUtTest::TearDown()
59 {
60 }
61 /**
62  * @tc.cpp: /interfaces/innerkits/src/piuauth_innerkits/src/pinauth_register_impl.cpp
63  */
64 
65 /**
66  * @tc.name: UseriamUtTest.UseriamUtTest001
67  * @tc.type: FUNC
68  */
69 HWTEST_F(UseriamUtTest, UseriamUtTest001, TestSize.Level1)
70 {
71     IAM_LOGI("**********UseriamUtTest***001***in**********");
72     std::shared_ptr<IInputer> inputer = nullptr;
73     EXPECT_EQ(false, PinAuthRegister::GetInstance().RegisterInputer(inputer));
74     IAM_LOGI("**********UseriamUtTest***001***out**********");
75 }
76 
77 /**
78  * @tc.name: UseriamUtTest.UseriamUtTest002
79  * @tc.type: FUNC
80  */
81 HWTEST_F(UseriamUtTest, UseriamUtTest002, TestSize.Level1)
82 {
83     IAM_LOGI("**********UseriamUtTest***002***in**********");
84     std::shared_ptr<IInputer> inputer = std::make_shared<InputerUT>();
85     EXPECT_EQ(false, PinAuthRegister::GetInstance().RegisterInputer(inputer));
86     IAM_LOGI("**********UseriamUtTest***002***out**********");
87 }
88 
89 /**
90  * @tc.name: UseriamUtTest.UseriamUtTest003
91  * @tc.type: FUNC
92  */
93 HWTEST_F(UseriamUtTest, UseriamUtTest003, TestSize.Level1)
94 {
95     IAM_LOGI("**********UseriamUtTest***003***in**********");
96     PinAuthRegister::GetInstance().UnRegisterInputer();
97     IAM_LOGI("**********UseriamUtTest***003***out**********");
98 }
99 } // namespace PinAuth
100 } // namespace UserIam
101 } // namespace OHOS