1 /* 2 * Copyright (c) 2021-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 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 CompleteAddUser(int32_t userId)58 virtual int32_t CompleteAddUser(int32_t userId) override 59 { 60 return E_OK; 61 } 62 GetFreeSizeOfVolume(std::string volumeUuid,int64_t & freeSize)63 virtual int32_t GetFreeSizeOfVolume(std::string volumeUuid, int64_t &freeSize) override 64 { 65 return E_OK; 66 } 67 GetTotalSizeOfVolume(std::string volumeUuid,int64_t & totalSize)68 virtual int32_t GetTotalSizeOfVolume(std::string volumeUuid, int64_t &totalSize) override 69 { 70 return E_OK; 71 } 72 GetBundleStats(std::string pkgName,BundleStats & bundleStats,int32_t appIndex,uint32_t statFlag)73 virtual int32_t GetBundleStats(std::string pkgName, BundleStats &bundleStats, 74 int32_t appIndex, uint32_t statFlag) override 75 { 76 return E_OK; 77 } 78 GetSystemSize(int64_t & systemSize)79 virtual int32_t GetSystemSize(int64_t &systemSize) override 80 { 81 return E_OK; 82 } 83 GetTotalSize(int64_t & totalSize)84 virtual int32_t GetTotalSize(int64_t &totalSize) override 85 { 86 return E_OK; 87 } 88 GetFreeSize(int64_t & freeSize)89 virtual int32_t GetFreeSize(int64_t &freeSize) override 90 { 91 return E_OK; 92 } 93 GetUserStorageStats(StorageStats & storageStats)94 virtual int32_t GetUserStorageStats(StorageStats &storageStats) override 95 { 96 return E_OK; 97 } 98 GetUserStorageStats(int32_t userId,StorageStats & storageStats)99 virtual int32_t GetUserStorageStats(int32_t userId, StorageStats &storageStats) override 100 { 101 return E_OK; 102 } 103 GetUserStorageStatsByType(int32_t userId,StorageStats & storageStats,std::string type)104 virtual int32_t GetUserStorageStatsByType(int32_t userId, StorageStats &storageStats, std::string type) override 105 { 106 return E_OK; 107 } 108 GetCurrentBundleStats(BundleStats & bundleStats,uint32_t statFlag)109 virtual int32_t GetCurrentBundleStats(BundleStats &bundleStats, uint32_t statFlag) override 110 { 111 return E_OK; 112 } 113 NotifyVolumeCreated(VolumeCore vc)114 virtual int32_t NotifyVolumeCreated(VolumeCore vc) override 115 { 116 return E_OK; 117 } 118 NotifyVolumeMounted(std::string volumeId,int fsType,std::string fsUuid,std::string path,std::string description)119 virtual int32_t NotifyVolumeMounted(std::string volumeId, int fsType, std::string fsUuid, 120 std::string path, std::string description) override 121 { 122 return E_OK; 123 } 124 NotifyVolumeStateChanged(std::string volumeId,VolumeState state)125 virtual int32_t NotifyVolumeStateChanged(std::string volumeId, VolumeState state) override 126 { 127 return E_OK; 128 } 129 Mount(std::string volumeId)130 virtual int32_t Mount(std::string volumeId) override 131 { 132 return E_OK; 133 } 134 Unmount(std::string volumeId)135 virtual int32_t Unmount(std::string volumeId) override 136 { 137 return E_OK; 138 } 139 GetAllVolumes(std::vector<VolumeExternal> & vecOfVol)140 virtual int32_t GetAllVolumes(std::vector<VolumeExternal> &vecOfVol) override 141 { 142 return E_OK; 143 } 144 NotifyDiskCreated(Disk disk)145 virtual int32_t NotifyDiskCreated(Disk disk) override 146 { 147 return E_OK; 148 } 149 NotifyDiskDestroyed(std::string diskId)150 virtual int32_t NotifyDiskDestroyed(std::string diskId) override 151 { 152 return E_OK; 153 } 154 Partition(std::string diskId,int32_t type)155 virtual int32_t Partition(std::string diskId, int32_t type) override 156 { 157 return E_OK; 158 } 159 GetAllDisks(std::vector<Disk> & vecOfDisk)160 virtual int32_t GetAllDisks(std::vector<Disk> &vecOfDisk) override 161 { 162 return E_OK; 163 } 164 GetVolumeByUuid(std::string fsUuid,VolumeExternal & vc)165 virtual int32_t GetVolumeByUuid(std::string fsUuid, VolumeExternal &vc) override 166 { 167 return E_OK; 168 } 169 GetVolumeById(std::string volumeId,VolumeExternal & vc)170 virtual int32_t GetVolumeById(std::string volumeId, VolumeExternal &vc) override 171 { 172 return E_OK; 173 } 174 SetVolumeDescription(std::string fsUuid,std::string description)175 virtual int32_t SetVolumeDescription(std::string fsUuid, std::string description) override 176 { 177 return E_OK; 178 } 179 Format(std::string volumeId,std::string fsType)180 virtual int32_t Format(std::string volumeId, std::string fsType) override 181 { 182 return E_OK; 183 } 184 GetDiskById(std::string diskId,Disk & disk)185 virtual int32_t GetDiskById(std::string diskId, Disk &disk) override 186 { 187 return E_OK; 188 } 189 GenerateUserKeys(uint32_t userId,uint32_t flags)190 virtual int32_t GenerateUserKeys(uint32_t userId, uint32_t flags) override 191 { 192 return E_OK; 193 } 194 DeleteUserKeys(uint32_t userId)195 virtual int32_t DeleteUserKeys(uint32_t userId) override 196 { 197 return E_OK; 198 } 199 UpdateUserAuth(uint32_t userId,uint64_t secureUid,const std::vector<uint8_t> & token,const std::vector<uint8_t> & oldSecret,const std::vector<uint8_t> & newSecret)200 virtual int32_t UpdateUserAuth(uint32_t userId, uint64_t secureUid, 201 const std::vector<uint8_t> &token, 202 const std::vector<uint8_t> &oldSecret, 203 const std::vector<uint8_t> &newSecret) override 204 { 205 return E_OK; 206 } 207 ActiveUserKey(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)208 virtual int32_t ActiveUserKey(uint32_t userId, 209 const std::vector<uint8_t> &token, 210 const std::vector<uint8_t> &secret) override 211 { 212 return E_OK; 213 } 214 InactiveUserKey(uint32_t userId)215 virtual int32_t InactiveUserKey(uint32_t userId) override 216 { 217 return E_OK; 218 } 219 LockUserScreen(uint32_t userId)220 virtual int32_t LockUserScreen(uint32_t userId) override 221 { 222 return E_OK; 223 } 224 UnlockUserScreen(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)225 virtual int32_t UnlockUserScreen(uint32_t userId, 226 const std::vector<uint8_t> &token, 227 const std::vector<uint8_t> &secret) override 228 { 229 return E_OK; 230 } 231 MountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)232 virtual int32_t MountDfsDocs(int32_t userId, const std::string &relativePath, 233 const std::string &networkId, const std::string &deviceId) override 234 { 235 return E_OK; 236 } 237 UMountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)238 virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath, 239 const std::string &networkId, const std::string &deviceId) override 240 { 241 return E_OK; 242 } 243 GetLockScreenStatus(uint32_t userId,bool & lockScreenStatus)244 virtual int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus) override 245 { 246 return E_OK; 247 } 248 GenerateAppkey(uint32_t hashId,uint32_t userId,std::string & keyId)249 virtual int32_t GenerateAppkey(uint32_t hashId, uint32_t userId, std::string &keyId) override 250 { 251 return E_OK; 252 } 253 DeleteAppkey(const std::string keyId)254 virtual int32_t DeleteAppkey(const std::string keyId) override 255 { 256 return E_OK; 257 } 258 UpdateKeyContext(uint32_t userId)259 virtual int32_t UpdateKeyContext(uint32_t userId) override 260 { 261 return E_OK; 262 } 263 CreateShareFile(const std::vector<std::string> & uriList,uint32_t tokenId,uint32_t flag)264 virtual std::vector<int32_t> CreateShareFile(const std::vector<std::string> &uriList, 265 uint32_t tokenId, uint32_t flag) override 266 { 267 return std::vector<int32_t>{E_OK}; 268 } 269 DeleteShareFile(uint32_t tokenId,const std::vector<std::string> & uriList)270 virtual int32_t DeleteShareFile(uint32_t tokenId, const std::vector<std::string> &uriList) override 271 { 272 return E_OK; 273 } UpdateMemoryPara(int32_t size,int32_t & oldSize)274 virtual int32_t UpdateMemoryPara(int32_t size, int32_t &oldSize) override 275 { 276 return E_OK; 277 } GetBundleStatsForIncrease(uint32_t userId,const std::vector<std::string> & bundleNames,const std::vector<int64_t> & incrementalBackTimes,std::vector<int64_t> & pkgFileSizes,std::vector<int64_t> & incPkgFileSizes)278 virtual int32_t GetBundleStatsForIncrease(uint32_t userId, const std::vector<std::string> &bundleNames, 279 const std::vector<int64_t> &incrementalBackTimes, std::vector<int64_t> &pkgFileSizes, 280 std::vector<int64_t> &incPkgFileSizes) override 281 { 282 return E_OK; 283 } 284 virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override 285 { 286 return E_OK; 287 } 288 GetUserNeedActiveStatus(uint32_t userId,bool & needActive)289 virtual int32_t GetUserNeedActiveStatus(uint32_t userId, bool &needActive) override 290 { 291 return E_OK; 292 } 293 }; 294 } // namespace StorageManager 295 } // namespace OHOS 296 #endif // MOCK_STORAGE_MANAGER_SERVICE_H