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 #ifndef OHOS_ROSEN_TEST_COMMON_MOCK_IREMOTE_OBJECT_MOCKER 17 #define OHOS_ROSEN_TEST_COMMON_MOCK_IREMOTE_OBJECT_MOCKER 18 19 #include <iremote_object.h> 20 21 namespace OHOS { 22 namespace Rosen { 23 class IRemoteObjectMocker : public IRemoteObject { 24 public: IRemoteObjectMocker()25 IRemoteObjectMocker() : IRemoteObject {u"IRemoteObjectMocker"} 26 { 27 } 28 ~IRemoteObjectMocker()29 ~IRemoteObjectMocker() 30 { 31 } 32 GetObjectRefCount()33 int32_t GetObjectRefCount() 34 { 35 return 0; 36 } 37 SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)38 int SendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) 39 { 40 return 0; 41 } 42 IsProxyObject()43 bool IsProxyObject() const 44 { 45 return true; 46 } 47 CheckObjectLegality()48 bool CheckObjectLegality() const 49 { 50 return true; 51 } 52 AddDeathRecipient(const sptr<DeathRecipient> & recipient)53 bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) 54 { 55 return true; 56 } 57 RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)58 bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) 59 { 60 return true; 61 } 62 AsInterface()63 sptr<IRemoteBroker> AsInterface() 64 { 65 return nullptr; 66 } 67 Dump(int fd,const std::vector<std::u16string> & args)68 int Dump(int fd, const std::vector<std::u16string> &args) 69 { 70 return 0; 71 } 72 }; 73 class MockIRemoteObject : public IRemoteObject { 74 public: MockIRemoteObject()75 MockIRemoteObject() : IRemoteObject {u"MockIRemoteObject"} 76 { 77 } 78 ~MockIRemoteObject()79 ~MockIRemoteObject() 80 { 81 } 82 GetObjectRefCount()83 int32_t GetObjectRefCount() 84 { 85 return 0; 86 } 87 SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)88 int SendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) 89 { 90 return sendRequestResult_; 91 } 92 IsProxyObject()93 bool IsProxyObject() const 94 { 95 return true; 96 } 97 CheckObjectLegality()98 bool CheckObjectLegality() const 99 { 100 return true; 101 } 102 AddDeathRecipient(const sptr<DeathRecipient> & recipient)103 bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) 104 { 105 return true; 106 } 107 RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)108 bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) 109 { 110 return true; 111 } 112 AsInterface()113 sptr<IRemoteBroker> AsInterface() 114 { 115 return nullptr; 116 } 117 Dump(int fd,const std::vector<std::u16string> & args)118 int Dump(int fd, const std::vector<std::u16string> &args) 119 { 120 return 0; 121 } 122 SetRequestResult(int result)123 void SetRequestResult(int result) 124 { 125 sendRequestResult_ = result; 126 } 127 128 int sendRequestResult_ = 0; 129 int count_ = 0; 130 }; 131 } 132 } 133 134 #endif