• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "pinauth_log_wrapper.h"
20 #include "pinauth_register.h"
21 #include "i_inputer.h"
22 #include "hilog/log.h"
23 
24 using namespace testing::ext;
25 namespace OHOS {
26 namespace UserIAM {
27 namespace PinAuth {
28 class UseriamUtTest : public testing::Test {
29 public:
30     static void SetUpTestCase(void);
31 
32     static void TearDownTestCase(void);
33 
34     void SetUp();
35 
36     void TearDown();
37 };
38 class InputerUT : public IInputer {
39 public:
OnGetData(int32_t authSubType,std::shared_ptr<IInputerData> inputerData)40     void OnGetData(int32_t authSubType, std::shared_ptr<IInputerData> inputerData)override {}
41     virtual ~InputerUT()=default;
42 };
43 
SetUpTestCase(void)44 void UseriamUtTest::SetUpTestCase(void)
45 {
46 }
47 
TearDownTestCase(void)48 void UseriamUtTest::TearDownTestCase(void)
49 {
50 }
51 
SetUp()52 void UseriamUtTest::SetUp()
53 {
54 }
55 
TearDown()56 void UseriamUtTest::TearDown()
57 {
58 }
59 /**
60  * @tc.cpp: /interfaces/innerkits/src/piuauth_innerkits/src/pinauth_register.cpp
61  */
62 
63 /**
64  * @tc.name: UseriamUtTest.UseriamUtTest_001
65  * @tc.type: FUNC
66  */
67 HWTEST_F(UseriamUtTest, UseriamUtTest_001, TestSize.Level1)
68 {
69     PINAUTH_HILOGE(MODULE_COMMON, "**********UseriamUtTest***001***in**********");
70     std::shared_ptr<IInputer> inputer = nullptr;
71     EXPECT_EQ(false, PinAuthRegister::GetInstance().RegisterInputer(inputer));
72     PINAUTH_HILOGE(MODULE_COMMON, "**********UseriamUtTest***001***out**********");
73 }
74 
75 /**
76  * @tc.name: UseriamUtTest.UseriamUtTest_002
77  * @tc.type: FUNC
78  */
79 HWTEST_F(UseriamUtTest, UseriamUtTest_002, TestSize.Level1)
80 {
81     PINAUTH_HILOGE(MODULE_COMMON, "**********UseriamUtTest***002***in**********");
82     std::shared_ptr<IInputer> inputer = std::make_shared<InputerUT>();
83     EXPECT_EQ(false, PinAuthRegister::GetInstance().RegisterInputer(inputer));
84     PINAUTH_HILOGE(MODULE_COMMON, "**********UseriamUtTest***002***out**********");
85 }
86 
87 /**
88  * @tc.name: UseriamUtTest.UseriamUtTest_003
89  * @tc.type: FUNC
90  */
91 HWTEST_F(UseriamUtTest, UseriamUtTest_003, TestSize.Level1)
92 {
93     PINAUTH_HILOGE(MODULE_COMMON, "**********UseriamUtTest***003***in**********");
94     PinAuthRegister::GetInstance().UnRegisterInputer();
95     PINAUTH_HILOGE(MODULE_COMMON, "**********UseriamUtTest***003***out**********");
96 }
97 } // namespace PinAuth
98 } // namespace UserIAM
99 } // namespace OHOS