From a469c93ae575ecc32a5f76a8a7add9a9883ce051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 24 Jan 2018 08:34:05 -0800 Subject: [core] align implementations of local and asset file source --- test/storage/local_file_source.test.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/storage/local_file_source.test.cpp') 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 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; -- cgit v1.2.1