we are now scoping all file requests to an environment object. The FileSource implementation treats this as an opaque pointer, but allows canceling all Requests that are associated with that pointer. This is necessary to abort all file requests that originated from a particular Map object. Aborting a file request is different from canceling a file request: A canceled request doesn't have its callback called, while an aborted request will have its callback called with an error, indicating that the environment is going to be shut down.
30 lines
814 B
C++
30 lines
814 B
C++
#include "storage.hpp"
|
|
|
|
#include <uv.h>
|
|
|
|
#include <mbgl/storage/default_file_source.hpp>
|
|
|
|
TEST_F(Storage, HTTPOtherLoop) {
|
|
SCOPED_TEST(HTTPOtherLoop)
|
|
|
|
using namespace mbgl;
|
|
|
|
// This file source launches a separate thread to do the processing.
|
|
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,
|
|
[&](const Response &res) {
|
|
EXPECT_EQ(Response::Successful, res.status);
|
|
EXPECT_EQ("Hello World!", res.data);
|
|
EXPECT_EQ(0, res.expires);
|
|
EXPECT_EQ(0, res.modified);
|
|
EXPECT_EQ("", res.etag);
|
|
EXPECT_EQ("", res.message);
|
|
HTTPOtherLoop.finish();
|
|
});
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
}
|