1 /* 2 * Copyright (c) 2021 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 MOCK_STORAGE_MANAGER_SERVICE_H 16 #define MOCK_STORAGE_MANAGER_SERVICE_H 17 18 #include "gmock/gmock.h" 19 #include "iremote_stub.h" 20 #include "istorage_manager.h" 21 #include "storage_service_errno.h" 22 23 namespace OHOS { 24 namespace StorageManager { 25 class StorageManagerServiceMock : public IRemoteStub<IStorageManager> { 26 public: 27 int code_ = 0; StorageManagerServiceMock()28 StorageManagerServiceMock() : code_(0) {} ~StorageManagerServiceMock()29 virtual ~StorageManagerServiceMock() {} 30 31 MOCK_METHOD4(SendRequest, int(uint32_t, MessageParcel &, MessageParcel &, MessageOption &)); InvokeSendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)32 int32_t InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 33 { 34 code_ = code; 35 return E_OK; 36 } 37 PrepareAddUser(int32_t userId,uint32_t flags)38 virtual int32_t PrepareAddUser(int32_t userId, uint32_t flags) override 39 { 40 return E_OK; 41 } 42 RemoveUser(int32_t userId,uint32_t flags)43 virtual int32_t RemoveUser(int32_t userId, uint32_t flags) override 44 { 45 return E_OK; 46 } 47 PrepareStartUser(int32_t userId)48 virtual int32_t PrepareStartUser(int32_t userId) override 49 { 50 return E_OK; 51 } 52 StopUser(int32_t userId)53 virtual int32_t StopUser(int32_t userId) override 54 { 55 return E_OK; 56 } 57 GetFreeSizeOfVolume(std::string volumeUuid,int64_t & freeSize)58 virtual int32_t GetFreeSizeOfVolume(std::string volumeUuid, int64_t &freeSize) override 59 { 60 return E_OK; 61 } 62 GetTotalSizeOfVolume(std::string volumeUuid,int64_t & totalSize)63 virtual int32_t GetTotalSizeOfVolume(std::string volumeUuid, int64_t &totalSize) override 64 { 65 return E_OK; 66 } 67 GetBundleStats(std::string pkgName,BundleStats & bundleStats)68 virtual int32_t GetBundleStats(std::string pkgName, BundleStats &bundleStats) override 69 { 70 return E_OK; 71 } 72 GetSystemSize(int64_t & systemSize)73 virtual int32_t GetSystemSize(int64_t &systemSize) override 74 { 75 return E_OK; 76 } 77 GetTotalSize(int64_t & totalSize)78 virtual int32_t GetTotalSize(int64_t &totalSize) override 79 { 80 return E_OK; 81 } 82 GetFreeSize(int64_t & freeSize)83 virtual int32_t GetFreeSize(int64_t &freeSize) override 84 { 85 return E_OK; 86 } 87 GetUserStorageStats(StorageStats & storageStats)88 virtual int32_t GetUserStorageStats(StorageStats &storageStats) override 89 { 90 return E_OK; 91 } 92 GetUserStorageStats(int32_t userId,StorageStats & storageStats)93 virtual int32_t GetUserStorageStats(int32_t userId, StorageStats &storageStats) override 94 { 95 return E_OK; 96 } 97 GetCurrentBundleStats(BundleStats & bundleStats)98 virtual int32_t GetCurrentBundleStats(BundleStats &bundleStats) override 99 { 100 return E_OK; 101 } 102 NotifyVolumeCreated(VolumeCore vc)103 virtual int32_t NotifyVolumeCreated(VolumeCore vc) override 104 { 105 return E_OK; 106 } 107 NotifyVolumeMounted(std::string volumeId,int fsType,std::string fsUuid,std::string path,std::string description)108 virtual int32_t NotifyVolumeMounted(std::string volumeId, int fsType, std::string fsUuid, 109 std::string path, std::string description) override 110 { 111 return E_OK; 112 } 113 NotifyVolumeDestroyed(std::string volumeId)114 virtual int32_t NotifyVolumeDestroyed(std::string volumeId) override 115 { 116 return E_OK; 117 } 118 Mount(std::string volumeId)119 virtual int32_t Mount(std::string volumeId) override 120 { 121 return E_OK; 122 } 123 Unmount(std::string volumeId)124 virtual int32_t Unmount(std::string volumeId) override 125 { 126 return E_OK; 127 } 128 GetAllVolumes(std::vector<VolumeExternal> & vecOfVol)129 virtual int32_t GetAllVolumes(std::vector<VolumeExternal> &vecOfVol) override 130 { 131 return E_OK; 132 } 133 NotifyDiskCreated(Disk disk)134 virtual int32_t NotifyDiskCreated(Disk disk) override 135 { 136 return E_OK; 137 } 138 NotifyDiskDestroyed(std::string diskId)139 virtual int32_t NotifyDiskDestroyed(std::string diskId) override 140 { 141 return E_OK; 142 } 143 Partition(std::string diskId,int32_t type)144 virtual int32_t Partition(std::string diskId, int32_t type) override 145 { 146 return E_OK; 147 } 148 GetAllDisks(std::vector<Disk> & vecOfDisk)149 virtual int32_t GetAllDisks(std::vector<Disk> &vecOfDisk) override 150 { 151 return E_OK; 152 } 153 GetVolumeByUuid(std::string fsUuid,VolumeExternal & vc)154 virtual int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc) override 155 { 156 return E_OK; 157 } 158 GetVolumeById(std::string volumeId,VolumeExternal & vc)159 virtual int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc) override 160 { 161 return E_OK; 162 } 163 SetVolumeDescription(std::string fsUuid,std::string description)164 virtual int32_t SetVolumeDescription(std::string fsUuid, std::string description) override 165 { 166 return E_OK; 167 } 168 Format(std::string volumeId,std::string fsType)169 virtual int32_t Format(std::string volumeId, std::string fsType) override 170 { 171 return E_OK; 172 } 173 GetDiskById(std::string diskId,Disk & disk)174 virtual int32_t GetDiskById(std::string diskId, Disk &disk) override 175 { 176 return E_OK; 177 } 178 GenerateUserKeys(uint32_t userId,uint32_t flags)179 virtual int32_t GenerateUserKeys(uint32_t userId, uint32_t flags) override 180 { 181 return E_OK; 182 } 183 DeleteUserKeys(uint32_t userId)184 virtual int32_t DeleteUserKeys(uint32_t userId) override 185 { 186 return E_OK; 187 } 188 UpdateUserAuth(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & oldSecret,const std::vector<uint8_t> & newSecret)189 virtual int32_t UpdateUserAuth(uint32_t userId, 190 const std::vector<uint8_t> &token, 191 const std::vector<uint8_t> &oldSecret, 192 const std::vector<uint8_t> &newSecret) override 193 { 194 return E_OK; 195 } 196 ActiveUserKey(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)197 virtual int32_t ActiveUserKey(uint32_t userId, 198 const std::vector<uint8_t> &token, 199 const std::vector<uint8_t> &secret) override 200 { 201 return E_OK; 202 } 203 InactiveUserKey(uint32_t userId)204 virtual int32_t InactiveUserKey(uint32_t userId) override 205 { 206 return E_OK; 207 } 208 UpdateKeyContext(uint32_t userId)209 virtual int32_t UpdateKeyContext(uint32_t userId) override 210 { 211 return E_OK; 212 } 213 CreateShareFile(std::string uri,int32_t tokenId,int32_t flag)214 virtual int32_t CreateShareFile(std::string uri, int32_t tokenId, int32_t flag) override 215 { 216 return E_OK; 217 } 218 DeleteShareFile(int32_t tokenId,std::vector<std::string> sharePathList)219 virtual int32_t DeleteShareFile(int32_t tokenId, std::vector<std::string>sharePathList) override 220 { 221 return E_OK; 222 } 223 }; 224 } // namespace StorageManager 225 } // namespace OHOS 226 #endif // MOCK_STORAGE_MANAGER_SERVICE_H