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