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 <gtest/gtest.h>
17 #include <gmock/gmock.h>
18 
19 #define private public
20 #include "ipc_object_proxy.h"
21 #undef private
22 
23 using namespace testing::ext;
24 using namespace OHOS;
25 
26 class IRemoteObjectTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29     static void TearDownTestCase(void);
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase()34 void IRemoteObjectTest::SetUpTestCase()
35 {
36 }
37 
TearDownTestCase()38 void IRemoteObjectTest::TearDownTestCase()
39 {
40 }
41 
SetUp()42 void IRemoteObjectTest::SetUp()
43 {
44 }
45 
TearDown()46 void IRemoteObjectTest::TearDown()
47 {
48 }
49 
50 /**
51  * @tc.name: CheckObjectLegalityTest001
52  * @tc.desc: Verify the IRemoteObject::CheckObjectLegality function
53  * @tc.type: FUNC
54  */
55 HWTEST_F(IRemoteObjectTest, CheckObjectLegalityTest001, TestSize.Level1)
56 {
57     IPCObjectProxy object(1);
58 
59     auto ret = object.CheckObjectLegality();
60     ASSERT_FALSE(ret);
61 }
62 
63 /**
64  * @tc.name: IsObjectDeadTest001
65  * @tc.desc: Verify the IRemoteObject::IsObjectDead function
66  * @tc.type: FUNC
67  */
68 HWTEST_F(IRemoteObjectTest, IsObjectDeadTest001, TestSize.Level1)
69 {
70     sptr<IRemoteObject> object = new IPCObjectProxy(16);
71 
72     auto ret = object->IsObjectDead();
73     ASSERT_FALSE(ret);
74 }
75 
76 /**
77  * @tc.name: GetInterfaceDescriptorTest001
78  * @tc.desc: Verify the IRemoteObject::GetInterfaceDescriptor function
79  * @tc.type: FUNC
80  */
81 HWTEST_F(IRemoteObjectTest, GetInterfaceDescriptorTest001, TestSize.Level1)
82 {
83     sptr<IRemoteObject> object = new IPCObjectProxy(0);
84 
85     EXPECT_EQ(object->descriptor_, object->GetInterfaceDescriptor());
86 }
87