| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 | |
| 32 #include "platform/geometry/FloatRoundedRect.h" | 31 #include "platform/geometry/FloatRoundedRect.h" |
| 33 | 32 |
| 34 #include <gtest/gtest.h> | 33 #include <gtest/gtest.h> |
| 35 | 34 |
| 36 using namespace blink; | |
| 37 | |
| 38 namespace blink { | 35 namespace blink { |
| 39 | 36 |
| 40 void PrintTo(const FloatSize& size, std::ostream* os) | 37 void PrintTo(const FloatSize& size, std::ostream* os) |
| 41 { | 38 { |
| 42 *os << "FloatSize(" | 39 *os << "FloatSize(" |
| 43 << size.width() << ", " | 40 << size.width() << ", " |
| 44 << size.height() << ")"; | 41 << size.height() << ")"; |
| 45 } | 42 } |
| 46 | 43 |
| 47 void PrintTo(const FloatRect& rect, std::ostream* os) | 44 void PrintTo(const FloatRect& rect, std::ostream* os) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 62 << ::testing::PrintToString(radii.bottomLeft()) << ")"; | 59 << ::testing::PrintToString(radii.bottomLeft()) << ")"; |
| 63 } | 60 } |
| 64 | 61 |
| 65 void PrintTo(const FloatRoundedRect& roundedRect, std::ostream* os) | 62 void PrintTo(const FloatRoundedRect& roundedRect, std::ostream* os) |
| 66 { | 63 { |
| 67 *os << "FloatRoundedRect(" | 64 *os << "FloatRoundedRect(" |
| 68 << ::testing::PrintToString(roundedRect.rect()) << ", " | 65 << ::testing::PrintToString(roundedRect.rect()) << ", " |
| 69 << ::testing::PrintToString(roundedRect.radii()) << ")"; | 66 << ::testing::PrintToString(roundedRect.radii()) << ")"; |
| 70 } | 67 } |
| 71 | 68 |
| 72 } // namespace blink | |
| 73 | |
| 74 namespace { | |
| 75 | |
| 76 #define TEST_INTERCEPTS(roundedRect, yCoordinate, expectedMinXIntercept, expecte
dMaxXIntercept) \ | 69 #define TEST_INTERCEPTS(roundedRect, yCoordinate, expectedMinXIntercept, expecte
dMaxXIntercept) \ |
| 77 {
\ | 70 {
\ |
| 78 float minXIntercept;
\ | 71 float minXIntercept;
\ |
| 79 float maxXIntercept;
\ | 72 float maxXIntercept;
\ |
| 80 EXPECT_TRUE(roundedRect.xInterceptsAtY(yCoordinate, minXIntercept, maxXInter
cept)); \ | 73 EXPECT_TRUE(roundedRect.xInterceptsAtY(yCoordinate, minXIntercept, maxXInter
cept)); \ |
| 81 EXPECT_FLOAT_EQ(expectedMinXIntercept, minXIntercept);
\ | 74 EXPECT_FLOAT_EQ(expectedMinXIntercept, minXIntercept);
\ |
| 82 EXPECT_FLOAT_EQ(expectedMaxXIntercept, maxXIntercept);
\ | 75 EXPECT_FLOAT_EQ(expectedMaxXIntercept, maxXIntercept);
\ |
| 83 } | 76 } |
| 84 | 77 |
| 85 TEST(FloatRoundedRectTest, zeroRadii) | 78 TEST(FloatRoundedRectTest, zeroRadii) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 FloatRect collapsedRect(0, 0, 100, 50); | 199 FloatRect collapsedRect(0, 0, 100, 50); |
| 207 collapsedRect.expand(FloatRectOutsets(-200, -200, -200, -200)); | 200 collapsedRect.expand(FloatRectOutsets(-200, -200, -200, -200)); |
| 208 FloatRoundedRect r1(collapsedRect); | 201 FloatRoundedRect r1(collapsedRect); |
| 209 EXPECT_TRUE(r1.radiusCenterRect().isEmpty()); | 202 EXPECT_TRUE(r1.radiusCenterRect().isEmpty()); |
| 210 | 203 |
| 211 FloatRoundedRect::Radii radiiWithTooLargeCorner(FloatSize(55, 55), FloatSize
(), FloatSize(), FloatSize()); | 204 FloatRoundedRect::Radii radiiWithTooLargeCorner(FloatSize(55, 55), FloatSize
(), FloatSize(), FloatSize()); |
| 212 FloatRoundedRect r2(FloatRect(0, 0, 100, 50), radiiWithTooLargeCorner); | 205 FloatRoundedRect r2(FloatRect(0, 0, 100, 50), radiiWithTooLargeCorner); |
| 213 EXPECT_TRUE(r2.radiusCenterRect().isEmpty()); | 206 EXPECT_TRUE(r2.radiusCenterRect().isEmpty()); |
| 214 } | 207 } |
| 215 | 208 |
| 216 } // namespace | 209 } // namespace blink |
| 217 | 210 |
| OLD | NEW |