summaryrefslogtreecommitdiff
path: root/test/storage
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-01-24 08:34:05 -0800
committerKonstantin Käfer <mail@kkaefer.com>2018-01-25 13:45:47 -0800
commitc148a7a0616568b0ae82ab8dc89c1c096af10537 (patch)
tree678bc978cb108a21f9ed22a6b88d33952b0083e7 /test/storage
parentda7759a273c096117e513b249741355865f9af8e (diff)
downloadqtlocation-mapboxgl-c148a7a0616568b0ae82ab8dc89c1c096af10537.tar.gz
[core] align implementations of local and asset file source
Diffstat (limited to 'test/storage')
-rw-r--r--test/storage/asset_file_source.test.cpp26
-rw-r--r--test/storage/local_file_source.test.cpp26
2 files changed, 52 insertions, 0 deletions
diff --git a/test/storage/asset_file_source.test.cpp b/test/storage/asset_file_source.test.cpp
index a39d2963d2..978a41a306 100644
--- a/test/storage/asset_file_source.test.cpp
+++ b/test/storage/asset_file_source.test.cpp
@@ -69,6 +69,15 @@ TEST(AssetFileSource, Load) {
loop.run();
}
+TEST(AssetFileSource, AcceptsURL) {
+ EXPECT_TRUE(AssetFileSource::acceptsURL("asset://empty"));
+ EXPECT_TRUE(AssetFileSource::acceptsURL("asset:///test"));
+ EXPECT_FALSE(AssetFileSource::acceptsURL("assds://foo"));
+ EXPECT_FALSE(AssetFileSource::acceptsURL("asset:"));
+ EXPECT_FALSE(AssetFileSource::acceptsURL("style.json"));
+ EXPECT_FALSE(AssetFileSource::acceptsURL(""));
+}
+
TEST(AssetFileSource, EmptyFile) {
util::RunLoop loop;
@@ -118,6 +127,23 @@ TEST(AssetFileSource, NonExistentFile) {
loop.run();
}
+TEST(AssetFileSource, InvalidURL) {
+ util::RunLoop loop;
+
+ AssetFileSource fs("test/fixtures/storage/assets");
+
+ 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 asset URL", res.error->message);
+ ASSERT_FALSE(res.data.get());
+ loop.stop();
+ });
+
+ loop.run();
+}
+
TEST(AssetFileSource, ReadDirectory) {
util::RunLoop loop;
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;