summaryrefslogtreecommitdiff
path: root/test/storage/local_file_source.test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/storage/local_file_source.test.cpp')
-rw-r--r--test/storage/local_file_source.test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/storage/local_file_source.test.cpp b/test/storage/local_file_source.test.cpp
index 4d509e6c7d..e1756f8e7d 100644
--- a/test/storage/local_file_source.test.cpp
+++ b/test/storage/local_file_source.test.cpp
@@ -20,6 +20,15 @@ std::string toAbsoluteURL(const std::string& fileName) {
using namespace mbgl;
+TEST(LocalFileSource, AcceptsURL) {
+ EXPECT_TRUE(LocalFileSource::acceptsURL("file://empty"));
+ EXPECT_TRUE(LocalFileSource::acceptsURL("file:///test"));
+ EXPECT_FALSE(LocalFileSource::acceptsURL("flie://foo"));
+ EXPECT_FALSE(LocalFileSource::acceptsURL("file:"));
+ EXPECT_FALSE(LocalFileSource::acceptsURL("style.json"));
+ EXPECT_FALSE(LocalFileSource::acceptsURL(""));
+}
+
TEST(LocalFileSource, EmptyFile) {
util::RunLoop loop;
@@ -69,6 +78,23 @@ TEST(LocalFileSource, NonExistentFile) {
loop.run();
}
+TEST(LocalFileSource, InvalidURL) {
+ util::RunLoop loop;
+
+ LocalFileSource fs;
+
+ std::unique_ptr<AsyncRequest> req = fs.request({ Resource::Unknown, "test://wrong-scheme" }, [&](Response res) {
+ req.reset();
+ ASSERT_NE(nullptr, res.error);
+ EXPECT_EQ(Response::Error::Reason::Other, res.error->reason);
+ EXPECT_EQ("Invalid file URL", res.error->message);
+ ASSERT_FALSE(res.data.get());
+ loop.stop();
+ });
+
+ loop.run();
+}
+
TEST(LocalFileSource, ReadDirectory) {
util::RunLoop loop;