diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/geometry/physical_rect_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/layout/geometry/physical_rect_test.cc | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/geometry/physical_rect_test.cc b/chromium/third_party/blink/renderer/core/layout/geometry/physical_rect_test.cc index c7248194a29..b9bd748ea12 100644 --- a/chromium/third_party/blink/renderer/core/layout/geometry/physical_rect_test.cc +++ b/chromium/third_party/blink/renderer/core/layout/geometry/physical_rect_test.cc @@ -25,11 +25,11 @@ struct PhysicalOffsetRectUniteTestData { {"saturated width", {-1000, 0, 200, 200}, {33554402, 500, 30, 100}, - {0, 0, 99999999.0f, 600}}, + {0, 0, 99999999, 600}}, {"saturated height", {0, -1000, 200, 200}, {0, 33554402, 100, 30}, - {0, 0, 200, 99999999.0f}}, + {0, 0, 200, 99999999}}, }; std::ostream& operator<<(std::ostream& os, @@ -66,6 +66,44 @@ TEST_P(PhysicalRectUniteTest, Data) { EXPECT_EQ(expected, actual); } +TEST(PhysicalRectTest, SquaredDistanceTo) { + PhysicalRect rect(0, 0, 200, 200); + EXPECT_EQ(200, rect.SquaredDistanceTo(PhysicalOffset(-10, -10))) + << "over the top-left corner"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(0, 0))) + << "on the top-left corner"; + EXPECT_EQ(100, rect.SquaredDistanceTo(PhysicalOffset(10, -10))) + << "over the top edge"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(10, 0))) + << "on the top edge"; + EXPECT_EQ(200, rect.SquaredDistanceTo(PhysicalOffset(210, -10))) + << "over the top-right corner"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(200, 0))) + << "on the top-right corner"; + EXPECT_EQ(100, rect.SquaredDistanceTo(PhysicalOffset(210, 10))) + << "over the right edge"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(200, 10))) + << "on the right edge"; + EXPECT_EQ(200, rect.SquaredDistanceTo(PhysicalOffset(210, 210))) + << "over the bottom-right corner"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(200, 200))) + << "on the bottom-right corner"; + EXPECT_EQ(10000, rect.SquaredDistanceTo(PhysicalOffset(100, 300))) + << "over the bottom edge"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(100, 200))) + << "on the bottom edge"; + EXPECT_EQ(401, rect.SquaredDistanceTo(PhysicalOffset(-20, 201))) + << "over the bottom-left corner"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(0, 200))) + << "on the bottom-left corner"; + EXPECT_EQ(9, rect.SquaredDistanceTo(PhysicalOffset(-3, 100))) + << "over the left edge"; + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(0, 3))) + << "on the left edge"; + + EXPECT_EQ(0, rect.SquaredDistanceTo(PhysicalOffset(10, 190))) << "contained"; +} + TEST(PhysicalRectTest, InclusiveIntersect) { PhysicalRect rect(11, 12, 0, 0); EXPECT_TRUE(rect.InclusiveIntersect(PhysicalRect(11, 12, 13, 14))); |