[Impeller] Fix IntersectsWithRect and cover with tests (flutter/engine#34726)

This commit is contained in:
Brandon DeRosier
2022-07-18 15:08:05 -07:00
committed by GitHub
parent 596a5f3b52
commit 297d5c605d
2 changed files with 27 additions and 1 deletions

View File

@@ -904,6 +904,32 @@ TEST(GeometryTest, RectIntersection) {
}
}
TEST(GeometryTest, RectIntersectsWithRect) {
{
Rect a(100, 100, 100, 100);
Rect b(0, 0, 0, 0);
ASSERT_FALSE(a.IntersectsWithRect(b));
}
{
Rect a(100, 100, 100, 100);
Rect b(10, 10, 0, 0);
ASSERT_FALSE(a.IntersectsWithRect(b));
}
{
Rect a(0, 0, 100, 100);
Rect b(10, 10, 100, 100);
ASSERT_TRUE(a.IntersectsWithRect(b));
}
{
Rect a(0, 0, 100, 100);
Rect b(100, 100, 100, 100);
ASSERT_FALSE(a.IntersectsWithRect(b));
}
}
TEST(GeometryTest, RectContainsPoint) {
{
// Origin is inclusive

View File

@@ -186,7 +186,7 @@ struct TRect {
}
constexpr bool IntersectsWithRect(const TRect& o) const {
return Interesection(o).has_value();
return Intersection(o).has_value();
}
};