diff options
Diffstat (limited to 'test/storage/http_expires.cpp')
-rw-r--r-- | test/storage/http_expires.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/storage/http_expires.cpp b/test/storage/http_expires.cpp index 0a37df8e37..676e15da4f 100644 --- a/test/storage/http_expires.cpp +++ b/test/storage/http_expires.cpp @@ -1,5 +1,6 @@ #include "storage.hpp" +#include <mbgl/storage/default_file_source.hpp> #include <mbgl/storage/online_file_source.hpp> #include <mbgl/util/chrono.hpp> #include <mbgl/util/run_loop.hpp> @@ -33,3 +34,37 @@ TEST_F(Storage, HTTPRetryDelayOnExpiredTile) { HTTPRetryDelayOnExpiredTile.finish(); } + +TEST_F(Storage, HTTPRetryOnClockSkew) { + SCOPED_TEST(HTTPRetryOnClockSkew) + + using namespace mbgl; + + util::RunLoop loop; + DefaultFileSource fs(":memory:", "."); + + int counter = 0; + + const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/clockskew" }; + std::unique_ptr<FileRequest> req1 = fs.request(resource, [&](Response res) { + switch (counter++) { + case 0: { + EXPECT_EQ(nullptr, res.error); + EXPECT_GT(SystemClock::now(), res.expires); + } break; + case 1: { + EXPECT_EQ(nullptr, res.error); + + auto now = SystemClock::now(); + EXPECT_LT(now + Seconds(40), res.expires) << "Expiration not interpolated to 60s"; + EXPECT_GT(now + Seconds(80), res.expires) << "Expiration not interpolated to 60s"; + + loop.stop(); + } break; + } + }); + + loop.run(); + + HTTPRetryOnClockSkew.finish(); +} |