diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-09-11 13:40:40 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-09-11 14:29:26 +0300 |
commit | 788508984fa35b97129cd4ef310986c5d15f30a8 (patch) | |
tree | 1cc5d2679c6ff583fb543a238484408a7019580c /test | |
parent | dfaa859d9957028c24a27fe33f6760a0096d5cb1 (diff) | |
download | qtlocation-mapboxgl-788508984fa35b97129cd4ef310986c5d15f30a8.tar.gz |
[test] Added style light setProperty tests
Diffstat (limited to 'test')
-rw-r--r-- | test/style/conversion/light.test.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/style/conversion/light.test.cpp b/test/style/conversion/light.test.cpp index 092c476277..e49667f319 100644 --- a/test/style/conversion/light.test.cpp +++ b/test/style/conversion/light.test.cpp @@ -5,8 +5,10 @@ #include <mbgl/style/conversion/light.hpp> #include <mbgl/style/conversion_impl.hpp> #include <mbgl/style/position.hpp> +#include <mbgl/style/rapidjson_conversion.hpp> #include <mbgl/util/color.hpp> #include <mbgl/util/chrono.hpp> +#include <mbgl/util/rapidjson.hpp> #include <array> @@ -24,6 +26,27 @@ TEST(StyleConversion, Light) { { auto light = parseLight("{}"); ASSERT_TRUE((bool) light); + + const mbgl::JSValue colorValue("blue"); + light->setProperty("color", &colorValue); + + ASSERT_FALSE(light->getColor().isUndefined()); + ASSERT_TRUE(light->getColor().isConstant()); + ASSERT_EQ(light->getColor().asConstant(), mbgl::Color::blue()); + + const mbgl::JSValue intensityValue(0.5); + light->setProperty("intensity", &intensityValue); + ASSERT_FALSE(light->getIntensity().isUndefined()); + ASSERT_TRUE(light->getIntensity().isConstant()); + ASSERT_EQ(light->getIntensity().asConstant(), 0.5); + + mbgl::JSValue::AllocatorType allocator; + const mbgl::JSValue positionValue(std::move(mbgl::JSValue(rapidjson::kArrayType).PushBack(1.f, allocator).PushBack(2.f, allocator).PushBack(3.f, allocator).Move())); + light->setProperty("position", &positionValue); + ASSERT_FALSE(light->getPosition().isUndefined()); + ASSERT_TRUE(light->getPosition().isConstant()); + std::array<float, 3> expected{{ 1.f, 2.f, 3.f }}; + ASSERT_EQ(light->getPosition().asConstant(), mbgl::style::Position({ expected })); } { |