diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-11-13 02:52:53 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2018-11-13 23:26:34 +0200 |
commit | 01d9005c3bab3a725e0be97d545ce6587c53123d (patch) | |
tree | 2549a24e792d3e27d9d29215fb0c3e205a71448c /test | |
parent | 253ba55f1f05a16e90102191e0e8adf636eb198a (diff) | |
download | qtlocation-mapboxgl-01d9005c3bab3a725e0be97d545ce6587c53123d.tar.gz |
[test] Add test for when requesting the same resource many times
This test would have prevented the crash fixed by the previous patch.
Diffstat (limited to 'test')
-rw-r--r-- | test/storage/online_file_source.test.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/storage/online_file_source.test.cpp b/test/storage/online_file_source.test.cpp index 5021a513e3..39582543ef 100644 --- a/test/storage/online_file_source.test.cpp +++ b/test/storage/online_file_source.test.cpp @@ -515,4 +515,22 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequestsMany)) { NetworkStatus::Set(NetworkStatus::Status::Online); loop.run(); -}
\ No newline at end of file +} + +TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RequestSameUrlMultipleTimes)) { + util::RunLoop loop; + OnlineFileSource fs; + + int count = 0; + std::vector<std::unique_ptr<AsyncRequest>> requests; + + for (int i = 0; i < 100; ++i) { + requests.emplace_back(fs.request({ Resource::Unknown, "http://127.0.0.1:3000/load" }, [&](Response) { + if (++count == 100) { + loop.stop(); + } + })); + } + + loop.run(); +} |