From 8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 21 Jan 2015 19:30:58 +0100 Subject: rearrange tests and add storage tests --- test/storage/http_cancel.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/storage/http_cancel.cpp (limited to 'test/storage/http_cancel.cpp') 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 + +#include +#include + +#include + +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); +} -- cgit v1.2.1