diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/storage/http_expires.cpp | 35 | ||||
-rw-r--r-- | test/test.gypi | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/test/storage/http_expires.cpp b/test/storage/http_expires.cpp new file mode 100644 index 0000000000..0a37df8e37 --- /dev/null +++ b/test/storage/http_expires.cpp @@ -0,0 +1,35 @@ +#include "storage.hpp" + +#include <mbgl/storage/online_file_source.hpp> +#include <mbgl/util/chrono.hpp> +#include <mbgl/util/run_loop.hpp> +#include <mbgl/util/timer.hpp> + +TEST_F(Storage, HTTPRetryDelayOnExpiredTile) { + SCOPED_TEST(HTTPRetryDelayOnExpiredTile) + + using namespace mbgl; + + util::RunLoop loop; + OnlineFileSource fs; + + int counter = 0; + + const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test?expires=10000" }; + std::unique_ptr<FileRequest> req = fs.request(resource, [&](Response res) { + counter++; + EXPECT_EQ(nullptr, res.error); + EXPECT_GT(SystemClock::now(), res.expires); + }); + + util::Timer timer; + timer.start(Milliseconds(500), Duration::zero(), [&] () { + loop.stop(); + }); + + loop.run(); + + EXPECT_EQ(1, counter); + + HTTPRetryDelayOnExpiredTile.finish(); +} diff --git a/test/test.gypi b/test/test.gypi index 32b686a80d..d85faf2f5a 100644 --- a/test/test.gypi +++ b/test/test.gypi @@ -77,6 +77,7 @@ 'storage/headers.cpp', 'storage/http_cancel.cpp', 'storage/http_error.cpp', + 'storage/http_expires.cpp', 'storage/http_header_parsing.cpp', 'storage/http_issue_1369.cpp', 'storage/http_load.cpp', |