From 0af3e0e24d131815ae139e2b980d4ba13f58cf4b Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 2 Oct 2018 16:19:15 -0700 Subject: [core] Read style's transition from parser --- src/mbgl/style/parser.hpp | 3 ++- src/mbgl/style/style_impl.cpp | 3 +-- test/style/style.test.cpp | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mbgl/style/parser.hpp b/src/mbgl/style/parser.hpp index 401b5ff513..ec7be038fb 100644 --- a/src/mbgl/style/parser.hpp +++ b/src/mbgl/style/parser.hpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -32,7 +33,7 @@ public: std::vector> sources; std::vector> layers; - TransitionOptions transition; + TransitionOptions transition { { util::DEFAULT_TRANSITION_DURATION } }; Light light; std::string name; diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp index 0c7f924917..5c9edc789f 100644 --- a/src/mbgl/style/style_impl.cpp +++ b/src/mbgl/style/style_impl.cpp @@ -92,8 +92,7 @@ void Style::Impl::parse(const std::string& json_) { layers.clear(); images.clear(); - transitionOptions = {}; - transitionOptions.duration = util::DEFAULT_TRANSITION_DURATION; + transitionOptions = parser.transition; for (auto& source : parser.sources) { addSource(std::move(source)); diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp index f2055c88f8..2371e91107 100644 --- a/test/style/style.test.cpp +++ b/test/style/style.test.cpp @@ -43,6 +43,14 @@ TEST(Style, Properties) { ASSERT_EQ("", style.getName()); ASSERT_EQ(60, *style.getDefaultCamera().pitch); + style.loadJSON(R"STYLE({})STYLE"); + ASSERT_EQ(Milliseconds(300), *style.getTransitionOptions().duration); + ASSERT_EQ(optional {}, style.getTransitionOptions().delay); + + style.loadJSON(R"STYLE({"transition": { "duration": 500, "delay": 50 }})STYLE"); + ASSERT_EQ(Milliseconds(500), *style.getTransitionOptions().duration); + ASSERT_EQ(Milliseconds(50), *style.getTransitionOptions().delay); + style.loadJSON(R"STYLE({"name": 23, "center": {}, "bearing": "north", "zoom": null, "pitch": "wide"})STYLE"); ASSERT_EQ("", style.getName()); ASSERT_EQ(LatLng {}, *style.getDefaultCamera().center); -- cgit v1.2.1