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 MOCK_ACCESSIBLE_ABILITY_CLIENT_STUB_H 17 #define MOCK_ACCESSIBLE_ABILITY_CLIENT_STUB_H 18 19 #include <gtest/gtest.h> 20 #include <gmock/gmock.h> 21 #include <iremote_object.h> 22 #include <iremote_stub.h> 23 #include "accessible_ability_client_interface.h" 24 25 namespace OHOS { 26 namespace Accessibility { 27 class AccessibleAbilityClientStubMock : public IRemoteStub<IAccessibleAbilityClient> { 28 public: 29 DECLARE_INTERFACE_DESCRIPTOR(u"IAccessibleAbilityClientMock"); 30 AccessibleAbilityClientStubMock()31 AccessibleAbilityClientStubMock() : code_(0) 32 {} ~AccessibleAbilityClientStubMock()33 virtual ~AccessibleAbilityClientStubMock() 34 {} 35 36 MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel &, MessageParcel &, MessageOption &)); 37 InvokeSendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)38 int InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 39 { 40 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock InvokeSendRequest"; 41 code_ = code; 42 return NO_ERROR; 43 } 44 InvokeErrorSendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)45 int InvokeErrorSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 46 { 47 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock InvokeErrorSendRequest"; 48 code_ = code; 49 return ERROR; 50 } 51 Init(const sptr<IAccessibleAbilityChannel> & channel,const int channelId)52 virtual void Init(const sptr<IAccessibleAbilityChannel> &channel, const int channelId) 53 { 54 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock Init"; 55 } 56 Disconnect(const int channelId)57 virtual void Disconnect(const int channelId) 58 { 59 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock Disconnect"; 60 } 61 OnAccessibilityEvent(const AccessibilityEventInfo & eventInfo)62 virtual void OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) 63 { 64 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock OnAccessibilityEvent"; 65 } 66 OnKeyPressEvent(const MMI::KeyEvent & keyEvent,const int sequence)67 virtual void OnKeyPressEvent(const MMI::KeyEvent &keyEvent, const int sequence) 68 { 69 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock OnKeyPressEvent"; 70 } 71 OnDisplayResized(const int displayId,const Rect & rect,const float scale,const float centerX,const float centerY)72 virtual void OnDisplayResized(const int displayId, const Rect &rect, const float scale, const float centerX, 73 const float centerY) 74 { 75 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock OnDisplayResized"; 76 } 77 OnGestureSimulateResult(const int sequence,const bool completedSuccessfully)78 virtual void OnGestureSimulateResult(const int sequence, const bool completedSuccessfully) 79 { 80 GTEST_LOG_(INFO) << "MOCK AccessibleAbilityClientStubMock OnGestureSimulateResult"; 81 } 82 83 int code_ = 0; 84 }; 85 } // namespace Accessibility 86 } // namespace OHOS 87 #endif // MOCK_ACCESSIBLE_ABILITY_CLIENT_STUB_H