• 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 "inputer_get_data_service_test.h"
17 
18 #include "iam_ptr.h"
19 #include "inputer_get_data_service.h"
20 #include "mock_inputer.h"
21 #include "mock_inputer_set_data.h"
22 
23 namespace OHOS {
24 namespace UserIam {
25 namespace PinAuth {
26 using namespace testing;
27 using namespace testing::ext;
28 
SetUpTestCase()29 void InputerGetDataServiceTest::SetUpTestCase()
30 {
31 }
32 
TearDownTestCase()33 void InputerGetDataServiceTest::TearDownTestCase()
34 {
35 }
36 
SetUp()37 void InputerGetDataServiceTest::SetUp()
38 {
39 }
40 
TearDown()41 void InputerGetDataServiceTest::TearDown()
42 {
43 }
44 
45 HWTEST_F(InputerGetDataServiceTest, InputerGetDataServiceTest001, TestSize.Level0)
46 {
47     int32_t testAuthSubType = 10000;
48     std::vector<uint8_t> testSalt = {1, 2, 3, 4, 5};
49     sptr<InputerSetData> testInputerSetData(new (std::nothrow) MockInputerSetData());
50     EXPECT_NE(testInputerSetData, nullptr);
51 
52     auto testInputer = Common::MakeShared<MockInputer>();
53     EXPECT_NE(testInputer, nullptr);
54 
55     EXPECT_CALL(*testInputer, OnGetData(_, _))
56         .Times(Exactly(1))
__anona96e0b530102(int32_t authSubType, std::shared_ptr<IInputerData> inputerData) 57         .WillOnce([&testAuthSubType](int32_t authSubType, std::shared_ptr<IInputerData> inputerData) {
58             EXPECT_EQ(authSubType, testAuthSubType);
59             return;
60         });
61 
62     auto service = Common::MakeShared<InputerGetDataService>(testInputer);
63     EXPECT_NE(service, nullptr);
64 
65     service->OnGetData(testAuthSubType, testSalt, testInputerSetData);
66 }
67 } // namespace PinAuth
68 } // namespace UserIam
69 } // namespace OHOS
70