summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/api/query.test.cpp16
-rw-r--r--test/gl/bucket.test.cpp15
-rw-r--r--test/style/expression/expression.test.cpp3
-rw-r--r--test/style/style_layer.test.cpp18
4 files changed, 45 insertions, 7 deletions
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index bf3f64a0c8..83aeec81ec 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -126,6 +126,22 @@ TEST(Query, QuerySourceFeatures) {
EXPECT_EQ(features1.size(), 1u);
}
+TEST(Query, QuerySourceFeatureStates) {
+ QueryTest test;
+
+ FeatureState newState;
+ newState["hover"] = true;
+ newState["radius"].set<uint64_t>(20);
+ test.frontend.getRenderer()->setFeatureState("source1", {}, "feature1", newState);
+
+ FeatureState states;
+ test.frontend.getRenderer()->getFeatureState(states, "source1", {}, "feature1");
+ ASSERT_EQ(states.size(), 2u);
+ ASSERT_EQ(states["hover"], true);
+ ASSERT_EQ(states["radius"].get<uint64_t>(), 20u);
+ ASSERT_EQ(newState, states);
+}
+
TEST(Query, QuerySourceFeaturesOptionValidation) {
QueryTest test;
diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp
index a3dbdb8f99..13b30eb75d 100644
--- a/test/gl/bucket.test.cpp
+++ b/test/gl/bucket.test.cpp
@@ -52,7 +52,8 @@ TEST(Buckets, CircleBucket) {
ASSERT_FALSE(bucket.needsUpload());
GeometryCollection point { { { 0, 0 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap());
+ bucket.addFeature(StubGeometryTileFeature{{}, FeatureType::Point, point, properties}, point, {}, PatternLayerMap(),
+ 0);
ASSERT_TRUE(bucket.hasData());
ASSERT_TRUE(bucket.needsUpload());
@@ -74,7 +75,8 @@ TEST(Buckets, FillBucket) {
ASSERT_FALSE(bucket.needsUpload());
GeometryCollection polygon { { { 0, 0 }, { 0, 1 }, { 1, 1 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Polygon, polygon, properties }, polygon, {}, PatternLayerMap());
+ bucket.addFeature(StubGeometryTileFeature{{}, FeatureType::Polygon, polygon, properties}, polygon, {},
+ PatternLayerMap(), 0);
ASSERT_TRUE(bucket.hasData());
ASSERT_TRUE(bucket.needsUpload());
@@ -96,11 +98,13 @@ TEST(Buckets, LineBucket) {
// Ignore invalid feature type.
GeometryCollection point { { { 0, 0 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap());
+ bucket.addFeature(StubGeometryTileFeature{{}, FeatureType::Point, point, properties}, point, {}, PatternLayerMap(),
+ 0);
ASSERT_FALSE(bucket.hasData());
GeometryCollection line { { { 0, 0 }, { 1, 1 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::LineString, line, properties }, line, {}, PatternLayerMap());
+ bucket.addFeature(StubGeometryTileFeature{{}, FeatureType::LineString, line, properties}, line, {},
+ PatternLayerMap(), 1);
ASSERT_TRUE(bucket.hasData());
ASSERT_TRUE(bucket.needsUpload());
@@ -134,7 +138,8 @@ TEST(Buckets, SymbolBucket) {
// SymbolBucket::addFeature() is a no-op.
GeometryCollection point { { { 0, 0 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, std::move(point), properties }, point, {}, PatternLayerMap());
+ bucket.addFeature(StubGeometryTileFeature{{}, FeatureType::Point, std::move(point), properties}, point, {},
+ PatternLayerMap(), 0);
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
diff --git a/test/style/expression/expression.test.cpp b/test/style/expression/expression.test.cpp
index dd986c98f5..ef9f7b7930 100644
--- a/test/style/expression/expression.test.cpp
+++ b/test/style/expression/expression.test.cpp
@@ -33,10 +33,9 @@ TEST(Expression, IsExpression) {
document.Parse<0>(R"([")" + name + R"("])");
const JSValue* expression = &document;
- // TODO: "feature-state": https://github.com/mapbox/mapbox-gl-native/issues/12613
// TODO: "interpolate-hcl": https://github.com/mapbox/mapbox-gl-native/issues/8720
// TODO: "interpolate-lab": https://github.com/mapbox/mapbox-gl-native/issues/8720
- if (name == "feature-state" || name == "interpolate-hcl" || name == "interpolate-lab") {
+ if (name == "interpolate-hcl" || name == "interpolate-lab") {
if (expression::isExpression(conversion::Convertible(expression))) {
ASSERT_TRUE(false) << "Expression name" << name << "is implemented - please update Expression.IsExpression test.";
}
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index d6a926c631..dfced634b7 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -299,6 +299,24 @@ TEST(Layer, DuplicateLayer) {
}
}
+TEST(Layer, IncompatibleLayer) {
+ util::RunLoop loop;
+
+ // Setup style
+ StubFileSource fileSource;
+ Style::Impl style{fileSource, 1.0};
+ style.loadJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
+
+ // Try to add duplicate
+ try {
+ style.addLayer(std::make_unique<RasterLayer>("raster", "unusedsource"));
+ FAIL() << "Should not have been allowed to add an incompatible layer to the source";
+ } catch (const std::runtime_error& e) {
+ // Expected
+ ASSERT_STREQ("Layer 'raster' is not compatible with source 'unusedsource'", e.what());
+ }
+}
+
namespace {
template<template<typename> class PropertyValueType, typename LayoutType>