6#include "flutter/testing/testing.h"
15 std::vector<impeller::SolidFillVertexShader::PerVertexData>
a,
16 std::vector<impeller::SolidFillVertexShader::PerVertexData>
b) {
17 if (
a.size() !=
b.size()) {
18 return ::testing::AssertionFailure() <<
"Colors length does not match";
20 for (
auto i = 0u; i <
b.size(); i++) {
22 return ::testing::AssertionFailure() <<
"Positions are not equal.";
25 return ::testing::AssertionSuccess();
29 std::vector<impeller::TextureFillVertexShader::PerVertexData>
a,
30 std::vector<impeller::TextureFillVertexShader::PerVertexData>
b) {
31 if (
a.size() !=
b.size()) {
32 return ::testing::AssertionFailure() <<
"Colors length does not match";
34 for (
auto i = 0u; i <
b.size(); i++) {
36 return ::testing::AssertionFailure() <<
"Positions are not equal.";
38 if (!
PointNear(
a[i].texture_coords,
b[i].texture_coords)) {
39 return ::testing::AssertionFailure() <<
"Texture coords are not equal.";
42 return ::testing::AssertionSuccess();
45#define EXPECT_SOLID_VERTICES_NEAR(a, b) \
46 EXPECT_PRED2(&::SolidVerticesNear, a, b)
47#define EXPECT_TEXTURE_VERTICES_NEAR(a, b) \
48 EXPECT_PRED2(&::TextureVerticesNear, a, b)
54 static std::vector<SolidFillVertexShader::PerVertexData>
61 return StrokePathGeometry::GenerateSolidStrokeVertices(
68TEST(EntityGeometryTest, RectGeometryCoversArea) {
70 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(0, 0, 100, 100)));
71 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(-1, 0, 100, 100)));
72 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(1, 1, 100, 100)));
73 ASSERT_TRUE(geometry->CoversArea({},
Rect()));
76TEST(EntityGeometryTest, FillPathGeometryCoversArea) {
80 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(0, 0, 100, 100)));
81 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(-1, 0, 100, 100)));
82 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(1, 1, 100, 100)));
83 ASSERT_TRUE(geometry->CoversArea({},
Rect()));
86TEST(EntityGeometryTest, FillPathGeometryCoversAreaNoInnerRect) {
89 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(0, 0, 100, 100)));
90 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(-1, 0, 100, 100)));
91 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(1, 1, 100, 100)));
92 ASSERT_FALSE(geometry->CoversArea({},
Rect()));
95TEST(EntityGeometryTest, LineGeometryCoverage) {
98 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(10, 9, 20, 11));
104 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(9, 9, 21, 11));
110 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(9, 10, 11, 20));
116 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(9, 9, 11, 21));
121TEST(EntityGeometryTest, RoundRectGeometryCoversArea) {
124 EXPECT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(15, 15, 85, 85)));
130TEST(EntityGeometryTest, GeometryResultHasReasonableDefaults) {
#define TEST(S, s, D, expected)
static std::shared_ptr< Geometry > MakeLine(const Point &p0, const Point &p1, Scalar width, Cap cap)
static std::shared_ptr< Geometry > MakeRect(const Rect &rect)
static std::shared_ptr< Geometry > MakeRoundRect(const Rect &rect, const Size &radii)
static std::shared_ptr< Geometry > MakeFillPath(const Path &path, std::optional< Rect > inner_rect=std::nullopt)
static std::vector< SolidFillVertexShader::PerVertexData > GenerateSolidStrokeVertices(const Path::Polyline &polyline, Scalar stroke_width, Scalar miter_limit, Join stroke_join, Cap stroke_cap, Scalar scale)
PathBuilder & AddRect(Rect rect)
Path TakePath(FillType fill=FillType::kNonZero)
inline ::testing::AssertionResult PointNear(impeller::Point a, impeller::Point b)
inline ::testing::AssertionResult SolidVerticesNear(std::vector< impeller::SolidFillVertexShader::PerVertexData > a, std::vector< impeller::SolidFillVertexShader::PerVertexData > b)
inline ::testing::AssertionResult TextureVerticesNear(std::vector< impeller::TextureFillVertexShader::PerVertexData > a, std::vector< impeller::TextureFillVertexShader::PerVertexData > b)
const Scalar stroke_width
const Path::Polyline & polyline
@ kNormal
The geometry has no overlapping triangles.
A 4x4 matrix using column-major storage.
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
#define EXPECT_TRUE(handle)