[Impeller] add test case for path that explicitly closes at origin. (flutter/engine#52314)

Follow up from https://github.com/flutter/engine/pull/52290#discussion_r1575451249
This commit is contained in:
Jonah Williams 2024-04-23 08:01:15 -07:00 committed by GitHub
parent ac3c768679
commit efbf913cc0

View File

@ -482,6 +482,22 @@ TEST(PathTest, CloseAfterMoveDoesNotAddNewLines) {
EXPECT_EQ(path.GetComponentCount(Path::ComponentType::kContour), 2u);
}
TEST(PathTest, CloseAtOriginDoesNotAddNewLineSegment) {
PathBuilder builder;
// Create a path that has a current position at the origin when close is
// called. This should not insert a new line segment
auto path = builder.LineTo({10, 0})
.LineTo({10, 10})
.LineTo({0, 10})
.LineTo({0, 0})
.Close()
.TakePath();
EXPECT_EQ(path.GetComponentCount(), 6u);
EXPECT_EQ(path.GetComponentCount(Path::ComponentType::kLinear), 4u);
EXPECT_EQ(path.GetComponentCount(Path::ComponentType::kContour), 2u);
}
TEST(PathTest, CanBeCloned) {
PathBuilder builder;
builder.MoveTo({10, 10});