diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-08-24 19:57:16 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-08-24 20:02:39 +0300 |
commit | 1d7a5b0fe0bc3d69cc77cfb654876ad3db2ea33a (patch) | |
tree | 2584ce377d31eb24a0af06a11b94d64d4de7cea5 /test | |
parent | c98f4f476bd590bdfd78409d428459e40347302a (diff) | |
download | qtlocation-mapboxgl-1d7a5b0fe0bc3d69cc77cfb654876ad3db2ea33a.tar.gz |
[tests] Add unit test for style loading failures
Diffstat (limited to 'test')
-rw-r--r-- | test/map/map.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/map/map.cpp b/test/map/map.cpp index 7e0bbd0234..314fb947f7 100644 --- a/test/map/map.cpp +++ b/test/map/map.cpp @@ -60,11 +60,20 @@ TEST(Map, SetStyleInvalidJSON) { Log::setObserver(std::make_unique<FixtureLogObserver>()); + bool fail = false; + test.view.setMapChangeCallback([&](MapChange change) { + if (change == mbgl::MapChangeDidFailLoadingMap) { + fail = true; + } + }); + { Map map(test.view, test.fileSource, MapMode::Still); map.setStyleJSON("invalid"); } + EXPECT_TRUE(fail); + auto observer = Log::removeObserver(); auto flo = dynamic_cast<FixtureLogObserver*>(observer.get()); EXPECT_EQ(1u, flo->count({ EventSeverity::Error, Event::ParseStyle, -1, @@ -73,6 +82,29 @@ TEST(Map, SetStyleInvalidJSON) { EXPECT_TRUE(unchecked.empty()) << unchecked; } +TEST(Map, SetStyleInvalidURL) { + MapTest test; + + test.fileSource.styleResponse = [] (const Resource&) { + Response response; + response.error = std::make_unique<Response::Error>( + Response::Error::Reason::Other, + "Failed by the test case"); + return response; + }; + + test.view.setMapChangeCallback([&](MapChange change) { + if (change == mbgl::MapChangeDidFailLoadingMap) { + test.runLoop.stop(); + } + }); + + Map map(test.view, test.fileSource, MapMode::Still); + map.setStyleURL("mapbox://bar"); + + test.runLoop.run(); +} + TEST(Map, DoubleStyleLoad) { MapTest test; |