diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-01-24 08:34:05 -0800 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-01-24 16:28:31 -0800 |
commit | a469c93ae575ecc32a5f76a8a7add9a9883ce051 (patch) | |
tree | 8b997654bbd09a1fc91beeb919df9f3fc85ca9bc /test/storage/local_file_source.test.cpp | |
parent | 2502a3ab2bf793dcb3a41deb5c93290b3c6ce5fd (diff) | |
download | qtlocation-mapboxgl-upstream/local-asset-filesource.tar.gz |
[core] align implementations of local and asset file sourceupstream/local-asset-filesource
Diffstat (limited to 'test/storage/local_file_source.test.cpp')
-rw-r--r-- | test/storage/local_file_source.test.cpp | 26 |
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; |