1 /*
2 * Copyright (C) 2023 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 "widget_callback_proxy_test.h"
17
18 #include "iam_ptr.h"
19 #include "mock_remote_object.h"
20 #include "widget_callback_proxy.h"
21 #include "user_auth_interface.h"
22
23 namespace OHOS {
24 namespace UserIam {
25 namespace UserAuth {
26 using namespace testing;
27 using namespace testing::ext;
28
SetUpTestCase()29 void WidgetCallbackProxyTest::SetUpTestCase()
30 {
31 }
32
TearDownTestCase()33 void WidgetCallbackProxyTest::TearDownTestCase()
34 {
35 }
36
SetUp()37 void WidgetCallbackProxyTest::SetUp()
38 {
39 }
40
TearDown()41 void WidgetCallbackProxyTest::TearDown()
42 {
43 }
44
45 HWTEST_F(WidgetCallbackProxyTest, WidgetCallbackStubOnRemoteRequest001, TestSize.Level0)
46 {
47 sptr<MockRemoteObject> obj(new (std::nothrow) MockRemoteObject());
48 EXPECT_NE(obj, nullptr);
49 EXPECT_CALL(*obj, SendRequest(_, _, _, _))
50 .WillOnce(
__anonb5affd760102(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 51 [](uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) {
52 EXPECT_EQ(code, UserAuthInterfaceCode::USER_AUTH_ON_SEND_COMMAND);
53 return OHOS::NO_ERROR;
54 }
55 );
56
57 auto proxy = Common::MakeShared<WidgetCallbackProxy>(obj);
58 EXPECT_NE(proxy, nullptr);
59
60 std::string cmdData = "cmd";
61 proxy->SendCommand(cmdData);
62 }
63 } // namespace UserAuth
64 } // namespace UserIam
65 } // namespace OHOS