diff options
author | Artem Pavlenko <artem@mapnik.org> | 2020-02-14 16:56:46 +0000 |
---|---|---|
committer | Artem Pavlenko <artem@mapnik.org> | 2020-02-14 16:56:46 +0000 |
commit | 145c053a02d918d74002ea690dac398ee588a374 (patch) | |
tree | c645ffaec12822f0668858181248cd7365fc4e20 /test/storage/main_resource_loader.test.cpp | |
parent | 37a4660ca367f141b9e0dedf3932c74f0ee0c920 (diff) | |
parent | 59294aaef333bdd455bd13d6bab6fca730379b52 (diff) | |
download | qtlocation-mapboxgl-upstream/galinelle_setStyle++_updated.tar.gz |
Merge branch 'master' into galinelle_setStyle++_updatedupstream/galinelle_setStyle++_updated
Diffstat (limited to 'test/storage/main_resource_loader.test.cpp')
-rw-r--r-- | test/storage/main_resource_loader.test.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/storage/main_resource_loader.test.cpp b/test/storage/main_resource_loader.test.cpp index ee9211b064..b5245dbad8 100644 --- a/test/storage/main_resource_loader.test.cpp +++ b/test/storage/main_resource_loader.test.cpp @@ -8,6 +8,7 @@ #include <mbgl/storage/resource_transform.hpp> #include <mbgl/test/util.hpp> #include <mbgl/util/run_loop.hpp> +#include <mbgl/util/timer.hpp> using namespace mbgl; @@ -749,3 +750,38 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CachedResourceLowPriority)) { loop.run(); } + +TEST(MainResourceLoader, TEST_REQUIRES_SERVER(NoDoubleDispatch)) { + util::RunLoop loop; + MainResourceLoader fs(ResourceOptions{}); + + const Resource resource{Resource::Unknown, "http://127.0.0.1:3000/revalidate-same"}; + Response response; + response.data = std::make_shared<std::string>("data"); + response.etag.emplace("snowfall"); + + std::unique_ptr<AsyncRequest> req; + unsigned responseCount = 0u; + auto dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{}); + dbfs->forward(resource, response, [&] { + req = fs.request(resource, [&](Response res) { + EXPECT_EQ(nullptr, res.error); + EXPECT_FALSE(bool(res.modified)); + EXPECT_TRUE(bool(res.etag)); + EXPECT_EQ("snowfall", *res.etag); + if (!res.notModified) { + ASSERT_TRUE(res.data.get()); + EXPECT_EQ("data", *res.data); + ++responseCount; + } + }); + }); + + util::Timer timer; + timer.start(Milliseconds(100), Duration::zero(), [&loop, &responseCount] { + EXPECT_EQ(1u, responseCount); + loop.stop(); + }); + + loop.run(); +} |