Skip to content

Commit 33de213

Browse files
committed
Add ProjectDownloaderStub class
1 parent 276bbbb commit 33de213

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

src/internal/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ if (LIBSCRATCHCPP_NETWORK_SUPPORT)
2626
projectdownloader.cpp
2727
projectdownloader.h
2828
)
29+
else()
30+
target_sources(scratchcpp
31+
PRIVATE
32+
projectdownloaderstub.cpp
33+
projectdownloaderstub.h
34+
)
2935
endif()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
#include "projectdownloaderstub.h"
4+
5+
using namespace libscratchcpp;
6+
7+
ProjectDownloaderStub::ProjectDownloaderStub()
8+
{
9+
}
10+
11+
bool ProjectDownloaderStub::downloadJson(const std::string &)
12+
{
13+
return false;
14+
}
15+
16+
bool ProjectDownloaderStub::downloadAssets(const std::vector<std::string> &)
17+
{
18+
return false;
19+
}
20+
21+
void ProjectDownloaderStub::cancel()
22+
{
23+
}
24+
25+
const std::string &ProjectDownloaderStub::json() const
26+
{
27+
static const std::string empty;
28+
return empty;
29+
}
30+
31+
const std::vector<std::string> &ProjectDownloaderStub::assets() const
32+
{
33+
static const std::vector<std::string> empty;
34+
return empty;
35+
}
36+
37+
unsigned int ProjectDownloaderStub::downloadedAssetCount() const
38+
{
39+
return 0;
40+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
#pragma once
4+
5+
#include "iprojectdownloader.h"
6+
7+
namespace libscratchcpp
8+
{
9+
10+
class ProjectDownloaderStub : public IProjectDownloader
11+
{
12+
public:
13+
ProjectDownloaderStub();
14+
15+
bool downloadJson(const std::string &) override;
16+
bool downloadAssets(const std::vector<std::string> &) override;
17+
void cancel() override;
18+
19+
const std::string &json() const override;
20+
const std::vector<std::string> &assets() const override;
21+
unsigned int downloadedAssetCount() const override;
22+
};
23+
24+
} // namespace libscratchcpp

0 commit comments

Comments
 (0)