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_LABEL OHOS::UserIam::Common::LABEL_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::shared_ptr<IInputerData> inputerData)41 void OnGetData(int32_t authSubType, std::shared_ptr<IInputerData> inputerData)override {}
42 virtual ~InputerUT() = default;
43 };
44
SetUpTestCase(void)45 void UseriamUtTest::SetUpTestCase(void)
46 {
47 }
48
TearDownTestCase(void)49 void UseriamUtTest::TearDownTestCase(void)
50 {
51 }
52
SetUp()53 void UseriamUtTest::SetUp()
54 {
55 }
56
TearDown()57 void UseriamUtTest::TearDown()
58 {
59 }
60 /**
61 * @tc.cpp: /interfaces/innerkits/src/piuauth_innerkits/src/pinauth_register_impl.cpp
62 */
63
64 /**
65 * @tc.name: UseriamUtTest.UseriamUtTest001
66 * @tc.type: FUNC
67 */
68 HWTEST_F(UseriamUtTest, UseriamUtTest001, TestSize.Level1)
69 {
70 IAM_LOGI("**********UseriamUtTest***001***in**********");
71 std::shared_ptr<IInputer> inputer = nullptr;
72 EXPECT_EQ(false, PinAuthRegister::GetInstance().RegisterInputer(inputer));
73 IAM_LOGI("**********UseriamUtTest***001***out**********");
74 }
75
76 /**
77 * @tc.name: UseriamUtTest.UseriamUtTest002
78 * @tc.type: FUNC
79 */
80 HWTEST_F(UseriamUtTest, UseriamUtTest002, TestSize.Level1)
81 {
82 IAM_LOGI("**********UseriamUtTest***002***in**********");
83 std::shared_ptr<IInputer> inputer = std::make_shared<InputerUT>();
84 EXPECT_EQ(false, PinAuthRegister::GetInstance().RegisterInputer(inputer));
85 IAM_LOGI("**********UseriamUtTest***002***out**********");
86 }
87
88 /**
89 * @tc.name: UseriamUtTest.UseriamUtTest003
90 * @tc.type: FUNC
91 */
92 HWTEST_F(UseriamUtTest, UseriamUtTest003, TestSize.Level1)
93 {
94 IAM_LOGI("**********UseriamUtTest***003***in**********");
95 PinAuthRegister::GetInstance().UnRegisterInputer();
96 IAM_LOGI("**********UseriamUtTest***003***out**********");
97 }
98 } // namespace PinAuth
99 } // namespace UserIam
100 } // namespace OHOS