• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 MOCK_OHOS_IPC_IREMOTE_OBJECT_H
17 #define MOCK_OHOS_IPC_IREMOTE_OBJECT_H
18 
19 #include "parcel.h"
20 #include "refbase.h"
21 #include "oh_mock_utils.h"
22 
23 namespace OHOS {
24 class IRemoteBroker;
25 class IRemoteObject : public virtual Parcelable, public virtual RefBase {
26 public:
27     enum {
28         IF_PROT_DEFAULT,
29         IF_PROT_BINDER = IF_PROT_DEFAULT,
30         IF_PROT_DATABUS,
31         IF_PROT_ERROR,
32     };
33     enum {
34         DATABUS_TYPE,
35     };
36     class DeathRecipient : public virtual RefBase {
37     public:
38         enum {
39             ADD_DEATH_RECIPIENT,
40             REMOVE_DEATH_RECIPIENT,
41             NOTICE_DEATH_RECIPIENT,
42             TEST_SERVICE_DEATH_RECIPIENT,
43             TEST_DEVICE_DEATH_RECIPIENT,
44         };
OnRemoteDied(const wptr<IRemoteObject> & object)45         virtual void OnRemoteDied(const wptr<IRemoteObject> &object) {}
46     };
47 
GetInterfaceDescriptor()48     virtual std::u16string GetInterfaceDescriptor()
49     {
50         return u"";
51     }
52 
53     OH_MOCK_METHOD_WITH_DECORATOR(virtual, bool, IRemoteObject, IsProxyObject);
54     OH_MOCK_METHOD_WITH_DECORATOR(virtual, bool, IRemoteObject, AddDeathRecipient, const sptr<DeathRecipient> &);
55 
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)56     virtual bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient)
57     {
58         return false;
59     }
60 
Marshalling(Parcel & parcel)61     virtual bool Marshalling(Parcel &parcel) const override
62     {
63         return false;
64     }
65 
Unmarshalling(Parcel & parcel)66     static sptr<IRemoteObject> Unmarshalling(Parcel &parcel)
67     {
68         return nullptr;
69     }
70 
Marshalling(Parcel & parcel,const sptr<IRemoteObject> & object)71     static bool Marshalling(Parcel &parcel, const sptr<IRemoteObject> &object)
72     {
73         return false;
74     }
75 
AsInterface()76     virtual sptr<IRemoteBroker> AsInterface()
77     {
78         return nullptr;
79     }
80 
GetObjectDescriptor()81     std::u16string GetObjectDescriptor() const
82     {
83         return u"";
84     }
85 };
86 } // namespace OHOS
87 #endif