6#include "flutter/testing/testing.h"
7#include "gtest/gtest.h"
17 std::vector<impeller::SolidFillVertexShader::PerVertexData>
a,
18 std::vector<impeller::SolidFillVertexShader::PerVertexData>
b) {
19 if (
a.size() !=
b.size()) {
20 return ::testing::AssertionFailure() <<
"Colors length does not match";
22 for (
auto i = 0u;
i <
b.size();
i++) {
24 return ::testing::AssertionFailure() <<
"Positions are not equal.";
27 return ::testing::AssertionSuccess();
31 std::vector<impeller::TextureFillVertexShader::PerVertexData>
a,
32 std::vector<impeller::TextureFillVertexShader::PerVertexData>
b) {
33 if (
a.size() !=
b.size()) {
34 return ::testing::AssertionFailure() <<
"Colors length does not match";
36 for (
auto i = 0u;
i <
b.size();
i++) {
38 return ::testing::AssertionFailure() <<
"Positions are not equal.";
41 return ::testing::AssertionFailure() <<
"Texture coords are not equal.";
44 return ::testing::AssertionSuccess();
47#define EXPECT_SOLID_VERTICES_NEAR(a, b) \
48 EXPECT_PRED2(&::SolidVerticesNear, a, b)
49#define EXPECT_TEXTURE_VERTICES_NEAR(a, b) \
50 EXPECT_PRED2(&::TextureVerticesNear, a, b)
56 static std::vector<SolidFillVertexShader::PerVertexData>
63 return StrokePathGeometry::GenerateSolidStrokeVertices(
70TEST(EntityGeometryTest, RectGeometryCoversArea) {
72 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(0, 0, 100, 100)));
73 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(-1, 0, 100, 100)));
74 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(1, 1, 100, 100)));
75 ASSERT_TRUE(geometry->CoversArea({},
Rect()));
78TEST(EntityGeometryTest, FillPathGeometryCoversArea) {
82 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(0, 0, 100, 100)));
83 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(-1, 0, 100, 100)));
84 ASSERT_TRUE(geometry->CoversArea({},
Rect::MakeLTRB(1, 1, 100, 100)));
85 ASSERT_TRUE(geometry->CoversArea({},
Rect()));
88TEST(EntityGeometryTest, FillPathGeometryCoversAreaNoInnerRect) {
91 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(0, 0, 100, 100)));
92 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(-1, 0, 100, 100)));
93 ASSERT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(1, 1, 100, 100)));
94 ASSERT_FALSE(geometry->CoversArea({},
Rect()));
97TEST(EntityGeometryTest, LineGeometryCoverage) {
100 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(10, 9, 20, 11));
106 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(9, 9, 21, 11));
112 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(9, 10, 11, 20));
118 EXPECT_EQ(geometry->GetCoverage({}),
Rect::MakeLTRB(9, 9, 11, 21));
123TEST(EntityGeometryTest, RoundRectGeometryCoversArea) {
126 EXPECT_FALSE(geometry->CoversArea({},
Rect::MakeLTRB(15, 15, 85, 85)));
132TEST(EntityGeometryTest, GeometryResultHasReasonableDefaults) {
139TEST(EntityGeometryTest, AlphaCoverageStrokePaths) {
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
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 > MakeStrokePath(const Path &path, Scalar stroke_width=0.0, Scalar miter_limit=4.0, Cap stroke_cap=Cap::kButt, Join stroke_join=Join::kMiter)
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)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
TEST(AiksCanvasTest, EmptyCullRect)
const Scalar stroke_width
const Path::Polyline & polyline
@ kNormal
The geometry has no overlapping triangles.
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeScale(const Vector3 &s)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
#define EXPECT_TRUE(handle)