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#ifndef MESSAGE_PARCEL_MOCK_H 16#define MESSAGE_PARCEL_MOCK_H 17 18#include <memory> 19#include <string> 20#include <gmock/gmock.h> 21 22#include "iremote_broker.h" 23#include "message_parcel.h" 24#include "permission_helper.h" 25#include "pixel_map.h" 26 27namespace OHOS { 28namespace MMI { 29class DfsMessageParcel { 30public: 31 virtual ~DfsMessageParcel() = default; 32public: 33 virtual bool WriteInterfaceToken(std::u16string name) = 0; 34 virtual std::u16string ReadInterfaceToken() = 0; 35 virtual bool WriteInt32(int32_t value) = 0; 36 virtual bool WriteInt64(int64_t value) = 0; 37 virtual int32_t ReadInt32() = 0; 38 virtual bool ReadInt32(int32_t &value) = 0; 39 virtual bool WriteRemoteObject(const Parcelable *object) = 0; 40 virtual bool WriteRemoteObject(const sptr<IRemoteObject> &object) = 0; 41 virtual sptr<IRemoteObject> ReadRemoteObject() = 0; 42 virtual bool ReadBool(); 43 virtual bool ReadBool(bool &value) = 0; 44 virtual bool WriteBool(bool value) = 0; 45 virtual bool WriteString(const std::string &value) = 0; 46 virtual bool WriteCString(const char *value) = 0; 47 virtual bool WriteFileDescriptor(int fd) = 0; 48 virtual std::string ReadString() = 0; 49 virtual bool ReadString(std::string &value) = 0; 50 virtual int ReadFileDescriptor() = 0; 51 virtual bool ReadStringVector(std::vector<std::string> *value) = 0; 52 virtual bool ReadUint32(uint32_t &value) = 0; 53 virtual bool WriteUint64(uint64_t value) = 0; 54 virtual bool WriteUint16(uint16_t value) = 0; 55 virtual bool WriteUint32(uint32_t value) = 0; 56 virtual bool ReadUint64(uint64_t &value) = 0; 57 virtual bool VerifySystemApp() = 0; 58 virtual bool CheckMouseCursor() = 0; 59 virtual bool CheckInputEventFilter() = 0; 60 virtual bool CheckInterceptor() = 0; 61 virtual bool CheckMonitor() = 0; 62 virtual bool CheckDispatchControl() = 0; 63 virtual bool CheckInfraredEmmit() = 0; 64 virtual bool CheckAuthorize() = 0; 65 virtual bool WriteBoolVector(const std::vector<bool> &val) = 0; 66 virtual bool WriteInt32Vector(const std::vector<int32_t> &val) = 0; 67 virtual int64_t ReadInt64() = 0; 68 virtual bool ReadInt64(int64_t &value) = 0; 69 virtual float ReadFloat() = 0; 70 virtual bool ReadFloat(float &value) = 0; 71 virtual double ReadDouble() = 0; 72 virtual bool ReadDouble(double &value) = 0; 73 virtual Media::PixelMap *Unmarshalling(Parcel &parcel) = 0; 74public: 75 static inline std::shared_ptr<DfsMessageParcel> messageParcel = nullptr; 76}; 77 78class MessageParcelMock : public DfsMessageParcel { 79public: 80 MOCK_METHOD1(WriteInterfaceToken, bool(std::u16string name)); 81 MOCK_METHOD0(ReadInterfaceToken, std::u16string()); 82 MOCK_METHOD1(WriteInt32, bool(int32_t value)); 83 MOCK_METHOD1(WriteInt64, bool(int64_t value)); 84 MOCK_METHOD0(ReadInt32, int32_t()); 85 MOCK_METHOD1(ReadInt32, bool(int32_t &value)); 86 MOCK_METHOD1(WriteRemoteObject, bool(const Parcelable *object)); 87 MOCK_METHOD1(WriteRemoteObject, bool(const sptr<IRemoteObject> &object)); 88 MOCK_METHOD0(ReadRemoteObject, sptr<IRemoteObject>()); 89 MOCK_METHOD0(ReadBool, bool()); 90 MOCK_METHOD1(ReadBool, bool(bool &value)); 91 MOCK_METHOD1(WriteBool, bool(bool value)); 92 MOCK_METHOD1(WriteString, bool(const std::string &value)); 93 MOCK_METHOD1(WriteCString, bool(const char *value)); 94 MOCK_METHOD1(WriteFileDescriptor, bool(int fd)); 95 MOCK_METHOD0(ReadString, std::string()); 96 MOCK_METHOD1(ReadString, bool(std::string &value)); 97 MOCK_METHOD0(ReadFileDescriptor, int()); 98 MOCK_METHOD1(ReadStringVector, bool(std::vector<std::string> *value)); 99 MOCK_METHOD1(ReadUint32, bool(uint32_t &value)); 100 MOCK_METHOD1(WriteUint64, bool(uint64_t value)); 101 MOCK_METHOD1(WriteUint16, bool(uint16_t value)); 102 MOCK_METHOD1(WriteUint32, bool(uint32_t value)); 103 MOCK_METHOD1(ReadUint64, bool(uint64_t &value)); 104 MOCK_METHOD0(VerifySystemApp, bool()); 105 MOCK_METHOD0(CheckMouseCursor, bool()); 106 MOCK_METHOD0(CheckInputEventFilter, bool()); 107 MOCK_METHOD0(CheckInterceptor, bool()); 108 MOCK_METHOD0(CheckMonitor, bool()); 109 MOCK_METHOD0(CheckDispatchControl, bool()); 110 MOCK_METHOD0(CheckInfraredEmmit, bool()); 111 MOCK_METHOD0(CheckAuthorize, bool()); 112 MOCK_METHOD1(WriteBoolVector, bool(const std::vector<bool> &val)); 113 MOCK_METHOD1(WriteInt32Vector, bool(const std::vector<int32_t> &val)); 114 MOCK_METHOD0(ReadInt64, int64_t()); 115 MOCK_METHOD1(ReadInt64, bool(int64_t &value)); 116 MOCK_METHOD0(ReadFloat, float()); 117 MOCK_METHOD1(ReadFloat, bool(float &value)); 118 MOCK_METHOD0(ReadDouble, double()); 119 MOCK_METHOD1(ReadDouble, bool(double &value)); 120 MOCK_METHOD1(Unmarshalling, Media::PixelMap *(Parcel &parcel)); 121}; 122} // namespace MMI 123} // namespace OHOS 124#endif