• 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_set_data_proxy_test.h"
17 
18 #include "iam_common_defines.h"
19 #include "iam_ptr.h"
20 #include "inputer_set_data_proxy.h"
21 #include "mock_inputer_data_impl.h"
22 #include "mock_remote_object.h"
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace PinAuth {
27 using namespace testing;
28 using namespace testing::ext;
29 
SetUpTestCase()30 void InputerSetDataProxyTest::SetUpTestCase()
31 {
32 }
33 
TearDownTestCase()34 void InputerSetDataProxyTest::TearDownTestCase()
35 {
36 }
37 
SetUp()38 void InputerSetDataProxyTest::SetUp()
39 {
40 }
41 
TearDown()42 void InputerSetDataProxyTest::TearDown()
43 {
44 }
45 
46 HWTEST_F(InputerSetDataProxyTest, InputerSetDataProxyTest, TestSize.Level0)
47 {
48     int32_t testAuthSubType = 10000;
49     std::vector<uint8_t> testSalt = {1, 2, 3, 4, 5, 6};
50     sptr<MockRemoteObject> obj(new (std::nothrow) MockRemoteObject());
51     EXPECT_NE(obj, nullptr);
52     auto proxy = Common::MakeShared<InputerSetDataProxy>(obj);
53     EXPECT_NE(proxy, nullptr);
54 
55     auto service = Common::MakeShared<MockInputerDataImpl>();
56     EXPECT_NE(service, nullptr);
57     EXPECT_CALL(*service, OnSetData(_, _))
58         .Times(Exactly(1))
__anone1b1a4910102(int32_t authSubType, std::vector<uint8_t> data) 59         .WillOnce([&testAuthSubType](int32_t authSubType, std::vector<uint8_t> data) {
60             EXPECT_EQ(authSubType, testAuthSubType);
61             EXPECT_THAT(data, ElementsAre(1, 2, 3, 4, 5, 6));
62             return;
63         });
64     EXPECT_CALL(*obj, SendRequest(_, _, _, _)).Times(1);
65     ON_CALL(*obj, SendRequest)
__anone1b1a4910202(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 66         .WillByDefault([&service](uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) {
67             return service->OnRemoteRequest(code, data, reply, option);
68         });
69     proxy->OnSetData(testAuthSubType, testSalt);
70 }
71 } // namespace PinAuth
72 } // namespace UserIam
73 } // namespace OHOS
74