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 RegisterCallbackInner(const sptr<IRemoteObject> &remoteObject, const std::string &bundleName = "") override 50 { 51 return E_OK; 52 } 53 54 int32_t StartSyncInner(bool forceFlag, const std::string &bundleName = "") override 55 { 56 return E_OK; 57 } 58 TriggerSyncInner(const std::string & bundleName,const int32_t & userId)59 int32_t TriggerSyncInner(const std::string &bundleName, const int32_t &userId) override 60 { 61 return E_OK; 62 } 63 64 int32_t StopSyncInner(const std::string &bundleName = "", bool forceFlag = false) override 65 { 66 return E_OK; 67 } 68 69 int32_t ResetCursor(const std::string &bundleName = "") override 70 { 71 return E_OK; 72 } 73 ChangeAppSwitch(const std::string & accoutId,const std::string & bundleName,bool status)74 int32_t ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) override 75 { 76 return E_OK; 77 } 78 Clean(const std::string & accountId,const CleanOptions & cleanOptions)79 int32_t Clean(const std::string &accountId, const CleanOptions &cleanOptions) override 80 { 81 return E_OK; 82 } 83 NotifyDataChange(const std::string & accoutId,const std::string & bundleName)84 int32_t NotifyDataChange(const std::string &accoutId, const std::string &bundleName) override 85 { 86 return E_OK; 87 } NotifyEventChange(int32_t userId,const std::string & eventId,const std::string & extraData)88 int32_t NotifyEventChange(int32_t userId, const std::string &eventId, const std::string &extraData) override 89 { 90 return E_OK; 91 } EnableCloud(const std::string & accoutId,const SwitchDataObj & switchData)92 int32_t EnableCloud(const std::string &accoutId, const SwitchDataObj &switchData) override 93 { 94 return E_OK; 95 } DisableCloud(const std::string & accoutId)96 int32_t DisableCloud(const std::string &accoutId) override 97 { 98 return E_OK; 99 } StartDownloadFile(const std::string & path)100 int32_t StartDownloadFile(const std::string &path) 101 { 102 return E_OK; 103 } StartFileCache(const std::vector<std::string> & pathVec,int64_t & downloadId,bool isCallbackValid,const sptr<IRemoteObject> & downloadCallback)104 int32_t StartFileCache(const std::vector<std::string> &pathVec, int64_t &downloadId, 105 bool isCallbackValid, 106 const sptr<IRemoteObject> &downloadCallback) 107 { 108 return E_OK; 109 } 110 int32_t StopDownloadFile(const std::string &path, bool needClean = false) 111 { 112 return E_OK; 113 } 114 int32_t StopFileCache(const int64_t &downloadId, bool needClean = false) 115 { 116 return E_OK; 117 } RegisterDownloadFileCallback(const sptr<IRemoteObject> & downloadCallback)118 int32_t RegisterDownloadFileCallback(const sptr<IRemoteObject> &downloadCallback) 119 { 120 return E_OK; 121 } UnregisterDownloadFileCallback()122 int32_t UnregisterDownloadFileCallback() 123 { 124 return E_OK; 125 } UploadAsset(const int32_t userId,const std::string & request,std::string & result)126 int32_t UploadAsset(const int32_t userId, const std::string &request, std::string &result) 127 { 128 return E_OK; 129 } DownloadFile(const int32_t userId,const std::string & bundleName,AssetInfoObj & assetInfoObj)130 int32_t DownloadFile(const int32_t userId, const std::string &bundleName, AssetInfoObj &assetInfoObj) 131 { 132 return E_OK; 133 } DownloadFiles(const int32_t userId,const std::string & bundleName,const std::vector<AssetInfoObj> & assetInfoObj,std::vector<bool> & assetResultMap)134 int32_t DownloadFiles(const int32_t userId, 135 const std::string &bundleName, 136 const std::vector<AssetInfoObj> &assetInfoObj, 137 std::vector<bool> &assetResultMap) 138 { 139 return E_OK; 140 } DeleteAsset(const int32_t userId,const std::string & uri)141 int32_t DeleteAsset(const int32_t userId, const std::string &uri) 142 { 143 return E_OK; 144 } 145 int32_t GetSyncTimeInner(int64_t &syncTime, const std::string &bundleName = "") 146 { 147 return E_OK; 148 } 149 BatchDentryFileInsert(const std::vector<DentryFileInfoObj> & fileInfo,std::vector<std::string> & failCloudId)150 int32_t BatchDentryFileInsert(const std::vector<DentryFileInfoObj> &fileInfo, 151 std::vector<std::string> &failCloudId) 152 { 153 return E_OK; 154 } 155 CleanCacheInner(const std::string & uri)156 int32_t CleanCacheInner(const std::string &uri) 157 { 158 return E_OK; 159 } 160 OptimizeStorage(const int32_t agingDays)161 int32_t OptimizeStorage(const int32_t agingDays) 162 { 163 return E_OK; 164 } 165 DownloadAsset(const uint64_t taskId,const int32_t userId,const std::string & bundleName,const std::string & networkId,AssetInfoObj & assetInfoObj)166 int32_t DownloadAsset(const uint64_t taskId, 167 const int32_t userId, 168 const std::string &bundleName, 169 const std::string &networkId, 170 AssetInfoObj &assetInfoObj) 171 { 172 return E_OK; 173 } RegisterDownloadAssetCallback(const sptr<IRemoteObject> & remoteObject)174 int32_t RegisterDownloadAssetCallback(const sptr<IRemoteObject> &remoteObject) 175 { 176 return E_OK; 177 } 178 DownloadThumb()179 int32_t DownloadThumb() 180 { 181 return E_OK; 182 } 183 }; 184 185 } // namespace OHOS::FileManagement::CloudSync 186 187 #endif // MOCK_I_CLOUD_SYNC_SERVICE_H 188