summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-17 17:44:45 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-20 21:54:31 +0300
commitce11fc6cfeb157673befd6a00290e19d6522b01a (patch)
treec673a1a005033e16589be8cf620ab61cfecb0f50
parent64cbc9911dfd43af0c29034d92656b55bc16217a (diff)
downloadqtlocation-mapboxgl-ce11fc6cfeb157673befd6a00290e19d6522b01a.tar.gz
Add OnlineFileSource.RespectMinimumUpdateInterval unit test
-rw-r--r--test/storage/online_file_source.test.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/storage/online_file_source.test.cpp b/test/storage/online_file_source.test.cpp
index 1bed5f9618..050b9d0f3f 100644
--- a/test/storage/online_file_source.test.cpp
+++ b/test/storage/online_file_source.test.cpp
@@ -217,6 +217,25 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectPriorExpires)) {
loop.run();
}
+TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectMinimumUpdateInterval)) {
+ util::RunLoop loop;
+ std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();
+
+ auto start = util::now();
+ Resource resource{Resource::Unknown, "http://127.0.0.1:3000/test"};
+ resource.priorExpires = start + std::chrono::duration_cast<Seconds>(Milliseconds(100));
+ resource.minimumUpdateInterval = Seconds(1);
+
+ std::unique_ptr<AsyncRequest> req = fs->request(resource, [&](Response) {
+ auto wait = util::now() - start;
+ EXPECT_GE(wait, resource.minimumUpdateInterval);
+ EXPECT_LT(wait, resource.minimumUpdateInterval + Milliseconds(10));
+ loop.stop();
+ });
+
+ loop.run();
+}
+
TEST(OnlineFileSource, TEST_REQUIRES_SERVER(Load)) {
util::RunLoop loop;
std::unique_ptr<FileSource> fs = std::make_unique<OnlineFileSource>();