1 /*
2 * Copyright (c) 2021-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 #include "base/network/download_manager.h"
17
18 namespace OHOS::Ace {
19 class MockDownloadManager final : public DownloadManager {
20 public:
21 MockDownloadManager() = default;
22 ~MockDownloadManager() = default;
23
Download(const std::string &,std::vector<uint8_t> &)24 bool Download(const std::string& /* url */, std::vector<uint8_t>& /* dataOut */) override
25 {
26 return false;
27 }
28
Download(const std::string &,const std::shared_ptr<DownloadResult> &)29 bool Download(const std::string& /* url */, const std::shared_ptr<DownloadResult>& /* result */) override
30 {
31 return false;
32 }
33
DownloadAsync(DownloadCallback &&,const std::string &,int32_t,int32_t)34 bool DownloadAsync(DownloadCallback&& /* downloadCallback */, const std::string& /* url */,
35 int32_t /* instanceId */, int32_t /* nodeId */) override
36 {
37 return false;
38 }
DownloadSync(DownloadCallback &&,const std::string &,int32_t,int32_t)39 bool DownloadSync(DownloadCallback&& /* downloadCallback */, const std::string& /* url */, int32_t /* instanceId */,
40 int32_t /* nodeId */) override
41 {
42 return false;
43 }
RemoveDownloadTask(const std::string &,int32_t,bool)44 bool RemoveDownloadTask(const std::string& /* url */, int32_t /*nodeId*/, bool /*isCancel = true*/) override
45 {
46 return false;
47 }
RemoveDownloadTaskWithPreload(const std::string & url,int32_t nodeId,bool)48 bool RemoveDownloadTaskWithPreload(const std::string& url, int32_t nodeId, bool /*isCancel = true*/) override
49 {
50 return false;
51 }
DownloadAsyncWithPreload(DownloadCallback &&,const std::string &,int32_t,int32_t)52 bool DownloadAsyncWithPreload(DownloadCallback&& /* downloadCallback */, const std::string& /* url */,
53 int32_t /* instanceId */, int32_t /* nodeId */) override
54 {
55 return false;
56 }
DownloadSyncWithPreload(DownloadCallback &&,const std::string &,int32_t,int32_t)57 bool DownloadSyncWithPreload(DownloadCallback&& /* downloadCallback */, const std::string& /* url */,
58 int32_t /* instanceId */, int32_t /* nodeId */) override
59 {
60 return false;
61 }
IsContains(const std::string &)62 bool IsContains(const std::string& /* url */) override
63 {
64 return false;
65 }
66
fetchCachedResult(const std::string &,std::string &)67 bool fetchCachedResult(const std::string& /* url */, std::string& /* result */) override
68 {
69 return false;
70 }
71 };
72
GetInstance()73 DownloadManager* DownloadManager::GetInstance()
74 {
75 static MockDownloadManager manager;
76 return &manager;
77 }
78 } // namespace OHOS::Ace
79