• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef OHOS_MOCK_DEATH_RECIPIENT_H
17 #define OHOS_MOCK_DEATH_RECIPIENT_H
18 
19 #include <string>
20 
21 #include <gtest/gtest.h>
22 #include <gmock/gmock.h>
23 #include "ipc_object_proxy.h"
24 
25 namespace OHOS {
26 class MockDeathRecipient : public IRemoteObject::DeathRecipient {
27 public:
28     MockDeathRecipient() = default;
29     ~MockDeathRecipient() = default;
OnRemoteDied(const wptr<IRemoteObject> & object)30     void OnRemoteDied(const wptr<IRemoteObject> &object)
31     {
32         (void)object;
33     }
34 };
35 
36 class MockIPCObjectProxy : public IPCObjectProxy {
37 public:
MockIPCObjectProxy()38     MockIPCObjectProxy() : IPCObjectProxy(1, u"mockProxyService") {};
~MockIPCObjectProxy()39     ~MockIPCObjectProxy() {};
40 
41     MOCK_METHOD0(GetObjectRefCount, int32_t());
42     MOCK_METHOD0(GetSessionName, std::string());
43     MOCK_METHOD0(GetInterfaceDescriptor, std::u16string());
44     MOCK_METHOD1(AddDeathRecipient, bool(const sptr<DeathRecipient> &recipient));
45     MOCK_METHOD1(RemoveDeathRecipient, bool(const sptr<DeathRecipient> &recipient));
46     MOCK_METHOD2(Dump, int(int fd, const std::vector<std::u16string> &args));
47     MOCK_METHOD2(InvokeListenThread, int(MessageParcel &data, MessageParcel &reply));
48     MOCK_METHOD4(SendRequest, int(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option));
49 
50     MOCK_CONST_METHOD0(GetProto, int());
51     MOCK_CONST_METHOD0(IsProxyObject, bool());
52     MOCK_CONST_METHOD0(IsObjectDead, bool());
53     MOCK_CONST_METHOD0(CheckObjectLegality, bool());
54     MOCK_CONST_METHOD0(GetObjectDescriptor, std::u16string());
55     MOCK_CONST_METHOD1(Marshalling, bool(Parcel &parcel));
56 };
57 } // namespace OHOS
58 #endif // OHOS_MOCK_DEATH_RECIPIENT_H
59