1 /*
2 * Copyright (c) 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 <gtest/gtest.h>
17
18 #include "object_service_proxy.h"
19 #include "object_callback_impl.h"
20 #include "object_callback_stub.h"
21 #include <ipc_skeleton.h>
22 #include <logger.h>
23 #include "itypes_util.h"
24 #include "log_print.h"
25
26 using namespace testing::ext;
27 using namespace OHOS::DistributedObject;
28 using namespace OHOS::ObjectStore;
29 using namespace std;
30
31 namespace {
32 class ObjectCallbackStubTest : public testing::Test {
33 public:
34 static void SetUpTestCase(void);
35 static void TearDownTestCase(void);
36 void SetUp();
37 void TearDown();
38 };
39
SetUpTestCase(void)40 void ObjectCallbackStubTest::SetUpTestCase(void)
41 {
42 // input testsuit setup step,setup invoked before all testcases
43 }
44
TearDownTestCase(void)45 void ObjectCallbackStubTest::TearDownTestCase(void)
46 {
47 // input testsuit teardown step,teardown invoked after all testcases
48 }
49
SetUp(void)50 void ObjectCallbackStubTest::SetUp(void)
51 {
52 // input testcase setup step,setup invoked before each testcases
53 }
54
TearDown(void)55 void ObjectCallbackStubTest::TearDown(void)
56 {
57 // input testcase teardown step,teardown invoked after each testcases
58 }
59
60 /**
61 * @tc.name: OnRemoteRequest_001
62 * @tc.desc: Abnormal test for OnRemoteRequest, code is 0
63 * @tc.type: FUNC
64 */
65
66 HWTEST_F(ObjectCallbackStubTest, OnRemoteRequest_001, TestSize.Level1)
67 {
68 uint32_t code = 0;
69 OHOS::MessageParcel data;
70 OHOS::MessageParcel reply;
71 OHOS::MessageOption option;
72 const std::function<void(const std::map<std::string, std::vector<uint8_t>> &, bool)> callback;
73 ObjectChangeCallback objectChangeCallback(callback);
74 OHOS::IPCObjectStub objectStub;
75 int ret = objectChangeCallback.OnRemoteRequest(code, data, reply, option);
76 EXPECT_EQ(ret, -1);
77 }
78 }
79