diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-04-23 10:44:02 -0400 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-04-23 10:44:02 -0400 |
commit | e08b6fe87f5824ab05a4cc67d9a76af5bb5ddd3b (patch) | |
tree | 886e10260bfa044f62943186ec837b9ccd02934c /test | |
parent | 2bb785dad2489d04db179fa9cf65514640db0a96 (diff) | |
parent | a45670cfb5752866b9c8130024a313944684c2db (diff) | |
download | qtlocation-mapboxgl-e08b6fe87f5824ab05a4cc67d9a76af5bb5ddd3b.tar.gz |
Merge branch 'release-boba' into masterupstream/fabian-merge-v4.0.0
# Conflicts:
# circle.yml
# include/mbgl/style/expression/let.hpp
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
# platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
# platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
# platform/android/gradle/dependencies.gradle
# platform/android/src/example_custom_layer.cpp
# platform/android/src/geojson/point.cpp
# platform/darwin/src/NSPredicate+MGLAdditions.mm
# platform/darwin/test/MGLExpressionTests.mm
# platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec
# platform/ios/Mapbox-iOS-SDK-symbols.podspec
# platform/ios/Mapbox-iOS-SDK.podspec
# platform/ios/app/MBXViewController.m
# src/mbgl/renderer/layers/render_custom_layer.cpp
# src/mbgl/style/conversion/filter.cpp
# src/mbgl/style/expression/interpolate.cpp
# src/mbgl/style/expression/value.cpp
# test/style/filter.test.cpp
Diffstat (limited to 'test')
-rw-r--r-- | test/api/custom_layer.test.cpp | 38 | ||||
-rw-r--r-- | test/style/conversion/stringify.test.cpp | 27 | ||||
-rw-r--r-- | test/style/expression/expression.test.cpp | 2 | ||||
-rw-r--r-- | test/style/filter.test.cpp | 14 | ||||
-rw-r--r-- | test/tile/vector_tile.test.cpp | 33 |
5 files changed, 44 insertions, 70 deletions
diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index eb1d7e0d3a..6cb148a349 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -34,19 +34,8 @@ void main() { // layer implementation because it is intended to reflect how someone using custom layers // might actually write their own implementation. -class TestLayer { +class TestLayer : public mbgl::style::CustomLayerHost { public: - ~TestLayer() { - if (program) { - MBGL_CHECK_ERROR(glDeleteBuffers(1, &buffer)); - MBGL_CHECK_ERROR(glDetachShader(program, vertexShader)); - MBGL_CHECK_ERROR(glDetachShader(program, fragmentShader)); - MBGL_CHECK_ERROR(glDeleteShader(vertexShader)); - MBGL_CHECK_ERROR(glDeleteShader(fragmentShader)); - MBGL_CHECK_ERROR(glDeleteProgram(program)); - } - } - void initialize() { program = MBGL_CHECK_ERROR(glCreateProgram()); vertexShader = MBGL_CHECK_ERROR(glCreateShader(GL_VERTEX_SHADER)); @@ -67,7 +56,7 @@ public: MBGL_CHECK_ERROR(glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(GLfloat), triangle, GL_STATIC_DRAW)); } - void render() { + void render(const mbgl::style::CustomLayerRenderParameters&) { MBGL_CHECK_ERROR(glUseProgram(program)); MBGL_CHECK_ERROR(glBindBuffer(GL_ARRAY_BUFFER, buffer)); MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos)); @@ -75,6 +64,19 @@ public: MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 3)); } + void contextLost() {} + + void deinitialize() { + if (program) { + MBGL_CHECK_ERROR(glDeleteBuffers(1, &buffer)); + MBGL_CHECK_ERROR(glDetachShader(program, vertexShader)); + MBGL_CHECK_ERROR(glDetachShader(program, fragmentShader)); + MBGL_CHECK_ERROR(glDeleteShader(vertexShader)); + MBGL_CHECK_ERROR(glDeleteShader(fragmentShader)); + MBGL_CHECK_ERROR(glDeleteProgram(program)); + } + } + GLuint program = 0; GLuint vertexShader = 0; GLuint fragmentShader = 0; @@ -95,15 +97,7 @@ TEST(CustomLayer, Basic) { map.setLatLngZoom({ 37.8, -122.5 }, 10); map.getStyle().addLayer(std::make_unique<CustomLayer>( "custom", - [] (void* context) { - reinterpret_cast<TestLayer*>(context)->initialize(); - }, - [] (void* context, const CustomLayerRenderParameters&) { - reinterpret_cast<TestLayer*>(context)->render(); - }, - [] (void* context) { - delete reinterpret_cast<TestLayer*>(context); - }, new TestLayer())); + std::make_unique<TestLayer>())); auto layer = std::make_unique<FillLayer>("landcover", "mapbox"); layer->setSourceLayer("landcover"); diff --git a/test/style/conversion/stringify.test.cpp b/test/style/conversion/stringify.test.cpp index 0b2940a0e0..136f276aaf 100644 --- a/test/style/conversion/stringify.test.cpp +++ b/test/style/conversion/stringify.test.cpp @@ -80,23 +80,25 @@ TEST(Stringify, Filter) { } TEST(Stringify, CameraFunction) { + ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 1 })), + "[\"interpolate\",[\"linear\"],[\"zoom\"],0.0,1.0]"); ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 2 })), - "{\"type\":\"exponential\",\"base\":2.0,\"stops\":[[0.0,1.0]]}"); + "[\"interpolate\",[\"exponential\",2.0],[\"zoom\"],0.0,1.0]"); ASSERT_EQ(stringify(CameraFunction<float>(IntervalStops<float> { {{0, 1}} })), - "{\"type\":\"interval\",\"stops\":[[0.0,1.0]]}"); + "[\"step\",[\"zoom\"],0.0,1.0]"); } TEST(Stringify, SourceFunction) { ASSERT_EQ(stringify(SourceFunction<float>("property", ExponentialStops<float> { {{0, 1}}, 2 })), - "{\"property\":\"property\",\"type\":\"exponential\",\"base\":2.0,\"stops\":[[0.0,1.0]]}"); + "[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0]"); ASSERT_EQ(stringify(SourceFunction<float>("property", IntervalStops<float> { {{0, 1}} })), - "{\"property\":\"property\",\"type\":\"interval\",\"stops\":[[0.0,1.0]]}"); + "[\"step\",[\"number\",[\"get\",\"property\"]],0.0,1.0]"); ASSERT_EQ(stringify(SourceFunction<float>("property", CategoricalStops<float> { {{CategoricalValue(true), 1}} })), - "{\"property\":\"property\",\"type\":\"categorical\",\"stops\":[[true,1.0]]}"); + "[\"case\",[\"boolean\",[\"get\",\"property\"]],1.0,[\"error\"]]"); ASSERT_EQ(stringify(SourceFunction<float>("property", IdentityStops<float> {})), - "{\"property\":\"property\",\"type\":\"identity\"}"); + "[\"number\",[\"get\",\"property\"]]"); ASSERT_EQ(stringify(SourceFunction<float>("property", IdentityStops<float> {}, 0.0f)), - "{\"property\":\"property\",\"type\":\"identity\",\"default\":0.0}"); + "[\"number\",[\"get\",\"property\"]]"); } TEST(Stringify, CompositeFunction) { @@ -108,16 +110,17 @@ TEST(Stringify, CompositeFunction) { }, 2 }, 0.0f)), - "{\"property\":\"property\",\"type\":\"exponential\",\"base\":2.0," - "\"stops\":[" - "[{\"zoom\":0.0,\"value\":0.0},1.0]," - "[{\"zoom\":1.0,\"value\":0.0},1.0]],\"default\":0.0}"); + "[\"interpolate\"," + "[\"linear\"]," + "[\"zoom\"]," + "0.0,[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0]," + "1.0,[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0]]"); } TEST(Stringify, PropertyValue) { ASSERT_EQ(stringify(PropertyValue<float>(1)), "1.0"); ASSERT_EQ(stringify(PropertyValue<float>(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 2 }))), - "{\"type\":\"exponential\",\"base\":2.0,\"stops\":[[0.0,1.0]]}"); + "[\"interpolate\",[\"exponential\",2.0],[\"zoom\"],0.0,1.0]"); } TEST(Stringify, Layout) { diff --git a/test/style/expression/expression.test.cpp b/test/style/expression/expression.test.cpp index 694569695c..fe5c261be1 100644 --- a/test/style/expression/expression.test.cpp +++ b/test/style/expression/expression.test.cpp @@ -49,7 +49,7 @@ TEST_P(ExpressionEqualityTest, ExpressionEquality) { assert(!document.HasParseError()); const JSValue* expression = &document; expression::ParsingContext ctx; - expression::ParseResult parsed = ctx.parse(conversion::Convertible(expression)); + expression::ParseResult parsed = ctx.parseExpression(conversion::Convertible(expression)); if (!parsed) { error_ = ctx.getErrors().size() > 0 ? ctx.getErrors()[0].message : "failed to parse"; }; diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp index 6f261c43ec..49edcaef45 100644 --- a/test/style/filter.test.cpp +++ b/test/style/filter.test.cpp @@ -11,14 +11,19 @@ using namespace mbgl; using namespace mbgl::style; -bool filter(const char * json, const PropertyMap& featureProperties = {{}}, optional<FeatureIdentifier> featureId = {}, FeatureType featureType = FeatureType::Point, GeometryCollection featureGeometry = {}) { +bool filter(const char * json, + const PropertyMap& featureProperties = {{}}, + optional<FeatureIdentifier> featureId = {}, + FeatureType featureType = FeatureType::Point, + GeometryCollection featureGeometry = {}, + float zoom = 0.0f) { conversion::Error error; optional<Filter> filter = conversion::convertJSON<Filter>(json, error); EXPECT_TRUE(bool(filter)); EXPECT_EQ(error.message, ""); StubGeometryTileFeature feature { featureId, featureType, featureGeometry, featureProperties }; - expression::EvaluationContext context = { &feature }; + expression::EvaluationContext context = { zoom, &feature }; return (*filter)(context); } @@ -109,3 +114,8 @@ TEST(Filter, PropertyExpression) { ASSERT_TRUE(filter("[\"==\", [\"get\", \"two\"], 2]", {{"two", int64_t(2)}})); ASSERT_FALSE(filter("[\"==\", [\"get\", \"two\"], 4]", {{"two", int64_t(2)}})); } + +TEST(Filter, ZoomExpressionNested) { + ASSERT_TRUE(filter(R"(["==", ["get", "two"], ["zoom"]])", {{"two", int64_t(2)}}, {}, FeatureType::Point, {}, 2.0f)); + ASSERT_FALSE(filter(R"(["==", ["get", "two"], ["+", ["zoom"], 1]])", {{"two", int64_t(2)}}, {}, FeatureType::Point, {}, 2.0f)); +} diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp index 9d42f7ae74..cd53c7c4a4 100644 --- a/test/tile/vector_tile.test.cpp +++ b/test/tile/vector_tile.test.cpp @@ -65,39 +65,6 @@ TEST(VectorTile, onError) { EXPECT_TRUE(tile.isComplete()); } -TEST(VectorTile, Issue7615) { - VectorTileTest test; - VectorTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, test.tileset); - - style::SymbolLayer symbolLayer("symbol", "source"); - std::vector<SymbolInstance> symbolInstances; - auto symbolBucket = std::make_shared<SymbolBucket>( - style::SymbolLayoutProperties::PossiblyEvaluated(), - std::map< - std::string, - std::pair<style::IconPaintProperties::PossiblyEvaluated, style::TextPaintProperties::PossiblyEvaluated>>(), - 16.0f, 1.0f, 0.0f, false, false, false, std::move(symbolInstances)); - - // Simulate placement of a symbol layer. - tile.onPlacement(GeometryTile::PlacementResult { - {{ - symbolLayer.getID(), - symbolBucket - }}, - {}, - {}, - }, 0); - - // Subsequent onLayout should not cause the existing symbol bucket to be discarded. - tile.onLayout(GeometryTile::LayoutResult { - std::unordered_map<std::string, std::shared_ptr<Bucket>>(), - nullptr, - nullptr, - }, 0); - - EXPECT_EQ(symbolBucket.get(), tile.getBucket(*symbolLayer.baseImpl)); -} - TEST(VectorTile, Issue8542) { VectorTileTest test; VectorTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, test.tileset); |