summaryrefslogtreecommitdiff
path: root/test/style
diff options
context:
space:
mode:
authorAnand Thakker <anandthakker@users.noreply.github.com>2017-03-08 11:53:44 -0500
committerGitHub <noreply@github.com>2017-03-08 11:53:44 -0500
commitbb846fd6cdff84e71741de9428a00137fd5f73a8 (patch)
tree915421863f2d6468ad537113566ae609ff0a94be /test/style
parentf591421aaaf698c23ccff37a03d03c87eaa0d988 (diff)
downloadqtlocation-mapboxgl-bb846fd6cdff84e71741de9428a00137fd5f73a8.tar.gz
For data-driven paint setters, transition immediately to target value (#8306)
Closes #8237
Diffstat (limited to 'test/style')
-rw-r--r--test/style/paint_property.test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/style/paint_property.test.cpp b/test/style/paint_property.test.cpp
index c70fa101ca..39d31068c1 100644
--- a/test/style/paint_property.test.cpp
+++ b/test/style/paint_property.test.cpp
@@ -22,6 +22,22 @@ float evaluate(UnevaluatedPaintProperty<PropertyValue<float>>& property, Duratio
return property.evaluate(evaluator, parameters.now);
}
+PossiblyEvaluatedPropertyValue<float> evaluate(UnevaluatedPaintProperty<DataDrivenPropertyValue<float>>& property, Duration delta = Duration::zero()) {
+ PropertyEvaluationParameters parameters {
+ 0,
+ TimePoint::min() + delta,
+ ZoomHistory(),
+ Duration::zero()
+ };
+
+ DataDrivenPropertyEvaluator<float> evaluator {
+ parameters,
+ 0.0f
+ };
+
+ return property.evaluate(evaluator, parameters.now);
+}
+
TEST(UnevaluatedPaintProperty, EvaluateDefaultValue) {
UnevaluatedPaintProperty<PropertyValue<float>> property;
ASSERT_EQ(0.0f, evaluate(property));
@@ -86,3 +102,32 @@ TEST(UnevaluatedPaintProperty, EvaluateTransitionedConstantWithDelay) {
ASSERT_FLOAT_EQ(0.823099f, evaluate(t1, 1500ms));
ASSERT_FLOAT_EQ(1.0f, evaluate(t1, 2500ms));
}
+
+TEST(UnevaluatedPaintProperty, EvaluateDataDrivenValue) {
+ TransitionOptions transition;
+ transition.delay = { 1000ms };
+ transition.duration = { 1000ms };
+
+ UnevaluatedPaintProperty<DataDrivenPropertyValue<float>> t0 {
+ DataDrivenPropertyValue<float>(0.0f),
+ UnevaluatedPaintProperty<DataDrivenPropertyValue<float>>(),
+ TransitionOptions(),
+ TimePoint::min()
+ };
+
+ SourceFunction<float> sourceFunction = {
+ "property_name",
+ IdentityStops<float>()
+ };
+
+ UnevaluatedPaintProperty<DataDrivenPropertyValue<float>> t1 {
+ DataDrivenPropertyValue<float>(sourceFunction),
+ t0,
+ transition,
+ TimePoint::min()
+ };
+
+ ASSERT_TRUE(evaluate(t0, 0ms).isConstant());
+ ASSERT_FALSE(evaluate(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).";
+}