diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-01-21 19:30:58 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-02-04 10:49:05 +0100 |
commit | 8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd (patch) | |
tree | e3f0e8f4b16071667c6a4fdf706740335500dbc6 /test/storage/http_cancel.cpp | |
parent | 5503aef6907b1fea74d6bdbe696f02b9f016f752 (diff) | |
download | qtlocation-mapboxgl-8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd.tar.gz |
rearrange tests and add storage tests
Diffstat (limited to 'test/storage/http_cancel.cpp')
-rw-r--r-- | test/storage/http_cancel.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/storage/http_cancel.cpp b/test/storage/http_cancel.cpp new file mode 100644 index 0000000000..4da70b965b --- /dev/null +++ b/test/storage/http_cancel.cpp @@ -0,0 +1,50 @@ +#include "../util.hpp" + +#include <uv.h> + +#include <mbgl/storage/default/default_file_source.hpp> +#include <mbgl/storage/network_status.hpp> + +#include <cmath> + +TEST(Storage, HTTPCancel) { + SCOPED_TEST(HTTPCancel) + + using namespace mbgl; + + DefaultFileSource fs(nullptr, uv_default_loop()); + + auto req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/test" }, uv_default_loop(), [&](const Response &) { + ADD_FAILURE() << "Callback should not be called"; + }); + + fs.cancel(req); + HTTPCancel.finish(); + + uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} + +TEST(Storage, HTTPCancelMultiple) { + SCOPED_TEST(HTTPCancelMultiple) + + using namespace mbgl; + + DefaultFileSource fs(nullptr, uv_default_loop()); + + const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/test" }; + auto req2 = fs.request(resource, uv_default_loop(), [&](const Response &) { + ADD_FAILURE() << "Callback should not be called"; + }); + fs.request(resource, uv_default_loop(), [&](const Response &res) { + EXPECT_EQ(res.status, Response::Successful); + EXPECT_EQ(res.data, "Hello World!"); + EXPECT_EQ(res.expires, 0); + EXPECT_EQ(res.modified, 0); + EXPECT_EQ(res.etag, ""); + EXPECT_EQ(res.message, ""); + HTTPCancelMultiple.finish(); + }); + fs.cancel(req2); + + uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} |