summaryrefslogtreecommitdiff
path: root/test/text
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/text
parent2f4d162debd7e4accfc0b20360058304dce40801 (diff)
downloadqtlocation-mapboxgl-98e2e59e5e963dbc5451a19233d942b429a74855.tar.gz
[core] Safeguard PositionedIcon usage via optional
Diffstat (limited to 'test/text')
-rw-r--r--test/text/quads.test.cpp34
1 files changed, 20 insertions, 14 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);