summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-04-11 20:31:18 +0300
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-04-14 12:33:13 -0700
commit98e2e59e5e963dbc5451a19233d942b429a74855 (patch)
tree2eb68e34823d07a7402e0c633e4c3e9510b76b4c /test
parent2f4d162debd7e4accfc0b20360058304dce40801 (diff)
downloadqtlocation-mapboxgl-98e2e59e5e963dbc5451a19233d942b429a74855.tar.gz
[core] Safeguard PositionedIcon usage via optional
Diffstat (limited to 'test')
-rw-r--r--test/text/quads.test.cpp34
-rw-r--r--test/tile/annotation_tile.test.cpp2
2 files changed, 21 insertions, 15 deletions
diff --git a/test/text/quads.test.cpp b/test/text/quads.test.cpp
index 18fbedc2dd..91f2ea7af8 100644
--- a/test/text/quads.test.cpp
+++ b/test/text/quads.test.cpp
@@ -18,12 +18,15 @@ TEST(getIconQuads, normal) {
{ 0, 0 },
1.0f
};
- PositionedIcon shapedIcon(image, -5.0, 6.0, -7.0, 8.0, 0);
+
+ auto shapedIcon = PositionedIcon::shapeIcon(image, {{ -6.5f, -4.5f }}, 0);
+ ASSERT_TRUE(shapedIcon);
+
GeometryCoordinates line;
Shaping shapedText;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 16.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 16.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.anchorPoint.x, 2);
ASSERT_EQ(quad.anchorPoint.y, 3);
@@ -48,7 +51,10 @@ TEST(getIconQuads, style) {
{ 0, 0 },
1.0f
};
- PositionedIcon shapedIcon(image, -10.0, 10.0, -10.0, 10.0, 0);
+
+ auto shapedIcon = PositionedIcon::shapeIcon(image, {{ -9.5f, -9.5f }}, 0);
+ ASSERT_TRUE(shapedIcon);
+
GeometryCoordinates line;
Shaping shapedText;
shapedText.top = -10.0f;
@@ -61,7 +67,7 @@ TEST(getIconQuads, style) {
{
SymbolLayoutProperties::Evaluated layout;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.anchorPoint.x, 0);
ASSERT_EQ(quad.anchorPoint.y, 0);
@@ -84,7 +90,7 @@ TEST(getIconQuads, style) {
layout.get<TextSize>() = 24.0f;
layout.get<IconTextFit>() = IconTextFitType::Width;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 24.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 24.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -60);
ASSERT_EQ(quad.tl.y, 0);
@@ -102,7 +108,7 @@ TEST(getIconQuads, style) {
layout.get<TextSize>() = 12.0f;
layout.get<IconTextFit>() = IconTextFitType::Width;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -5);
@@ -124,7 +130,7 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[2] = 5.0f;
layout.get<IconTextFitPadding>()[3] = 10.0f;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -40);
ASSERT_EQ(quad.tl.y, -10);
@@ -142,7 +148,7 @@ TEST(getIconQuads, style) {
layout.get<TextSize>() = 24.0f;
layout.get<IconTextFit>() = IconTextFitType::Height;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 24.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 24.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -10);
@@ -160,7 +166,7 @@ TEST(getIconQuads, style) {
layout.get<TextSize>() = 12.0f;
layout.get<IconTextFit>() = IconTextFitType::Height;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -20);
ASSERT_EQ(quad.tl.y, -5);
@@ -182,7 +188,7 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[2] = 5.0f;
layout.get<IconTextFitPadding>()[3] = 10.0f;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -10);
@@ -200,7 +206,7 @@ TEST(getIconQuads, style) {
layout.get<TextSize>() = 24.0f;
layout.get<IconTextFit>() = IconTextFitType::Both;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 24.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 24.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -60);
ASSERT_EQ(quad.tl.y, -10);
@@ -218,7 +224,7 @@ TEST(getIconQuads, style) {
layout.get<TextSize>() = 12.0f;
layout.get<IconTextFit>() = IconTextFitType::Both;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -30);
ASSERT_EQ(quad.tl.y, -5);
@@ -240,7 +246,7 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[2] = 5.0f;
layout.get<IconTextFitPadding>()[3] = 10.0f;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -40);
ASSERT_EQ(quad.tl.y, -10);
@@ -262,7 +268,7 @@ TEST(getIconQuads, style) {
layout.get<IconTextFitPadding>()[2] = 10.0f;
layout.get<IconTextFitPadding>()[3] = 15.0f;
SymbolQuad quad =
- getIconQuad(anchor, shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
+ getIconQuad(anchor, *shapedIcon, line, layout, 12.0f, SymbolPlacementType::Point, shapedText);
ASSERT_EQ(quad.tl.x, -45);
ASSERT_EQ(quad.tl.y, -5);
diff --git a/test/tile/annotation_tile.test.cpp b/test/tile/annotation_tile.test.cpp
index 4e28a3101c..cba2b61b59 100644
--- a/test/tile/annotation_tile.test.cpp
+++ b/test/tile/annotation_tile.test.cpp
@@ -58,7 +58,7 @@ TEST(AnnotationTile, Issue8289) {
auto collisionTile = std::make_unique<CollisionTile>(PlacementConfig());
IndexedSubfeature subfeature { 0, "", "", 0 };
- CollisionFeature feature(GeometryCoordinates(), Anchor(0, 0, 0, 0), -5, 5, -5, 5, 1, 0, style::SymbolPlacementType::Point, subfeature, false);
+ CollisionFeature feature(GeometryCoordinates(), Anchor(0, 0, 0, 0), -5, 5, -5, 5, 1, 0, style::SymbolPlacementType::Point, subfeature, CollisionFeature::AlignmentType::Curved);
collisionTile->insertFeature(feature, 0, true);
collisionTile->placeFeature(feature, false, false);