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 UpdateUseAuthWithRecoveryKey(const std::vector<uint8_t> & authToken,const std::vector<uint8_t> & newSecret,uint64_t secureUid,uint32_t userId,std::vector<std::vector<uint8_t>> & plainText)208 virtual int32_t UpdateUseAuthWithRecoveryKey(const std::vector<uint8_t> &authToken, 209 const std::vector<uint8_t> &newSecret, 210 uint64_t secureUid, 211 uint32_t userId, 212 std::vector<std::vector<uint8_t>> &plainText) 213 { 214 return E_OK; 215 } 216 217 virtual int32_t ActiveUserKey(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)218 ActiveUserKey(uint32_t userId, const std::vector<uint8_t> &token, const std::vector<uint8_t> &secret) override 219 { 220 return E_OK; 221 } 222 InactiveUserKey(uint32_t userId)223 virtual int32_t InactiveUserKey(uint32_t userId) override 224 { 225 return E_OK; 226 } 227 LockUserScreen(uint32_t userId)228 virtual int32_t LockUserScreen(uint32_t userId) override 229 { 230 return E_OK; 231 } 232 UnlockUserScreen(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)233 virtual int32_t UnlockUserScreen(uint32_t userId, 234 const std::vector<uint8_t> &token, 235 const std::vector<uint8_t> &secret) override 236 { 237 return E_OK; 238 } 239 MountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)240 virtual int32_t MountDfsDocs(int32_t userId, const std::string &relativePath, 241 const std::string &networkId, const std::string &deviceId) override 242 { 243 return E_OK; 244 } 245 UMountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)246 virtual int32_t UMountDfsDocs(int32_t userId, const std::string &relativePath, 247 const std::string &networkId, const std::string &deviceId) override 248 { 249 return E_OK; 250 } 251 GetLockScreenStatus(uint32_t userId,bool & lockScreenStatus)252 virtual int32_t GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus) override 253 { 254 return E_OK; 255 } 256 GenerateAppkey(uint32_t hashId,uint32_t userId,std::string & keyId)257 virtual int32_t GenerateAppkey(uint32_t hashId, uint32_t userId, std::string &keyId) override 258 { 259 return E_OK; 260 } 261 DeleteAppkey(const std::string keyId)262 virtual int32_t DeleteAppkey(const std::string keyId) override 263 { 264 return E_OK; 265 } 266 CreateRecoverKey(uint32_t userId,uint32_t userType,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)267 virtual int32_t CreateRecoverKey(uint32_t userId, 268 uint32_t userType, 269 const std::vector<uint8_t> &token, 270 const std::vector<uint8_t> &secret) override 271 { 272 return E_OK; 273 } 274 SetRecoverKey(const std::vector<uint8_t> & key)275 virtual int32_t SetRecoverKey(const std::vector<uint8_t> &key) override 276 { 277 return E_OK; 278 } 279 280 virtual int32_t UpdateKeyContext(uint32_t userId, bool needRemoveTmpKey = false) override 281 { 282 return E_OK; 283 } 284 CreateShareFile(const std::vector<std::string> & uriList,uint32_t tokenId,uint32_t flag)285 virtual std::vector<int32_t> CreateShareFile(const std::vector<std::string> &uriList, 286 uint32_t tokenId, uint32_t flag) override 287 { 288 return std::vector<int32_t>{E_OK}; 289 } 290 DeleteShareFile(uint32_t tokenId,const std::vector<std::string> & uriList)291 virtual int32_t DeleteShareFile(uint32_t tokenId, const std::vector<std::string> &uriList) override 292 { 293 return E_OK; 294 } UpdateMemoryPara(int32_t size,int32_t & oldSize)295 virtual int32_t UpdateMemoryPara(int32_t size, int32_t &oldSize) override 296 { 297 return E_OK; 298 } 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)299 virtual int32_t GetBundleStatsForIncrease(uint32_t userId, const std::vector<std::string> &bundleNames, 300 const std::vector<int64_t> &incrementalBackTimes, std::vector<int64_t> &pkgFileSizes, 301 std::vector<int64_t> &incPkgFileSizes) override 302 { 303 return E_OK; 304 } 305 306 virtual int32_t GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount = false) override 307 { 308 return E_OK; 309 } 310 GetUserNeedActiveStatus(uint32_t userId,bool & needActive)311 virtual int32_t GetUserNeedActiveStatus(uint32_t userId, bool &needActive) override 312 { 313 return E_OK; 314 } 315 NotifyMtpMounted(const std::string & id,const std::string & path,const std::string & desc,const std::string & uuid)316 virtual int32_t NotifyMtpMounted(const std::string &id, const std::string &path, const std::string &desc, 317 const std::string &uuid) override 318 { 319 return E_OK; 320 } 321 NotifyMtpUnmounted(const std::string & id,const std::string & path,const bool isBadRemove)322 virtual int32_t NotifyMtpUnmounted(const std::string &id, const std::string &path, const bool isBadRemove) override 323 { 324 return E_OK; 325 } 326 MountMediaFuse(int32_t userId,int32_t & devFd)327 virtual int32_t MountMediaFuse(int32_t userId, int32_t &devFd) override 328 { 329 return E_OK; 330 } 331 UMountMediaFuse(int32_t userId)332 virtual int32_t UMountMediaFuse(int32_t userId) override 333 { 334 return E_OK; 335 } 336 MountFileMgrFuse(int32_t userId,const std::string & path,int32_t & fuseFd)337 virtual int32_t MountFileMgrFuse(int32_t userId, const std::string &path, int32_t &fuseFd) override 338 { 339 return E_OK; 340 } 341 UMountFileMgrFuse(int32_t userId,const std::string & path)342 virtual int32_t UMountFileMgrFuse(int32_t userId, const std::string &path) override 343 { 344 return E_OK; 345 } 346 }; 347 } // namespace StorageManager 348 } // namespace OHOS 349 #endif // MOCK_STORAGE_MANAGER_SERVICE_H