| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/geometry/FloatQuad.h" | 5 #include "platform/geometry/FloatQuad.h" |
| 6 | 6 |
| 7 #include <limits> |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "wtf/text/WTFString.h" | 9 #include "wtf/text/WTFString.h" |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 12 TEST(FloatQuadTest, ToString) { | 13 TEST(FloatQuadTest, ToString) { |
| 13 FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13), | 14 FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13), |
| 14 FloatPoint(17, 19)); | 15 FloatPoint(17, 19)); |
| 15 EXPECT_EQ("2,3; 5,7; 11,13; 17,19", quad.toString()); | 16 EXPECT_EQ("2,3; 5,7; 11,13; 17,19", quad.toString()); |
| 16 } | 17 } |
| 17 | 18 |
| 19 TEST(FloatQuadTest, BoundingBox) { |
| 20 FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13), |
| 21 FloatPoint(17, 19)); |
| 22 FloatRect rect = quad.boundingBox(); |
| 23 EXPECT_EQ(rect.x(), 2); |
| 24 EXPECT_EQ(rect.y(), 3); |
| 25 EXPECT_EQ(rect.width(), 17 - 2); |
| 26 EXPECT_EQ(rect.height(), 19 - 3); |
| 27 } |
| 28 |
| 29 TEST(FloatQuadTest, BoundingBoxSaturateInf) { |
| 30 double inf = std::numeric_limits<double>::infinity(); |
| 31 FloatQuad quad(FloatPoint(-inf, 3), FloatPoint(5, inf), FloatPoint(11, 13), |
| 32 FloatPoint(17, 19)); |
| 33 FloatRect rect = quad.boundingBox(); |
| 34 EXPECT_EQ(rect.x(), std::numeric_limits<int>::min()); |
| 35 EXPECT_EQ(rect.y(), 3.0f); |
| 36 EXPECT_EQ(rect.width(), 17.0f - std::numeric_limits<int>::min()); |
| 37 EXPECT_EQ(rect.height(), std::numeric_limits<int>::max() - 3.0f); |
| 38 } |
| 18 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |