diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-04-17 17:44:45 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-04-20 21:54:31 +0300 |
commit | ce11fc6cfeb157673befd6a00290e19d6522b01a (patch) | |
tree | c673a1a005033e16589be8cf620ab61cfecb0f50 | |
parent | 64cbc9911dfd43af0c29034d92656b55bc16217a (diff) | |
download | qtlocation-mapboxgl-ce11fc6cfeb157673befd6a00290e19d6522b01a.tar.gz |
Add OnlineFileSource.RespectMinimumUpdateInterval unit test
-rw-r--r-- | test/storage/online_file_source.test.cpp | 19 |
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>(); |