summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2015-07-08 16:03:45 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2015-07-08 23:48:05 +0300
commit0014c0bd8d1a44946f68b4aef72b6451de25187a (patch)
treebf8e1814f5e83f51b063aefde064bd0de0a64635 /test
parentaa51c15670f2a304eb270f64bb65aff41ac3f2a6 (diff)
downloadqtlocation-mapboxgl-0014c0bd8d1a44946f68b4aef72b6451de25187a.tar.gz
Make MockFileSource behave more like the real one
This will help make some bugs more reproducible on the tests as things will happen more asynchronously.
Diffstat (limited to 'test')
-rw-r--r--test/style/mock_file_source.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/test/style/mock_file_source.cpp b/test/style/mock_file_source.cpp
index 6f368bde52..0637645233 100644
--- a/test/style/mock_file_source.cpp
+++ b/test/style/mock_file_source.cpp
@@ -117,11 +117,13 @@ void MockFileSource::Impl::handleRequest(Request* req) {
void MockFileSource::Impl::cancelRequest(Request* req) {
auto it = std::find(pendingRequests_.begin(), pendingRequests_.end(), req);
if (it != pendingRequests_.end()) {
- (*it)->destruct();
pendingRequests_.erase(it);
} else {
- EXPECT_TRUE(false) << "Should never be reached.";
+ // There is no request for this URL anymore. Likely, the request already completed
+ // before we got around to process the cancelation request.
}
+
+ req->destruct();
}
void MockFileSource::Impl::dispatchPendingRequests() {
@@ -142,7 +144,7 @@ void MockFileSource::setOnRequestDelayedCallback(std::function<void(void)> callb
Request* MockFileSource::request(const Resource& resource, uv_loop_t* loop, Callback callback) {
Request* req = new Request(resource, loop, std::move(callback));
- thread_->invokeSync(&Impl::handleRequest, req);
+ thread_->invoke(&Impl::handleRequest, req);
return req;
}