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 "icloud_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,int32_t userId)75 int32_t TriggerSyncInner(const std::string &bundleName, 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 & uri,const sptr<IRemoteObject> & downloadCallback,int64_t & downloadId)121 int32_t StartDownloadFile(const std::string &uri, 122 const sptr<IRemoteObject> &downloadCallback, 123 int64_t &downloadId) 124 { 125 return E_OK; 126 } 127 int32_t StartFileCache(const std::vector<std::string> &pathVec, int64_t &downloadId, 128 int32_t fieldkey, 129 const sptr<IRemoteObject> &downloadCallback, 130 int32_t timeout = -1) 131 { 132 return E_OK; 133 } 134 int32_t StopDownloadFile(int64_t downloadId, bool needClean = false) 135 { 136 return E_OK; 137 } 138 int32_t StopFileCache(int64_t downloadId, bool needClean = false, int32_t timeout = -1) 139 { 140 return E_OK; 141 } UploadAsset(const int32_t userId,const std::string & request,std::string & result)142 int32_t UploadAsset(const int32_t userId, const std::string &request, std::string &result) 143 { 144 return E_OK; 145 } DownloadFile(const int32_t userId,const std::string & bundleName,const AssetInfoObj & assetInfoObj)146 int32_t DownloadFile(const int32_t userId, const std::string &bundleName, const AssetInfoObj &assetInfoObj) 147 { 148 return E_OK; 149 } DownloadFiles(const int32_t userId,const std::string & bundleName,const std::vector<AssetInfoObj> & assetInfoObj,std::vector<bool> & assetResultMap,int32_t connectTime)150 int32_t DownloadFiles(const int32_t userId, 151 const std::string &bundleName, 152 const std::vector<AssetInfoObj> &assetInfoObj, 153 std::vector<bool> &assetResultMap, 154 int32_t connectTime) 155 { 156 return E_OK; 157 } DeleteAsset(const int32_t userId,const std::string & uri)158 int32_t DeleteAsset(const int32_t userId, const std::string &uri) 159 { 160 return E_OK; 161 } 162 int32_t GetSyncTimeInner(int64_t &syncTime, const std::string &bundleName = "") 163 { 164 return E_OK; 165 } 166 BatchDentryFileInsert(const std::vector<DentryFileInfoObj> & fileInfo,std::vector<std::string> & failCloudId)167 int32_t BatchDentryFileInsert(const std::vector<DentryFileInfoObj> &fileInfo, 168 std::vector<std::string> &failCloudId) 169 { 170 return E_OK; 171 } 172 CleanCacheInner(const std::string & uri)173 int32_t CleanCacheInner(const std::string &uri) 174 { 175 return E_OK; 176 } 177 OptimizeStorage(const OptimizeSpaceOptions & optimizeOptions,bool isCallbackValid,const sptr<IRemoteObject> & optimizeCallback)178 int32_t OptimizeStorage(const OptimizeSpaceOptions &optimizeOptions, bool isCallbackValid, 179 const sptr<IRemoteObject> &optimizeCallback) 180 { 181 return E_OK; 182 } 183 StopOptimizeStorage()184 int32_t StopOptimizeStorage() 185 { 186 return E_OK; 187 } 188 DownloadAsset(const uint64_t taskId,const int32_t userId,const std::string & bundleName,const std::string & networkId,const AssetInfoObj & assetInfoObj)189 int32_t DownloadAsset(const uint64_t taskId, 190 const int32_t userId, 191 const std::string &bundleName, 192 const std::string &networkId, 193 const AssetInfoObj &assetInfoObj) 194 { 195 return E_OK; 196 } RegisterDownloadAssetCallback(const sptr<IRemoteObject> & remoteObject)197 int32_t RegisterDownloadAssetCallback(const sptr<IRemoteObject> &remoteObject) 198 { 199 return E_OK; 200 } 201 DownloadThumb()202 int32_t DownloadThumb() 203 { 204 return E_OK; 205 } BatchCleanFile(const std::vector<CleanFileInfoObj> & fileInfo,std::vector<std::string> & failCloudId)206 int32_t BatchCleanFile(const std::vector<CleanFileInfoObj> &fileInfo, std::vector<std::string> &failCloudId) 207 { 208 return E_OK; 209 } 210 }; 211 212 } // namespace OHOS::FileManagement::CloudSync 213 214 #endif // MOCK_I_CLOUD_SYNC_SERVICE_H 215