summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-07-05 16:31:16 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-07-05 16:48:14 +0300
commit3788f162d1b3b7570dcde56775aa60e56636c90c (patch)
tree8a7b5036632651fbfc678117e0514ef67e35817f
parent1c32b3bcdef6ac6b73c7012516d87533e3583c59 (diff)
downloadqtlocation-mapboxgl-upstream/bucket-test-updates.tar.gz
[test] Added bucket feature insertion testsupstream/bucket-test-updates
-rw-r--r--test/gl/bucket.test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp
index feca82998f..3fe29496ef 100644
--- a/test/gl/bucket.test.cpp
+++ b/test/gl/bucket.test.cpp
@@ -1,4 +1,5 @@
#include <mbgl/test/util.hpp>
+#include <mbgl/test/stub_geometry_tile_feature.hpp>
#include <mbgl/renderer/buckets/circle_bucket.hpp>
#include <mbgl/renderer/buckets/fill_bucket.hpp>
@@ -14,21 +15,50 @@
using namespace mbgl;
TEST(Buckets, CircleBucket) {
+ gl::Context context;
CircleBucket bucket { { {0, 0, 0}, MapMode::Still, 1.0 }, {} };
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
+
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, GeometryCollection { { { 0, 0 } } }, {} });
+ ASSERT_TRUE(bucket.hasData());
+ ASSERT_TRUE(bucket.needsUpload());
+
+ bucket.upload(context);
+ ASSERT_TRUE(bucket.hasData());
+ ASSERT_FALSE(bucket.needsUpload());
}
TEST(Buckets, FillBucket) {
+ gl::Context context;
FillBucket bucket { { {0, 0, 0}, MapMode::Still, 1.0 }, {} };
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
+
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Polygon, GeometryCollection { { { 0, 0 }, { 0, 1 }, { 1, 1 } } }, {} });
+ ASSERT_TRUE(bucket.hasData());
+ ASSERT_TRUE(bucket.needsUpload());
+
+ bucket.upload(context);
+ ASSERT_FALSE(bucket.needsUpload());
}
TEST(Buckets, LineBucket) {
+ gl::Context context;
LineBucket bucket { { {0, 0, 0}, MapMode::Still, 1.0 }, {}, {} };
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
+
+ // Ignore invalid feature type.
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, GeometryCollection { { { 0, 0 } } }, {} });
+ ASSERT_FALSE(bucket.hasData());
+
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::LineString, GeometryCollection { { { 0, 0 }, { 1, 1 } } }, {} });
+ ASSERT_TRUE(bucket.hasData());
+ ASSERT_TRUE(bucket.needsUpload());
+
+ bucket.upload(context);
+ ASSERT_FALSE(bucket.needsUpload());
}
TEST(Buckets, SymbolBucket) {
@@ -36,18 +66,33 @@ TEST(Buckets, SymbolBucket) {
bool sdfIcons = false;
bool iconsNeedLinear = false;
+ gl::Context context;
SymbolBucket bucket { layout, {}, 16.0f, 1.0f, 0, sdfIcons, iconsNeedLinear };
ASSERT_FALSE(bucket.hasIconData());
ASSERT_FALSE(bucket.hasTextData());
ASSERT_FALSE(bucket.hasCollisionBoxData());
ASSERT_FALSE(bucket.hasData());
ASSERT_FALSE(bucket.needsUpload());
+
+ // SymbolBucket::addFeature() is a no-op.
+ bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, GeometryCollection { { { 0, 0 } } }, {} });
+ ASSERT_FALSE(bucket.hasData());
+ ASSERT_FALSE(bucket.needsUpload());
+
+ bucket.text.segments.emplace_back(0, 0);
+ ASSERT_TRUE(bucket.hasTextData());
+ ASSERT_TRUE(bucket.hasData());
+ ASSERT_TRUE(bucket.needsUpload());
+
+ bucket.upload(context);
+ ASSERT_FALSE(bucket.needsUpload());
}
TEST(Buckets, RasterBucket) {
gl::Context context;
UnassociatedImage rgba({ 1, 1 });
+ // RasterBucket::hasData() is always true.
RasterBucket bucket = { std::move(rgba) };
ASSERT_TRUE(bucket.hasData());
ASSERT_TRUE(bucket.needsUpload());