[test] Added style light setProperty tests

This commit is contained in:
Bruno de Oliveira Abinader
2019-09-11 13:40:40 +03:00
parent dfaa859d99
commit 788508984f

View File

@@ -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 }));
}
{