convert DefaultFileSource to use util::Thread<>

This commit is contained in:
Konstantin Käfer
2015-04-10 22:37:27 +02:00
parent bd531b9e08
commit 4c7132337f
30 changed files with 164 additions and 243 deletions

View File

@@ -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).