1 /*
2  * Copyright (c) 2022-2024 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 "services_inputer_data_impl_test.h"
17 
18 #include <openssl/sha.h>
19 
20 #include "iam_ptr.h"
21 #include "i_inputer_data_impl.h"
22 #include "mock_iall_in_one_executor.h"
23 #include "mock_icollector_executor.h"
24 #include "mock_inputer_set_data.h"
25 #include "pin_auth_all_in_one_hdi.h"
26 #include "pin_auth_collector_hdi.h"
27 
28 namespace OHOS {
29 namespace UserIam {
30 namespace PinAuth {
31 using namespace testing;
32 using namespace testing::ext;
33 
SetUpTestCase()34 void ServicesInputerDataImplTest::SetUpTestCase()
35 {
36 }
37 
TearDownTestCase()38 void ServicesInputerDataImplTest::TearDownTestCase()
39 {
40 }
41 
SetUp()42 void ServicesInputerDataImplTest::SetUp()
43 {
44 }
45 
TearDown()46 void ServicesInputerDataImplTest::TearDown()
47 {
48 }
49 
50 HWTEST_F(ServicesInputerDataImplTest, ServicesInputerDataImplEnrollTest001, TestSize.Level0)
51 {
52     std::vector<uint8_t> data = {1, 2, 3, 4, 5};
53     std::shared_ptr<PinAuthAllInOneHdi> allInOnePtr = std::make_shared<PinAuthAllInOneHdi>(nullptr);
54     IInputerDataImpl inputerDataImpl(1, allInOnePtr);
55     int32_t authSubType = 10000;
56     EXPECT_NO_THROW(inputerDataImpl.OnSetData(authSubType, data, 0));
57 }
58 
59 HWTEST_F(ServicesInputerDataImplTest, ServicesInputerDataImplEnrollTest002, TestSize.Level0)
60 {
61     auto allInOneProxy = new (std::nothrow) MockIAllInOneExecutor();
62     ASSERT_TRUE(allInOneProxy != nullptr);
63     std::vector<uint8_t> data = {1, 2, 3, 4, 5};
64     std::shared_ptr<PinAuthAllInOneHdi> allInOnePtr = std::make_shared<PinAuthAllInOneHdi>(allInOneProxy);
65     IInputerDataImpl inputerDataImpl(1, allInOnePtr);
66     int32_t authSubType = 10000;
67     EXPECT_NO_THROW(inputerDataImpl.OnSetData(authSubType, data, 0));
68 }
69 
70 HWTEST_F(ServicesInputerDataImplTest, ServicesInputerDataImplEnrollTest003, TestSize.Level0)
71 {
72     std::vector<uint8_t> data = {1, 2, 3, 4, 5};
73     auto collectProxy = new (std::nothrow) MockICollectorExecutor();
74     ASSERT_TRUE(collectProxy != nullptr);
75     std::shared_ptr<PinAuthCollectorHdi> collectorPtr = std::make_shared<PinAuthCollectorHdi>(collectProxy);
76     IInputerDataImpl collectInputerDataImpl(1, collectorPtr);
77     int32_t authSubType = 10000;
78     EXPECT_NO_THROW(collectInputerDataImpl.OnSetData(authSubType, data, 0));
79 }
80 
81 HWTEST_F(ServicesInputerDataImplTest, ServicesInputerDataImplEnrollTest004, TestSize.Level0)
82 {
83     std::vector<uint8_t> data = {1, 2, 3, 4, 5};
84     auto collectProxy = new (std::nothrow) MockICollectorExecutor();
85     ASSERT_TRUE(collectProxy != nullptr);
86     std::shared_ptr<PinAuthCollectorHdi> collectorPtr = std::make_shared<PinAuthCollectorHdi>(collectProxy);
87     IInputerDataImpl *collectInputerDataImpl = new IInputerDataImpl(1, collectorPtr);
88     EXPECT_NO_THROW(delete collectInputerDataImpl);
89 }
90 } // namespace PinAuth
91 } // namespace UserIam
92 } // namespace OHOS
93