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,std::bitset<FIELD_KEY_MAX_SIZE> fieldkey,bool isCallbackValid,const sptr<IRemoteObject> & downloadCallback)104     int32_t StartFileCache(const std::vector<std::string> &pathVec, int64_t &downloadId,
105                            std::bitset<FIELD_KEY_MAX_SIZE> fieldkey,
106                            bool isCallbackValid,
107                            const sptr<IRemoteObject> &downloadCallback)
108     {
109         return E_OK;
110     }
111     int32_t StopDownloadFile(const std::string &path, bool needClean = false)
112     {
113         return E_OK;
114     }
115     int32_t StopFileCache(const int64_t &downloadId,  bool needClean = false)
116     {
117         return E_OK;
118     }
RegisterDownloadFileCallback(const sptr<IRemoteObject> & downloadCallback)119     int32_t RegisterDownloadFileCallback(const sptr<IRemoteObject> &downloadCallback)
120     {
121         return E_OK;
122     }
UnregisterDownloadFileCallback()123     int32_t UnregisterDownloadFileCallback()
124     {
125         return E_OK;
126     }
UploadAsset(const int32_t userId,const std::string & request,std::string & result)127     int32_t UploadAsset(const int32_t userId, const std::string &request, std::string &result)
128     {
129         return E_OK;
130     }
DownloadFile(const int32_t userId,const std::string & bundleName,AssetInfoObj & assetInfoObj)131     int32_t DownloadFile(const int32_t userId, const std::string &bundleName, AssetInfoObj &assetInfoObj)
132     {
133         return E_OK;
134     }
DownloadFiles(const int32_t userId,const std::string & bundleName,const std::vector<AssetInfoObj> & assetInfoObj,std::vector<bool> & assetResultMap)135     int32_t DownloadFiles(const int32_t userId,
136                           const std::string &bundleName,
137                           const std::vector<AssetInfoObj> &assetInfoObj,
138                           std::vector<bool> &assetResultMap)
139     {
140         return E_OK;
141     }
DeleteAsset(const int32_t userId,const std::string & uri)142     int32_t DeleteAsset(const int32_t userId, const std::string &uri)
143     {
144         return E_OK;
145     }
146     int32_t GetSyncTimeInner(int64_t &syncTime, const std::string &bundleName = "")
147     {
148         return E_OK;
149     }
CleanCacheInner(const std::string & uri)150     int32_t CleanCacheInner(const std::string &uri)
151     {
152         return E_OK;
153     }
154 
DownloadAsset(const uint64_t taskId,const int32_t userId,const std::string & bundleName,const std::string & networkId,AssetInfoObj & assetInfoObj)155     int32_t DownloadAsset(const uint64_t taskId,
156                           const int32_t userId,
157                           const std::string &bundleName,
158                           const std::string &networkId,
159                           AssetInfoObj &assetInfoObj)
160     {
161         return E_OK;
162     }
RegisterDownloadAssetCallback(const sptr<IRemoteObject> & remoteObject)163     int32_t RegisterDownloadAssetCallback(const sptr<IRemoteObject> &remoteObject)
164     {
165         return E_OK;
166     }
167 };
168 
169 } // namespace OHOS::FileManagement::CloudSync
170 
171 #endif // MOCK_I_CLOUD_SYNC_SERVICE_H
172