diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-09-12 12:02:04 +0100 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-09-13 12:38:59 +0300 |
commit | 22fc8cdc1a657681dab472d9a2678f86b9757eff (patch) | |
tree | 3f555c2b7596460d0004952775da0df88c58d11b /test/map | |
parent | beb67fb7b2119fbda8cf2906bdcc67aa7d7fad65 (diff) | |
download | qtlocation-mapboxgl-22fc8cdc1a657681dab472d9a2678f86b9757eff.tar.gz |
[test] Added Map class accessors tests
Diffstat (limited to 'test/map')
-rw-r--r-- | test/map/map.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/map/map.cpp b/test/map/map.cpp index 314fb947f7..e78160a324 100644 --- a/test/map/map.cpp +++ b/test/map/map.cpp @@ -228,3 +228,37 @@ TEST(Map, RemoveLayer) { test::checkImage("test/fixtures/map/remove_layer", test::render(map)); } + +TEST(Map, Classes) { + MapTest test; + + Map map(test.view, test.fileSource, MapMode::Still); + map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + + EXPECT_FALSE(map.getTransitionOptions().duration); + + auto duration = mbgl::Duration(mbgl::Milliseconds(300)); + map.setTransitionOptions({ duration }); + EXPECT_EQ(map.getTransitionOptions().duration, duration); + + map.addClass("test"); + EXPECT_TRUE(map.hasClass("test")); + + map.removeClass("test"); + EXPECT_TRUE(map.getClasses().empty()); + + std::vector<std::string> classes = { "foo", "bar" }; + map.setClasses(classes); + EXPECT_FALSE(map.hasClass("test")); + EXPECT_TRUE(map.hasClass("foo")); + EXPECT_TRUE(map.hasClass("bar")); + + // Does nothing - same style JSON. + map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + EXPECT_TRUE(map.hasClass("foo")); + EXPECT_EQ(map.getTransitionOptions().duration, duration); + + map.setStyleJSON(util::read_file("test/fixtures/api/water.json")); + EXPECT_TRUE(map.getClasses().empty()); + EXPECT_FALSE(map.getTransitionOptions().duration); +} |