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.
37 lines
1.0 KiB
C++
37 lines
1.0 KiB
C++
#include "storage.hpp"
|
|
|
|
#include <uv.h>
|
|
|
|
#include <mbgl/storage/default_file_source.hpp>
|
|
|
|
TEST_F(Storage, AssetReadDirectory) {
|
|
SCOPED_TEST(ReadDirectory)
|
|
|
|
using namespace mbgl;
|
|
|
|
#ifdef MBGL_ASSET_ZIP
|
|
DefaultFileSource fs(nullptr, uv_default_loop(), "test/fixtures/storage/assets.zip");
|
|
#else
|
|
DefaultFileSource fs(nullptr, uv_default_loop());
|
|
#endif
|
|
|
|
auto &env = *static_cast<const Environment *>(nullptr);
|
|
|
|
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());
|
|
EXPECT_EQ(0, res.expires);
|
|
EXPECT_EQ(0, res.modified);
|
|
EXPECT_EQ("", res.etag);
|
|
#ifdef MBGL_ASSET_ZIP
|
|
EXPECT_EQ("No such file", res.message);
|
|
#elif MBGL_ASSET_FS
|
|
EXPECT_EQ("illegal operation on a directory", res.message);
|
|
#endif
|
|
ReadDirectory.finish();
|
|
});
|
|
|
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
|
}
|