summaryrefslogtreecommitdiff
path: root/test/storage
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-02-21 15:45:43 +0200
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-02-26 03:20:51 +0200
commitc20b99f9a40b8b8632c34d67a1da104799506fe8 (patch)
tree3c85a8c781570c915b601cad442fda6d2eedaf0e /test/storage
parent843cad04fbc0af614289a38b8846935ae2633943 (diff)
downloadqtlocation-mapboxgl-c20b99f9a40b8b8632c34d67a1da104799506fe8.tar.gz
[tests] Add a test for the retry delay on expired response
Diffstat (limited to 'test/storage')
-rw-r--r--test/storage/http_expires.cpp35
1 files changed, 35 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();
+}