summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMolly Lloyd <molly@mapbox.com>2018-06-14 14:35:39 -0700
committerMolly Lloyd <mollymerp@users.noreply.github.com>2018-08-31 13:08:47 -0700
commit4a5dc37245d23805d13865f5ef9c5f26e539a9ca (patch)
treede77bfeff6f7afbe02210c9189bf72da59293083 /test
parentec62e321531b1a836074056e86de8e20018280fb (diff)
downloadqtlocation-mapboxgl-4a5dc37245d23805d13865f5ef9c5f26e539a9ca.tar.gz
[core] Implement CrossFadedDataDrivenProperty to add support for feature expressions in `*-pattern` properties
Diffstat (limited to 'test')
-rw-r--r--test/gl/bucket.test.cpp16
-rw-r--r--test/programs/symbol_program.test.cpp34
-rw-r--r--test/renderer/image_manager.test.cpp18
3 files changed, 37 insertions, 31 deletions
diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp
index 9b28b2e01a..04e6447ad8 100644
--- a/test/gl/bucket.test.cpp
+++ b/test/gl/bucket.test.cpp
@@ -52,7 +52,7 @@ TEST(Buckets, CircleBucket) {
ASSERT_FALSE(bucket.needsUpload());
GeometryCollection point { { { 0, 0 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point);
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap());
ASSERT_TRUE(bucket.hasData());
ASSERT_TRUE(bucket.needsUpload());
@@ -64,14 +64,15 @@ TEST(Buckets, CircleBucket) {
TEST(Buckets, FillBucket) {
HeadlessBackend backend({ 512, 256 });
BackendScope scope { backend };
+ style::Properties<>::PossiblyEvaluated layout;
gl::Context context;
- FillBucket bucket { { {0, 0, 0}, MapMode::Static, 1.0 }, {} };
+ FillBucket bucket { layout, {}, 5.0f, 1};
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
GeometryCollection polygon { { { 0, 0 }, { 0, 1 }, { 1, 1 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Polygon, polygon, properties }, polygon);
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Polygon, polygon, properties }, polygon, {}, PatternLayerMap());
ASSERT_TRUE(bucket.hasData());
ASSERT_TRUE(bucket.needsUpload());
@@ -82,19 +83,20 @@ TEST(Buckets, FillBucket) {
TEST(Buckets, LineBucket) {
HeadlessBackend backend({ 512, 256 });
BackendScope scope { backend };
+ style::LineLayoutProperties::PossiblyEvaluated layout;
gl::Context context;
- LineBucket bucket { { {0, 0, 0}, MapMode::Static, 1.0 }, {}, {} };
+ LineBucket bucket { layout, {}, 10.0f, 1 };
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
// Ignore invalid feature type.
GeometryCollection point { { { 0, 0 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point);
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap());
ASSERT_FALSE(bucket.hasData());
GeometryCollection line { { { 0, 0 }, { 1, 1 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::LineString, line, properties }, line);
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::LineString, line, properties }, line, {}, PatternLayerMap());
ASSERT_TRUE(bucket.hasData());
ASSERT_TRUE(bucket.needsUpload());
@@ -123,7 +125,7 @@ TEST(Buckets, SymbolBucket) {
// SymbolBucket::addFeature() is a no-op.
GeometryCollection point { { { 0, 0 } } };
- bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point);
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap());
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
diff --git a/test/programs/symbol_program.test.cpp b/test/programs/symbol_program.test.cpp
index b2467d5998..4d30e5dc3d 100644
--- a/test/programs/symbol_program.test.cpp
+++ b/test/programs/symbol_program.test.cpp
@@ -9,9 +9,9 @@ using namespace mbgl::style::expression::dsl;
TEST(SymbolProgram, SymbolSizeBinder) {
auto binder = SymbolSizeBinder::create(5.0f, 12.0f, 0.0f);
auto uniformValues = binder->uniformValues(5.5f);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, true);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true);
- EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 12.0f);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>(), true);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>(), true);
+ EXPECT_EQ(uniformValues.get<uniforms::u_size>(), 12.0f);
binder = SymbolSizeBinder::create(1.0f, style::PropertyExpression<float>(
interpolate(
@@ -20,9 +20,9 @@ TEST(SymbolProgram, SymbolSizeBinder) {
0., literal(8.),
10., literal(18.))), 0.0f);
uniformValues = binder->uniformValues(1.5f);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true);
- EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 9.5f);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>(), false);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>(), true);
+ EXPECT_EQ(uniformValues.get<uniforms::u_size>(), 9.5f);
binder = SymbolSizeBinder::create(0.0f, style::PropertyExpression<float>(
interpolate(
@@ -31,9 +31,9 @@ TEST(SymbolProgram, SymbolSizeBinder) {
1., literal(8.),
11., literal(18.))), 0.0f);
uniformValues = binder->uniformValues(0.5f);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true);
- EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 8.0f);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>(), false);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>(), true);
+ EXPECT_EQ(uniformValues.get<uniforms::u_size>(), 8.0f);
binder = SymbolSizeBinder::create(12.0f, style::PropertyExpression<float>(
interpolate(
@@ -42,9 +42,9 @@ TEST(SymbolProgram, SymbolSizeBinder) {
1., literal(8.),
11., literal(18.))), 0.0f);
uniformValues = binder->uniformValues(12.5f);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, true);
- EXPECT_EQ(uniformValues.get<uniforms::u_size>().t, 18.0f);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>(), false);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>(), true);
+ EXPECT_EQ(uniformValues.get<uniforms::u_size>(), 18.0f);
binder = SymbolSizeBinder::create(0.0f, style::PropertyExpression<float>(
interpolate(
@@ -53,8 +53,8 @@ TEST(SymbolProgram, SymbolSizeBinder) {
1., literal(8.),
11., literal(18.))), 0.0f);
uniformValues = binder->uniformValues(12.5f);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, true);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, false);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>(), true);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>(), false);
binder = SymbolSizeBinder::create(5.0f, style::PropertyExpression<float>(
interpolate(
@@ -63,7 +63,7 @@ TEST(SymbolProgram, SymbolSizeBinder) {
1., interpolate(linear(), number(get("x")), 0., literal(8.), 100., literal(18.)),
11., interpolate(linear(), number(get("x")), 0., literal(12.), 100., literal(24.9)))), 0.0f);
uniformValues = binder->uniformValues(5.5f);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>().t, false);
- EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>().t, false);
- EXPECT_EQ(uniformValues.get<uniforms::u_size_t>().t, 0.45f);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_zoom_constant>(), false);
+ EXPECT_EQ(uniformValues.get<uniforms::u_is_size_feature_constant>(), false);
+ EXPECT_EQ(uniformValues.get<uniforms::u_size_t>(), 0.45f);
}
diff --git a/test/renderer/image_manager.test.cpp b/test/renderer/image_manager.test.cpp
index ebe1bcd72f..4a838d0f9c 100644
--- a/test/renderer/image_manager.test.cpp
+++ b/test/renderer/image_manager.test.cpp
@@ -108,11 +108,11 @@ TEST(ImageManager, RemoveReleasesBinPackRect) {
class StubImageRequestor : public ImageRequestor {
public:
- void onImagesAvailable(ImageMap images, uint64_t imageCorrelationID_) final {
- if (imagesAvailable && imageCorrelationID == imageCorrelationID_) imagesAvailable(images);
+ void onImagesAvailable(ImageMap icons, ImageMap patterns, uint64_t imageCorrelationID_) final {
+ if (imagesAvailable && imageCorrelationID == imageCorrelationID_) imagesAvailable(icons, patterns);
}
- std::function<void (ImageMap)> imagesAvailable;
+ std::function<void (ImageMap, ImageMap)> imagesAvailable;
uint64_t imageCorrelationID = 0;
};
@@ -121,12 +121,14 @@ TEST(ImageManager, NotifiesRequestorWhenSpriteIsLoaded) {
StubImageRequestor requestor;
bool notified = false;
- requestor.imagesAvailable = [&] (ImageMap) {
+ requestor.imagesAvailable = [&] (ImageMap, ImageMap) {
notified = true;
};
uint64_t imageCorrelationID = 0;
- imageManager.getImages(requestor, std::make_pair(std::set<std::string> {"one"}, imageCorrelationID));
+ ImageDependencies dependencies;
+ dependencies.emplace("one", ImageType::Icon);
+ imageManager.getImages(requestor, std::make_pair(dependencies, imageCorrelationID));
ASSERT_FALSE(notified);
imageManager.setLoaded(true);
@@ -138,13 +140,15 @@ TEST(ImageManager, NotifiesRequestorImmediatelyIfDependenciesAreSatisfied) {
StubImageRequestor requestor;
bool notified = false;
- requestor.imagesAvailable = [&] (ImageMap) {
+ requestor.imagesAvailable = [&] (ImageMap, ImageMap) {
notified = true;
};
uint64_t imageCorrelationID = 0;
+ ImageDependencies dependencies;
+ dependencies.emplace("one", ImageType::Icon);
imageManager.addImage(makeMutable<style::Image::Impl>("one", PremultipliedImage({ 16, 16 }), 2));
- imageManager.getImages(requestor, std::make_pair(std::set<std::string> {"one"}, imageCorrelationID));
+ imageManager.getImages(requestor, std::make_pair(dependencies, imageCorrelationID));
ASSERT_TRUE(notified);
}