1 /* 2 * Copyright (c) 2023 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 16 #ifndef MOCK_I_CLOUD_SYNC_SERVICE_H 17 #define MOCK_I_CLOUD_SYNC_SERVICE_H 18 19 #include "i_cloud_sync_service.h" 20 21 #include <gmock/gmock.h> 22 #include <gtest/gtest.h> 23 24 #include "iremote_broker.h" 25 #include "cloud_sync_constants.h" 26 #include "dfs_error.h" 27 28 namespace OHOS::FileManagement::CloudSync { 29 class CloudSyncServiceMock : public IRemoteStub<ICloudSyncService> { 30 public: 31 int code_; CloudSyncServiceMock()32 CloudSyncServiceMock() : code_(0) {} ~CloudSyncServiceMock()33 virtual ~CloudSyncServiceMock() {} 34 35 MOCK_METHOD4(SendRequest, int(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)); 36 InvokeSendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)37 int32_t InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 38 { 39 code_ = code; 40 reply.WriteInt32(E_OK); 41 return E_OK; 42 } 43 44 int32_t UnRegisterCallbackInner(const std::string &bundleName = "") override 45 { 46 return E_OK; 47 } 48 49 int32_t UnRegisterFileSyncCallbackInner(const std::string &bundleName = "") override 50 { 51 return E_OK; 52 } 53 54 int32_t RegisterCallbackInner(const sptr<IRemoteObject> &remoteObject, const std::string &bundleName = "") override 55 { 56 return E_OK; 57 } 58 59 int32_t RegisterFileSyncCallbackInner(const sptr<IRemoteObject> &remoteObject, 60 const std::string &bundleName = "") override 61 { 62 return E_OK; 63 } 64 65 int32_t StartSyncInner(bool forceFlag, const std::string &bundleName = "") override 66 { 67 return E_OK; 68 } 69 70 int32_t StartFileSyncInner(bool forceFlag, const std::string &bundleName = "") override 71 { 72 return E_OK; 73 } 74 TriggerSyncInner(const std::string & bundleName,const int32_t & userId)75 int32_t TriggerSyncInner(const std::string &bundleName, const int32_t &userId) override 76 { 77 return E_OK; 78 } 79 80 int32_t StopSyncInner(const std::string &bundleName = "", bool forceFlag = false) override 81 { 82 return E_OK; 83 } 84 85 int32_t StopFileSyncInner(const std::string &bundleName = "", bool forceFlag = false) override 86 { 87 return E_OK; 88 } 89 90 int32_t ResetCursor(const std::string &bundleName = "") override 91 { 92 return E_OK; 93 } 94 ChangeAppSwitch(const std::string & accoutId,const std::string & bundleName,bool status)95 int32_t ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) override 96 { 97 return E_OK; 98 } 99 Clean(const std::string & accountId,const CleanOptions & cleanOptions)100 int32_t Clean(const std::string &accountId, const CleanOptions &cleanOptions) override 101 { 102 return E_OK; 103 } 104 NotifyDataChange(const std::string & accoutId,const std::string & bundleName)105 int32_t NotifyDataChange(const std::string &accoutId, const std::string &bundleName) override 106 { 107 return E_OK; 108 } NotifyEventChange(int32_t userId,const std::string & eventId,const std::string & extraData)109 int32_t NotifyEventChange(int32_t userId, const std::string &eventId, const std::string &extraData) override 110 { 111 return E_OK; 112 } EnableCloud(const std::string & accoutId,const SwitchDataObj & switchData)113 int32_t EnableCloud(const std::string &accoutId, const SwitchDataObj &switchData) override 114 { 115 return E_OK; 116 } DisableCloud(const std::string & accoutId)117 int32_t DisableCloud(const std::string &accoutId) override 118 { 119 return E_OK; 120 } StartDownloadFile(const std::string & path)121 int32_t StartDownloadFile(const std::string &path) 122 { 123 return E_OK; 124 } 125 int32_t StartFileCache(const std::vector<std::string> &pathVec, int64_t &downloadId, 126 std::bitset<FIELD_KEY_MAX_SIZE> fieldkey, 127 bool isCallbackValid, 128 const sptr<IRemoteObject> &downloadCallback, 129 int32_t timeout = -1) 130 { 131 return E_OK; 132 } 133 int32_t StopDownloadFile(const std::string &path, bool needClean = false) 134 { 135 return E_OK; 136 } 137 int32_t StopFileCache(int64_t downloadId, bool needClean = false, int32_t timeout = -1) 138 { 139 return E_OK; 140 } RegisterDownloadFileCallback(const sptr<IRemoteObject> & downloadCallback)141 int32_t RegisterDownloadFileCallback(const sptr<IRemoteObject> &downloadCallback) 142 { 143 return E_OK; 144 } RegisterFileCacheCallback(const sptr<IRemoteObject> & downloadCallback)145 int32_t RegisterFileCacheCallback(const sptr<IRemoteObject> &downloadCallback) 146 { 147 return E_OK; 148 } UnregisterDownloadFileCallback()149 int32_t UnregisterDownloadFileCallback() 150 { 151 return E_OK; 152 } UnregisterFileCacheCallback()153 int32_t UnregisterFileCacheCallback() 154 { 155 return E_OK; 156 } UploadAsset(const int32_t userId,const std::string & request,std::string & result)157 int32_t UploadAsset(const int32_t userId, const std::string &request, std::string &result) 158 { 159 return E_OK; 160 } DownloadFile(const int32_t userId,const std::string & bundleName,AssetInfoObj & assetInfoObj)161 int32_t DownloadFile(const int32_t userId, const std::string &bundleName, AssetInfoObj &assetInfoObj) 162 { 163 return E_OK; 164 } DownloadFiles(const int32_t userId,const std::string & bundleName,const std::vector<AssetInfoObj> & assetInfoObj,std::vector<bool> & assetResultMap)165 int32_t DownloadFiles(const int32_t userId, 166 const std::string &bundleName, 167 const std::vector<AssetInfoObj> &assetInfoObj, 168 std::vector<bool> &assetResultMap) 169 { 170 return E_OK; 171 } DeleteAsset(const int32_t userId,const std::string & uri)172 int32_t DeleteAsset(const int32_t userId, const std::string &uri) 173 { 174 return E_OK; 175 } 176 int32_t GetSyncTimeInner(int64_t &syncTime, const std::string &bundleName = "") 177 { 178 return E_OK; 179 } 180 BatchDentryFileInsert(const std::vector<DentryFileInfoObj> & fileInfo,std::vector<std::string> & failCloudId)181 int32_t BatchDentryFileInsert(const std::vector<DentryFileInfoObj> &fileInfo, 182 std::vector<std::string> &failCloudId) 183 { 184 return E_OK; 185 } 186 CleanCacheInner(const std::string & uri)187 int32_t CleanCacheInner(const std::string &uri) 188 { 189 return E_OK; 190 } 191 OptimizeStorage(const OptimizeSpaceOptions & optimizeOptions,bool isCallbackValid,const sptr<IRemoteObject> & optimizeCallback)192 int32_t OptimizeStorage(const OptimizeSpaceOptions &optimizeOptions, bool isCallbackValid, 193 const sptr<IRemoteObject> &optimizeCallback) 194 { 195 return E_OK; 196 } 197 StopOptimizeStorage()198 int32_t StopOptimizeStorage() 199 { 200 return E_OK; 201 } 202 DownloadAsset(const uint64_t taskId,const int32_t userId,const std::string & bundleName,const std::string & networkId,AssetInfoObj & assetInfoObj)203 int32_t DownloadAsset(const uint64_t taskId, 204 const int32_t userId, 205 const std::string &bundleName, 206 const std::string &networkId, 207 AssetInfoObj &assetInfoObj) 208 { 209 return E_OK; 210 } RegisterDownloadAssetCallback(const sptr<IRemoteObject> & remoteObject)211 int32_t RegisterDownloadAssetCallback(const sptr<IRemoteObject> &remoteObject) 212 { 213 return E_OK; 214 } 215 DownloadThumb()216 int32_t DownloadThumb() 217 { 218 return E_OK; 219 } BatchCleanFile(const std::vector<CleanFileInfoObj> & fileInfo,std::vector<std::string> & failCloudId)220 int32_t BatchCleanFile(const std::vector<CleanFileInfoObj> &fileInfo, std::vector<std::string> &failCloudId) 221 { 222 return E_OK; 223 } 224 }; 225 226 } // namespace OHOS::FileManagement::CloudSync 227 228 #endif // MOCK_I_CLOUD_SYNC_SERVICE_H 229