summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-07-31 14:21:47 -0700
committerGitHub <noreply@github.com>2018-07-31 14:21:47 -0700
commit9bdd765a02de75851a00ab85223d5d582a104757 (patch)
treebcb417a47808a4a94c171b083c7f2e2cce457107 /test
parent885f6e3c02138398d094e49243817a83349b4d50 (diff)
downloadqtlocation-mapboxgl-9bdd765a02de75851a00ab85223d5d582a104757.tar.gz
[core] Merge DataDrivenPropertyValue into PropertyValue (#12513)
Diffstat (limited to 'test')
-rw-r--r--test/style/conversion/function.test.cpp7
-rw-r--r--test/style/conversion/property_value.test.cpp2
-rw-r--r--test/style/properties.test.cpp24
3 files changed, 16 insertions, 17 deletions
diff --git a/test/style/conversion/function.test.cpp b/test/style/conversion/function.test.cpp
index 4612147f76..e63ad722cf 100644
--- a/test/style/conversion/function.test.cpp
+++ b/test/style/conversion/function.test.cpp
@@ -3,7 +3,6 @@
#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion/constant.hpp>
#include <mbgl/style/conversion/property_value.hpp>
-#include <mbgl/style/conversion/data_driven_property_value.hpp>
#include <mbgl/style/expression/dsl.hpp>
using namespace mbgl;
@@ -14,7 +13,7 @@ TEST(StyleConversion, Function) {
Error error;
auto parseFunction = [&](const std::string& json) {
- return convertJSON<PropertyValue<float>>(json, error);
+ return convertJSON<PropertyValue<float>>(json, error, false, false);
};
auto fn1 = parseFunction(R"({"stops":[]})");
@@ -57,12 +56,12 @@ TEST(StyleConversion, CompositeFunctionExpression) {
Error error;
auto parseFunction = [&](const std::string& json) {
- return convertJSON<DataDrivenPropertyValue<float>>(json, error, false);
+ return convertJSON<PropertyValue<float>>(json, error, true, false);
};
auto fn1 = parseFunction(R"(["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10])");
ASSERT_TRUE(fn1);
-
+
auto fn2 = parseFunction(R"(["coalesce", ["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10], 0])");
ASSERT_TRUE(fn2);
diff --git a/test/style/conversion/property_value.test.cpp b/test/style/conversion/property_value.test.cpp
index dcb08bcec7..e8a7d844cd 100644
--- a/test/style/conversion/property_value.test.cpp
+++ b/test/style/conversion/property_value.test.cpp
@@ -14,7 +14,7 @@ TEST(StyleConversion, PropertyValue) {
JSDocument doc;
doc.Parse<0>(R"(["literal", [1, 2]])");
auto expected = std::array<float, 2>{{1, 2}};
- auto result = convert<PropertyValue<std::array<float, 2>>>(doc, error);
+ auto result = convert<PropertyValue<std::array<float, 2>>>(doc, error, false, false);
ASSERT_TRUE(result);
ASSERT_TRUE(result->isConstant());
ASSERT_EQ(result->asConstant(), expected);
diff --git a/test/style/properties.test.cpp b/test/style/properties.test.cpp
index ef064ccba2..f3af1a92b2 100644
--- a/test/style/properties.test.cpp
+++ b/test/style/properties.test.cpp
@@ -27,7 +27,7 @@ float evaluate(Transitioning<PropertyValue<float>>& property, Duration delta = D
return property.evaluate(evaluator, parameters.now);
}
-PossiblyEvaluatedPropertyValue<float> evaluate(Transitioning<DataDrivenPropertyValue<float>>& property, Duration delta = Duration::zero()) {
+PossiblyEvaluatedPropertyValue<float> evaluateDataExpression(Transitioning<PropertyValue<float>>& property, Duration delta = Duration::zero()) {
ZoomHistory zoomHistory;
zoomHistory.update(0, TimePoint::min() + delta);
@@ -36,12 +36,12 @@ PossiblyEvaluatedPropertyValue<float> evaluate(Transitioning<DataDrivenPropertyV
TimePoint::min() + delta,
Duration::zero()
};
-
+
DataDrivenPropertyEvaluator<float> evaluator {
parameters,
0.0f
};
-
+
return property.evaluate(evaluator, parameters.now);
}
@@ -114,10 +114,10 @@ TEST(TransitioningDataDrivenPropertyValue, Evaluate) {
TransitionOptions transition;
transition.delay = { 1000ms };
transition.duration = { 1000ms };
-
- Transitioning<DataDrivenPropertyValue<float>> t0 {
- DataDrivenPropertyValue<float>(0.0f),
- Transitioning<DataDrivenPropertyValue<float>>(),
+
+ Transitioning<PropertyValue<float>> t0 {
+ PropertyValue<float>(0.0f),
+ Transitioning<PropertyValue<float>>(),
TransitionOptions(),
TimePoint::min()
};
@@ -125,14 +125,14 @@ TEST(TransitioningDataDrivenPropertyValue, Evaluate) {
using namespace mbgl::style::expression::dsl;
PropertyExpression<float> expression(number(get("property_name")));
- Transitioning<DataDrivenPropertyValue<float>> t1 {
- DataDrivenPropertyValue<float>(expression),
+ Transitioning<PropertyValue<float>> t1 {
+ PropertyValue<float>(expression),
t0,
transition,
TimePoint::min()
};
-
- ASSERT_TRUE(evaluate(t0, 0ms).isConstant());
- ASSERT_FALSE(evaluate(t1, 0ms).isConstant()) <<
+
+ ASSERT_TRUE(evaluateDataExpression(t0, 0ms).isConstant());
+ ASSERT_FALSE(evaluateDataExpression(t1, 0ms).isConstant()) <<
"A paint property transition to a data-driven evaluates immediately to the final value (see https://github.com/mapbox/mapbox-gl-native/issues/8237).";
}