diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-02-21 15:45:43 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-02-26 03:20:51 +0200 |
commit | c20b99f9a40b8b8632c34d67a1da104799506fe8 (patch) | |
tree | 3c85a8c781570c915b601cad442fda6d2eedaf0e /test | |
parent | 843cad04fbc0af614289a38b8846935ae2633943 (diff) | |
download | qtlocation-mapboxgl-c20b99f9a40b8b8632c34d67a1da104799506fe8.tar.gz |
[tests] Add a test for the retry delay on expired response
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', |