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
25using namespace testing::ext;
26namespace OHOS {
27namespace UserIam {
28namespace PinAuth {
29class UseriamUtTest : public testing::Test {
30public:
31    static void SetUpTestCase(void);
32
33    static void TearDownTestCase(void);
34
35    void SetUp();
36
37    void TearDown();
38};
39class InputerUT : public IInputer {
40public:
41    void OnGetData(
42        int32_t authSubType, std::vector<uint8_t> challenge, std::shared_ptr<IInputerData> inputerData) override {}
43    virtual ~InputerUT() = default;
44};
45
46void UseriamUtTest::SetUpTestCase(void)
47{
48}
49
50void UseriamUtTest::TearDownTestCase(void)
51{
52}
53
54void UseriamUtTest::SetUp()
55{
56}
57
58void 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 */
69HWTEST_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 */
81HWTEST_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 */
93HWTEST_F(UseriamUtTest, UseriamUtTest003, TestSize.Level1)
94{
95    IAM_LOGI("**********UseriamUtTest***003***in**********");
96    EXPECT_NO_THROW(PinAuthRegister::GetInstance().UnRegisterInputer());
97    IAM_LOGI("**********UseriamUtTest***003***out**********");
98}
99} // namespace PinAuth
100} // namespace UserIam
101} // namespace OHOS