Add OfflineDownload.NoFreezingOnCachedTilesAndNewStyle unit test

This commit is contained in:
Mikhail Pozdnyakov
2020-02-25 18:06:48 +02:00
parent 7c48611f9e
commit c85e7cbce0
3 changed files with 49 additions and 0 deletions

View File

@@ -70,6 +70,15 @@ void StubFileSource::remove(AsyncRequest* req) {
}
}
void StubFileSource::setProperty(const std::string& key, const mapbox::base::Value& value) {
properties[key] = value;
}
mapbox::base::Value StubFileSource::getProperty(const std::string& key) const {
auto it = properties.find(key);
return (it != properties.end()) ? it->second : mapbox::base::Value();
}
optional<Response> StubFileSource::defaultResponse(const Resource& resource) {
switch (resource.kind) {
case Resource::Kind::Style:

View File

@@ -5,6 +5,7 @@
#include <mbgl/storage/resource.hpp>
#include <mbgl/util/timer.hpp>
#include <map>
#include <unordered_map>
namespace mbgl {
@@ -22,6 +23,8 @@ public:
std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override;
bool canRequest(const Resource&) const override { return true; }
void remove(AsyncRequest*);
void setProperty(const std::string&, const mapbox::base::Value&) override;
mapbox::base::Value getProperty(const std::string&) const override;
using ResponseFunction = std::function<optional<Response> (const Resource&)>;
@@ -48,6 +51,7 @@ private:
std::unordered_map<AsyncRequest*, std::tuple<Resource, ResponseFunction, Callback>> pending;
ResponseType type;
util::Timer timer;
std::map<std::string, mapbox::base::Value> properties;
};
} // namespace mbgl