1cb7eb8c9Sopenharmony_ci/* 2cb7eb8c9Sopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd. 3cb7eb8c9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4cb7eb8c9Sopenharmony_ci * you may not use this file except in compliance with the License. 5cb7eb8c9Sopenharmony_ci * You may obtain a copy of the License at 6cb7eb8c9Sopenharmony_ci * 7cb7eb8c9Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8cb7eb8c9Sopenharmony_ci * 9cb7eb8c9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10cb7eb8c9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11cb7eb8c9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12cb7eb8c9Sopenharmony_ci * See the License for the specific language governing permissions and 13cb7eb8c9Sopenharmony_ci * limitations under the License. 14cb7eb8c9Sopenharmony_ci */ 15cb7eb8c9Sopenharmony_ci#ifndef OHOS_DFS_SERVICE_MESSAGE_PARCEL_MOCK_H 16cb7eb8c9Sopenharmony_ci#define OHOS_DFS_SERVICE_MESSAGE_PARCEL_MOCK_H 17cb7eb8c9Sopenharmony_ci 18cb7eb8c9Sopenharmony_ci#include <memory> 19cb7eb8c9Sopenharmony_ci#include <string> 20cb7eb8c9Sopenharmony_ci#include <gmock/gmock.h> 21cb7eb8c9Sopenharmony_ci 22cb7eb8c9Sopenharmony_ci#include "message_parcel.h" 23cb7eb8c9Sopenharmony_ci#include "iremote_broker.h" 24cb7eb8c9Sopenharmony_ci 25cb7eb8c9Sopenharmony_cinamespace OHOS::Storage::DistributedFile { 26cb7eb8c9Sopenharmony_ciclass DfsMessageParcel { 27cb7eb8c9Sopenharmony_cipublic: 28cb7eb8c9Sopenharmony_ci virtual ~DfsMessageParcel() = default; 29cb7eb8c9Sopenharmony_cipublic: 30cb7eb8c9Sopenharmony_ci virtual bool WriteInterfaceToken(std::u16string name) = 0; 31cb7eb8c9Sopenharmony_ci virtual std::u16string ReadInterfaceToken() = 0; 32cb7eb8c9Sopenharmony_ci virtual bool WriteParcelable(const Parcelable *object) = 0; 33cb7eb8c9Sopenharmony_ci virtual bool WriteInt32(int32_t value) = 0; 34cb7eb8c9Sopenharmony_ci virtual int32_t ReadInt32() = 0; 35cb7eb8c9Sopenharmony_ci virtual bool ReadInt32(int32_t &value) = 0; 36cb7eb8c9Sopenharmony_ci virtual bool WriteRemoteObject(const Parcelable *object) = 0; 37cb7eb8c9Sopenharmony_ci virtual bool WriteRemoteObject(const sptr<IRemoteObject> &object) = 0; 38cb7eb8c9Sopenharmony_ci virtual sptr<IRemoteObject> ReadRemoteObject() = 0; 39cb7eb8c9Sopenharmony_ci virtual bool ReadBool(); 40cb7eb8c9Sopenharmony_ci virtual bool ReadBool(bool &value) = 0; 41cb7eb8c9Sopenharmony_ci virtual bool WriteBool(bool value) = 0; 42cb7eb8c9Sopenharmony_ci virtual bool WriteString(const std::string &value) = 0; 43cb7eb8c9Sopenharmony_ci virtual bool WriteCString(const char *value) = 0; 44cb7eb8c9Sopenharmony_ci virtual bool WriteFileDescriptor(int fd) = 0; 45cb7eb8c9Sopenharmony_ci virtual bool ReadString(std::string &value) = 0; 46cb7eb8c9Sopenharmony_ci virtual int ReadFileDescriptor() = 0; 47cb7eb8c9Sopenharmony_ci virtual bool ReadStringVector(std::vector<std::string> *value) = 0; 48cb7eb8c9Sopenharmony_ci virtual bool ReadUint32(uint32_t &value) = 0; 49cb7eb8c9Sopenharmony_ci virtual bool WriteUint64(uint64_t value) = 0; 50cb7eb8c9Sopenharmony_ci virtual bool WriteUint16(uint16_t value) = 0; 51cb7eb8c9Sopenharmony_ci virtual bool ReadUint64(uint64_t &value) = 0; 52cb7eb8c9Sopenharmony_ci virtual bool WriteStringVector(const std::vector<std::string> &val) = 0; 53cb7eb8c9Sopenharmony_cipublic: 54cb7eb8c9Sopenharmony_ci static inline std::shared_ptr<DfsMessageParcel> messageParcel = nullptr; 55cb7eb8c9Sopenharmony_ci}; 56cb7eb8c9Sopenharmony_ci 57cb7eb8c9Sopenharmony_ciclass MessageParcelMock : public DfsMessageParcel { 58cb7eb8c9Sopenharmony_cipublic: 59cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteInterfaceToken, bool(std::u16string name)); 60cb7eb8c9Sopenharmony_ci MOCK_METHOD0(ReadInterfaceToken, std::u16string()); 61cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteParcelable, bool(const Parcelable *object)); 62cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteInt32, bool(int32_t value)); 63cb7eb8c9Sopenharmony_ci MOCK_METHOD0(ReadInt32, int32_t()); 64cb7eb8c9Sopenharmony_ci MOCK_METHOD1(ReadInt32, bool(int32_t &value)); 65cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteRemoteObject, bool(const Parcelable *object)); 66cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteRemoteObject, bool(const sptr<IRemoteObject> &object)); 67cb7eb8c9Sopenharmony_ci MOCK_METHOD0(ReadRemoteObject, sptr<IRemoteObject>()); 68cb7eb8c9Sopenharmony_ci MOCK_METHOD0(ReadBool, bool()); 69cb7eb8c9Sopenharmony_ci MOCK_METHOD1(ReadBool, bool(bool &value)); 70cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteBool, bool(bool value)); 71cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteString, bool(const std::string &value)); 72cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteCString, bool(const char *value)); 73cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteFileDescriptor, bool(int fd)); 74cb7eb8c9Sopenharmony_ci MOCK_METHOD1(ReadString, bool(std::string &value)); 75cb7eb8c9Sopenharmony_ci MOCK_METHOD0(ReadFileDescriptor, int()); 76cb7eb8c9Sopenharmony_ci MOCK_METHOD1(ReadStringVector, bool(std::vector<std::string> *value)); 77cb7eb8c9Sopenharmony_ci MOCK_METHOD1(ReadUint32, bool(uint32_t &value)); 78cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteUint64, bool(uint64_t value)); 79cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteUint16, bool(uint16_t value)); 80cb7eb8c9Sopenharmony_ci MOCK_METHOD1(ReadUint64, bool(uint64_t &value)); 81cb7eb8c9Sopenharmony_ci MOCK_METHOD1(WriteStringVector, bool(const std::vector<std::string> &val)); 82cb7eb8c9Sopenharmony_ci}; 83cb7eb8c9Sopenharmony_ci} 84cb7eb8c9Sopenharmony_ci#endif