diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-01-28 14:55:58 +0200 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2020-01-28 14:55:58 +0200 |
commit | 499a15e17a2f47aaa0841f191302d36cd1c37c77 (patch) | |
tree | 97b1b4240027cd6f899f5bab57129b0a40a10a29 | |
parent | 2d5b60294f65ff3262a86492cf74b7c503403c26 (diff) | |
download | qtlocation-mapboxgl-upstream/alexshalamov_flaky_unit_test.tar.gz |
[core] Start processing requests once all resources are in dbupstream/alexshalamov_flaky_unit_test
-rw-r--r-- | test/storage/main_resource_loader.test.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/storage/main_resource_loader.test.cpp b/test/storage/main_resource_loader.test.cpp index c5f1a9c707..96ca7afa99 100644 --- a/test/storage/main_resource_loader.test.cpp +++ b/test/storage/main_resource_loader.test.cpp @@ -678,6 +678,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CachedResourceLowPriority)) { auto dbfs = FileSourceManager::get()->getFileSource(FileSourceType::Database, ResourceOptions{}); auto onlineFs = FileSourceManager::get()->getFileSource(FileSourceType::Network, ResourceOptions{}); + onlineFs->setProperty("max-concurrent-requests", 1u); + NetworkStatus::Set(NetworkStatus::Status::Offline); + fs.pause(); + // Put existing values into the cache. Resource resource1{Resource::Unknown, "http://127.0.0.1:3000/load/3", {}, Resource::LoadingMethod::All}; response.data = std::make_shared<std::string>("Cached Request 3"); @@ -685,11 +689,10 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CachedResourceLowPriority)) { Resource resource2{Resource::Unknown, "http://127.0.0.1:3000/load/4", {}, Resource::LoadingMethod::All}; response.data = std::make_shared<std::string>("Cached Request 4"); - dbfs->forward(resource2, response); - - onlineFs->setProperty("max-concurrent-requests", 1u); - fs.pause(); - NetworkStatus::Set(NetworkStatus::Status::Offline); + dbfs->forward(resource2, response, [&] { + fs.resume(); + NetworkStatus::Set(NetworkStatus::Status::Online); + }); // Ensure that the online requests for new resources are processed first. Resource nonCached1{Resource::Unknown, "http://127.0.0.1:3000/load/1", {}, Resource::LoadingMethod::All}; @@ -737,8 +740,5 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CachedResourceLowPriority)) { EXPECT_EQ("Request 2", *res.data); }); - fs.resume(); - NetworkStatus::Set(NetworkStatus::Status::Online); - loop.run(); } |