summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-04-10 22:37:27 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-04-10 22:37:27 +0200
commit4c7132337f96486a154e75efe394f5a1c06a77a7 (patch)
treea1b49335556b5f09bd51173344899e9f2446597d /test
parentbd531b9e080f3300c6947b0e0e515218bb395f45 (diff)
downloadqtlocation-mapboxgl-4c7132337f96486a154e75efe394f5a1c06a77a7.tar.gz
convert DefaultFileSource to use util::Thread<>
Diffstat (limited to 'test')
-rw-r--r--test/headless/headless.cpp5
-rw-r--r--test/storage/cache_response.cpp6
-rw-r--r--test/storage/cache_revalidate.cpp14
-rw-r--r--test/storage/directory_reading.cpp7
-rw-r--r--test/storage/file_reading.cpp19
-rw-r--r--test/storage/http_cancel.cpp15
-rw-r--r--test/storage/http_coalescing.cpp5
-rw-r--r--test/storage/http_environment.cpp9
-rw-r--r--test/storage/http_error.cpp7
-rw-r--r--test/storage/http_header_parsing.cpp7
-rw-r--r--test/storage/http_load.cpp5
-rw-r--r--test/storage/http_noloop.cpp5
-rw-r--r--test/storage/http_other_loop.cpp5
-rw-r--r--test/storage/http_reading.cpp15
14 files changed, 68 insertions, 56 deletions
diff --git a/test/headless/headless.cpp b/test/headless/headless.cpp
index c47b9349a8..76c1264333 100644
--- a/test/headless/headless.cpp
+++ b/test/headless/headless.cpp
@@ -4,6 +4,7 @@
#include <mbgl/map/map.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/std.hpp>
+#include <mbgl/util/thread.hpp>
#include <mbgl/util/io.hpp>
#include <rapidjson/document.h>
@@ -139,8 +140,8 @@ TEST_P(HeadlessTest, render) {
}
HeadlessView view(display);
- mbgl::DefaultFileSource fileSource(nullptr);
- Map map(view, fileSource);
+ util::Thread<DefaultFileSource> fileSource(nullptr);
+ Map map(view, *fileSource);
map.setClasses(classes);
map.setStyleJSON(style, "test/suite");
diff --git a/test/storage/cache_response.cpp b/test/storage/cache_response.cpp
index f5d7c4bf3c..46083e2f93 100644
--- a/test/storage/cache_response.cpp
+++ b/test/storage/cache_response.cpp
@@ -12,12 +12,12 @@ TEST_F(Storage, CacheResponse) {
using namespace mbgl;
util::Thread<SQLiteCache> cache(":memory:");
- DefaultFileSource fs(cache, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(cache);
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/cache" };
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request(resource, uv_default_loop(), env, [&](const Response &res) {
+ fs->request(resource, uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ("Response 1", res.data);
EXPECT_LT(0, res.expires);
@@ -25,7 +25,7 @@ TEST_F(Storage, CacheResponse) {
EXPECT_EQ("", res.etag);
EXPECT_EQ("", res.message);
- fs.request(resource, uv_default_loop(), env, [&, res](const Response &res2) {
+ fs->request(resource, uv_default_loop(), env, [&, res](const Response &res2) {
EXPECT_EQ(res.status, res2.status);
EXPECT_EQ(res.data, res2.data);
EXPECT_EQ(res.expires, res2.expires);
diff --git a/test/storage/cache_revalidate.cpp b/test/storage/cache_revalidate.cpp
index 29f25eb775..901c151f14 100644
--- a/test/storage/cache_revalidate.cpp
+++ b/test/storage/cache_revalidate.cpp
@@ -14,12 +14,12 @@ TEST_F(Storage, CacheRevalidate) {
using namespace mbgl;
util::Thread<SQLiteCache> cache(":memory:");
- DefaultFileSource fs(cache);
+ util::Thread<DefaultFileSource> fs(cache);
auto &env = *static_cast<const Environment *>(nullptr);
const Resource revalidateSame { Resource::Unknown, "http://127.0.0.1:3000/revalidate-same" };
- fs.request(revalidateSame, uv_default_loop(), env, [&](const Response &res) {
+ fs->request(revalidateSame, uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ("Response", res.data);
EXPECT_EQ(0, res.expires);
@@ -27,7 +27,7 @@ TEST_F(Storage, CacheRevalidate) {
EXPECT_EQ("snowfall", res.etag);
EXPECT_EQ("", res.message);
- fs.request(revalidateSame, uv_default_loop(), env, [&, res](const Response &res2) {
+ fs->request(revalidateSame, uv_default_loop(), env, [&, res](const Response &res2) {
EXPECT_EQ(Response::Successful, res2.status);
EXPECT_EQ("Response", res2.data);
// We use this to indicate that a 304 reply came back.
@@ -43,7 +43,7 @@ TEST_F(Storage, CacheRevalidate) {
const Resource revalidateModified{ Resource::Unknown,
"http://127.0.0.1:3000/revalidate-modified" };
- fs.request(revalidateModified, uv_default_loop(), env, [&](const Response &res) {
+ fs->request(revalidateModified, uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ("Response", res.data);
EXPECT_EQ(0, res.expires);
@@ -51,7 +51,7 @@ TEST_F(Storage, CacheRevalidate) {
EXPECT_EQ("", res.etag);
EXPECT_EQ("", res.message);
- fs.request(revalidateModified, uv_default_loop(), env, [&, res](const Response &res2) {
+ fs->request(revalidateModified, uv_default_loop(), env, [&, res](const Response &res2) {
EXPECT_EQ(Response::Successful, res2.status);
EXPECT_EQ("Response", res2.data);
// We use this to indicate that a 304 reply came back.
@@ -65,7 +65,7 @@ TEST_F(Storage, CacheRevalidate) {
});
const Resource revalidateEtag { Resource::Unknown, "http://127.0.0.1:3000/revalidate-etag" };
- fs.request(revalidateEtag, uv_default_loop(), env, [&](const Response &res) {
+ fs->request(revalidateEtag, uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ("Response 1", res.data);
EXPECT_EQ(0, res.expires);
@@ -73,7 +73,7 @@ TEST_F(Storage, CacheRevalidate) {
EXPECT_EQ("response-1", res.etag);
EXPECT_EQ("", res.message);
- fs.request(revalidateEtag, uv_default_loop(), env, [&, res](const Response &res2) {
+ fs->request(revalidateEtag, uv_default_loop(), env, [&, res](const Response &res2) {
EXPECT_EQ(Response::Successful, res2.status);
EXPECT_EQ("Response 2", res2.data);
EXPECT_EQ(0, res2.expires);
diff --git a/test/storage/directory_reading.cpp b/test/storage/directory_reading.cpp
index a955648462..4264129b22 100644
--- a/test/storage/directory_reading.cpp
+++ b/test/storage/directory_reading.cpp
@@ -3,6 +3,7 @@
#include <uv.h>
#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/util/thread.hpp>
TEST_F(Storage, AssetReadDirectory) {
SCOPED_TEST(ReadDirectory)
@@ -10,14 +11,14 @@ TEST_F(Storage, AssetReadDirectory) {
using namespace mbgl;
#ifdef MBGL_ASSET_ZIP
- DefaultFileSource fs(nullptr, uv_default_loop(), "test/fixtures/storage/assets.zip");
+ util::Thread<DefaultFileSource> fs(nullptr, "test/fixtures/storage/assets.zip");
#else
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
#endif
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage" }, uv_default_loop(),
+ fs->request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage" }, uv_default_loop(),
env, [&](const Response &res) {
EXPECT_EQ(Response::Error, res.status);
EXPECT_EQ(0ul, res.data.size());
diff --git a/test/storage/file_reading.cpp b/test/storage/file_reading.cpp
index cca072b27a..de834798de 100644
--- a/test/storage/file_reading.cpp
+++ b/test/storage/file_reading.cpp
@@ -4,6 +4,7 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/platform/platform.hpp>
+#include <mbgl/util/thread.hpp>
TEST_F(Storage, AssetEmptyFile) {
SCOPED_TEST(EmptyFile)
@@ -11,14 +12,14 @@ TEST_F(Storage, AssetEmptyFile) {
using namespace mbgl;
#ifdef MBGL_ASSET_ZIP
- DefaultFileSource fs(nullptr, uv_default_loop(), "test/fixtures/storage/assets.zip");
+ util::Thread<DefaultFileSource> fs(nullptr, "test/fixtures/storage/assets.zip");
#else
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
#endif
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage/empty" }, uv_default_loop(),
+ fs->request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage/empty" }, uv_default_loop(),
env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ(0ul, res.data.size());
@@ -38,14 +39,14 @@ TEST_F(Storage, AssetNonEmptyFile) {
using namespace mbgl;
#ifdef MBGL_ASSET_ZIP
- DefaultFileSource fs(nullptr, uv_default_loop(), "test/fixtures/storage/assets.zip");
+ util::Thread<DefaultFileSource> fs(nullptr, "test/fixtures/storage/assets.zip");
#else
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
#endif
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage/nonempty" },
+ fs->request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage/nonempty" },
uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ(16ul, res.data.size());
@@ -66,14 +67,14 @@ TEST_F(Storage, AssetNonExistentFile) {
using namespace mbgl;
#ifdef MBGL_ASSET_ZIP
- DefaultFileSource fs(nullptr, uv_default_loop(), "test/fixtures/storage/assets.zip");
+ util::Thread<DefaultFileSource> fs(nullptr, "test/fixtures/storage/assets.zip");
#else
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
#endif
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage/does_not_exist" },
+ fs->request({ Resource::Unknown, "asset://TEST_DATA/fixtures/storage/does_not_exist" },
uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Error, res.status);
EXPECT_EQ(0ul, res.data.size());
diff --git a/test/storage/http_cancel.cpp b/test/storage/http_cancel.cpp
index d0dac8ccdb..33edbdf7c4 100644
--- a/test/storage/http_cancel.cpp
+++ b/test/storage/http_cancel.cpp
@@ -4,6 +4,7 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/network_status.hpp>
+#include <mbgl/util/thread.hpp>
#include <cmath>
@@ -12,15 +13,15 @@ TEST_F(Storage, HTTPCancel) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
auto req =
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
[&](const Response &) { ADD_FAILURE() << "Callback should not be called"; });
- fs.cancel(req);
+ fs->cancel(req);
HTTPCancel.finish();
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
@@ -31,15 +32,15 @@ TEST_F(Storage, HTTPCancelMultiple) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" };
- auto req2 = fs.request(resource, uv_default_loop(), env, [&](const Response &) {
+ auto req2 = fs->request(resource, uv_default_loop(), env, [&](const Response &) {
ADD_FAILURE() << "Callback should not be called";
});
- fs.request(resource, uv_default_loop(), env, [&](const Response &res) {
+ fs->request(resource, uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ("Hello World!", res.data);
EXPECT_EQ(0, res.expires);
@@ -48,7 +49,7 @@ TEST_F(Storage, HTTPCancelMultiple) {
EXPECT_EQ("", res.message);
HTTPCancelMultiple.finish();
});
- fs.cancel(req2);
+ fs->cancel(req2);
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
}
diff --git a/test/storage/http_coalescing.cpp b/test/storage/http_coalescing.cpp
index 9eaea70e11..5164117f52 100644
--- a/test/storage/http_coalescing.cpp
+++ b/test/storage/http_coalescing.cpp
@@ -3,6 +3,7 @@
#include <uv.h>
#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/util/thread.hpp>
TEST_F(Storage, HTTPCoalescing) {
SCOPED_TEST(HTTPCoalescing)
@@ -12,7 +13,7 @@ TEST_F(Storage, HTTPCoalescing) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
@@ -43,7 +44,7 @@ TEST_F(Storage, HTTPCoalescing) {
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" };
for (int i = 0; i < total; i++) {
- fs.request(resource, uv_default_loop(), env, complete);
+ fs->request(resource, uv_default_loop(), env, complete);
}
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
diff --git a/test/storage/http_environment.cpp b/test/storage/http_environment.cpp
index efd7b78ad4..b08a8071c4 100644
--- a/test/storage/http_environment.cpp
+++ b/test/storage/http_environment.cpp
@@ -4,6 +4,7 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/network_status.hpp>
+#include <mbgl/util/thread.hpp>
#include <cmath>
@@ -13,7 +14,7 @@ TEST_F(Storage, HTTPCancelEnvironment) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
// Create two fake environment pointers. The FileSource implementation treats these as opaque
// pointers and doesn't reach into them.
@@ -23,7 +24,7 @@ TEST_F(Storage, HTTPCancelEnvironment) {
const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/delayed" };
// Environment 1
- fs.request(resource, uv_default_loop(), env1, [&](const Response &res) {
+ fs->request(resource, uv_default_loop(), env1, [&](const Response &res) {
// This environment gets aborted below. This means the request is marked as failing and
// will return an error here.
EXPECT_EQ(Response::Error, res.status);
@@ -36,7 +37,7 @@ TEST_F(Storage, HTTPCancelEnvironment) {
});
// Environment 2
- fs.request(resource, uv_default_loop(), env2, [&](const Response &res) {
+ fs->request(resource, uv_default_loop(), env2, [&](const Response &res) {
// The same request as above, but in a different environment which doesn't get aborted. This
// means the request should succeed.
EXPECT_EQ(Response::Successful, res.status);
@@ -48,7 +49,7 @@ TEST_F(Storage, HTTPCancelEnvironment) {
HTTPRetainedEnvironment.finish();
});
- fs.abort(env1);
+ fs->abort(env1);
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
}
diff --git a/test/storage/http_error.cpp b/test/storage/http_error.cpp
index abaeff5396..bd5ef9811d 100644
--- a/test/storage/http_error.cpp
+++ b/test/storage/http_error.cpp
@@ -4,6 +4,7 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/storage/network_status.hpp>
+#include <mbgl/util/thread.hpp>
#include <cmath>
@@ -20,13 +21,13 @@ TEST_F(Storage, HTTPError) {
}, 500, 500);
uv_unref((uv_handle_t *)&statusChange);
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
auto start = uv_hrtime();
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/temporary-error" }, uv_default_loop(),
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/temporary-error" }, uv_default_loop(),
env, [&](const Response &res) {
const auto duration = double(uv_hrtime() - start) / 1e9;
EXPECT_LT(1, duration) << "Backoff timer didn't wait 1 second";
@@ -41,7 +42,7 @@ TEST_F(Storage, HTTPError) {
HTTPTemporaryError.finish();
});
- fs.request({ Resource::Unknown, "http://127.0.0.1:3001/" }, uv_default_loop(), env,
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3001/" }, uv_default_loop(), env,
[&](const Response &res) {
const auto duration = double(uv_hrtime() - start) / 1e9;
// 1.5 seconds == 4 retries, with a 500ms timeout (see above).
diff --git a/test/storage/http_header_parsing.cpp b/test/storage/http_header_parsing.cpp
index e4d86fcc27..df1fb1fc68 100644
--- a/test/storage/http_header_parsing.cpp
+++ b/test/storage/http_header_parsing.cpp
@@ -4,6 +4,7 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/chrono.hpp>
+#include <mbgl/util/thread.hpp>
#include <cmath>
@@ -13,11 +14,11 @@ TEST_F(Storage, HTTPHeaderParsing) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown,
+ fs->request({ Resource::Unknown,
"http://127.0.0.1:3000/test?modified=1420794326&expires=1420797926&etag=foo" },
uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
@@ -32,7 +33,7 @@ TEST_F(Storage, HTTPHeaderParsing) {
int64_t now = std::chrono::duration_cast<std::chrono::seconds>(
SystemClock::now().time_since_epoch()).count();
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test?cachecontrol=max-age=120" },
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/test?cachecontrol=max-age=120" },
uv_default_loop(), env, [&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ("Hello World!", res.data);
diff --git a/test/storage/http_load.cpp b/test/storage/http_load.cpp
index 2680daf93b..b037867233 100644
--- a/test/storage/http_load.cpp
+++ b/test/storage/http_load.cpp
@@ -3,13 +3,14 @@
#include <uv.h>
#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/util/thread.hpp>
TEST_F(Storage, HTTPLoad) {
SCOPED_TEST(HTTPLoad)
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
@@ -19,7 +20,7 @@ TEST_F(Storage, HTTPLoad) {
std::function<void()> req = [&]() {
const auto current = number++;
- fs.request({ Resource::Unknown,
+ fs->request({ Resource::Unknown,
std::string("http://127.0.0.1:3000/load/") + std::to_string(current) },
uv_default_loop(), env, [&, current](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
diff --git a/test/storage/http_noloop.cpp b/test/storage/http_noloop.cpp
index cd4ebeb2c4..0f75c106fe 100644
--- a/test/storage/http_noloop.cpp
+++ b/test/storage/http_noloop.cpp
@@ -4,13 +4,14 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/uv.hpp>
+#include <mbgl/util/thread.hpp>
TEST_F(Storage, HTTPNoLoop) {
SCOPED_TEST(HTTPNoLoop)
using namespace mbgl;
- DefaultFileSource fs(nullptr);
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
@@ -22,7 +23,7 @@ TEST_F(Storage, HTTPNoLoop) {
uv::close(as);
});
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/temporary-error" }, nullptr, env,
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/temporary-error" }, nullptr, env,
[&](const Response &res) {
EXPECT_NE(uv_thread_self(), mainThread) << "Response was called in the same thread";
EXPECT_EQ(Response::Successful, res.status);
diff --git a/test/storage/http_other_loop.cpp b/test/storage/http_other_loop.cpp
index 9ad673cf79..11fa2f324a 100644
--- a/test/storage/http_other_loop.cpp
+++ b/test/storage/http_other_loop.cpp
@@ -3,6 +3,7 @@
#include <uv.h>
#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/util/thread.hpp>
TEST_F(Storage, HTTPOtherLoop) {
SCOPED_TEST(HTTPOtherLoop)
@@ -10,11 +11,11 @@ TEST_F(Storage, HTTPOtherLoop) {
using namespace mbgl;
// This file source launches a separate thread to do the processing.
- DefaultFileSource fs(nullptr);
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
[&](const Response &res) {
EXPECT_EQ(Response::Successful, res.status);
EXPECT_EQ("Hello World!", res.data);
diff --git a/test/storage/http_reading.cpp b/test/storage/http_reading.cpp
index a6a5775825..1ba34801cd 100644
--- a/test/storage/http_reading.cpp
+++ b/test/storage/http_reading.cpp
@@ -3,6 +3,7 @@
#include <uv.h>
#include <mbgl/storage/default_file_source.hpp>
+#include <mbgl/util/thread.hpp>
TEST_F(Storage, HTTPReading) {
SCOPED_TEST(HTTPTest)
@@ -10,13 +11,13 @@ TEST_F(Storage, HTTPReading) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
const auto mainThread = uv_thread_self();
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
[&](const Response &res) {
EXPECT_EQ(uv_thread_self(), mainThread);
EXPECT_EQ(Response::Successful, res.status);
@@ -28,7 +29,7 @@ TEST_F(Storage, HTTPReading) {
HTTPTest.finish();
});
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/doesnotexist" }, uv_default_loop(),
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/doesnotexist" }, uv_default_loop(),
env, [&](const Response &res) {
EXPECT_EQ(uv_thread_self(), mainThread);
EXPECT_EQ(Response::Error, res.status);
@@ -47,11 +48,11 @@ TEST_F(Storage, HTTPNoCallback) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), env,
nullptr);
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
@@ -64,11 +65,11 @@ TEST_F(Storage, HTTPNoCallbackNoLoop) {
using namespace mbgl;
- DefaultFileSource fs(nullptr, uv_default_loop());
+ util::Thread<DefaultFileSource> fs(nullptr);
auto &env = *static_cast<const Environment *>(nullptr);
- fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, env, nullptr);
+ fs->request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, env, nullptr);
uv_run(uv_default_loop(), UV_RUN_DEFAULT);