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 29 matching lines...) Expand all Loading... |
40 EXPECT_TRUE(roundedRect.xInterceptsAtY(yCoordinate, minXIntercept, maxXInter
cept)); \ | 40 EXPECT_TRUE(roundedRect.xInterceptsAtY(yCoordinate, minXIntercept, maxXInter
cept)); \ |
41 EXPECT_FLOAT_EQ(expectedMinXIntercept, minXIntercept);
\ | 41 EXPECT_FLOAT_EQ(expectedMinXIntercept, minXIntercept);
\ |
42 EXPECT_FLOAT_EQ(expectedMaxXIntercept, maxXIntercept);
\ | 42 EXPECT_FLOAT_EQ(expectedMaxXIntercept, maxXIntercept);
\ |
43 } | 43 } |
44 | 44 |
45 TEST(FloatRoundedRectTest, zeroRadii) | 45 TEST(FloatRoundedRectTest, zeroRadii) |
46 { | 46 { |
47 FloatRoundedRect r = FloatRoundedRect(1, 2, 3, 4); | 47 FloatRoundedRect r = FloatRoundedRect(1, 2, 3, 4); |
48 | 48 |
49 EXPECT_EQ(FloatRect(1, 2, 3, 4), r.rect()); | 49 EXPECT_EQ(FloatRect(1, 2, 3, 4), r.rect()); |
50 EXPECT_EQ(FloatSize(), r.radii().topLeft()); | 50 EXPECT_EQ(FloatSize(), r.getRadii().topLeft()); |
51 EXPECT_EQ(FloatSize(), r.radii().topRight()); | 51 EXPECT_EQ(FloatSize(), r.getRadii().topRight()); |
52 EXPECT_EQ(FloatSize(), r.radii().bottomLeft()); | 52 EXPECT_EQ(FloatSize(), r.getRadii().bottomLeft()); |
53 EXPECT_EQ(FloatSize(), r.radii().bottomRight()); | 53 EXPECT_EQ(FloatSize(), r.getRadii().bottomRight()); |
54 EXPECT_TRUE(r.radii().isZero()); | 54 EXPECT_TRUE(r.getRadii().isZero()); |
55 EXPECT_FALSE(r.isRounded()); | 55 EXPECT_FALSE(r.isRounded()); |
56 EXPECT_FALSE(r.isEmpty()); | 56 EXPECT_FALSE(r.isEmpty()); |
57 | 57 |
58 EXPECT_EQ(FloatRect(1, 2, 0, 0), r.topLeftCorner()); | 58 EXPECT_EQ(FloatRect(1, 2, 0, 0), r.topLeftCorner()); |
59 EXPECT_EQ(FloatRect(4, 2, 0, 0), r.topRightCorner()); | 59 EXPECT_EQ(FloatRect(4, 2, 0, 0), r.topRightCorner()); |
60 EXPECT_EQ(FloatRect(4, 6, 0, 0), r.bottomRightCorner()); | 60 EXPECT_EQ(FloatRect(4, 6, 0, 0), r.bottomRightCorner()); |
61 EXPECT_EQ(FloatRect(1, 6, 0, 0), r.bottomLeftCorner()); | 61 EXPECT_EQ(FloatRect(1, 6, 0, 0), r.bottomLeftCorner()); |
62 | 62 |
63 TEST_INTERCEPTS(r, 2, r.rect().x(), r.rect().maxX()); | 63 TEST_INTERCEPTS(r, 2, r.rect().x(), r.rect().maxX()); |
64 TEST_INTERCEPTS(r, 4, r.rect().x(), r.rect().maxX()); | 64 TEST_INTERCEPTS(r, 4, r.rect().x(), r.rect().maxX()); |
65 TEST_INTERCEPTS(r, 6, r.rect().x(), r.rect().maxX()); | 65 TEST_INTERCEPTS(r, 6, r.rect().x(), r.rect().maxX()); |
66 | 66 |
67 float minXIntercept; | 67 float minXIntercept; |
68 float maxXIntercept; | 68 float maxXIntercept; |
69 | 69 |
70 EXPECT_FALSE(r.xInterceptsAtY(1, minXIntercept, maxXIntercept)); | 70 EXPECT_FALSE(r.xInterceptsAtY(1, minXIntercept, maxXIntercept)); |
71 EXPECT_FALSE(r.xInterceptsAtY(7, minXIntercept, maxXIntercept)); | 71 EXPECT_FALSE(r.xInterceptsAtY(7, minXIntercept, maxXIntercept)); |
72 | 72 |
73 // The FloatRoundedRect::expandRadii() function doesn't change radii FloatSi
zes that | 73 // The FloatRoundedRect::expandRadii() function doesn't change radii FloatSi
zes that |
74 // are <= zero. Same as RoundedRect::expandRadii(). | 74 // are <= zero. Same as RoundedRect::expandRadii(). |
75 r.expandRadii(20); | 75 r.expandRadii(20); |
76 r.shrinkRadii(10); | 76 r.shrinkRadii(10); |
77 EXPECT_TRUE(r.radii().isZero()); | 77 EXPECT_TRUE(r.getRadii().isZero()); |
78 } | 78 } |
79 | 79 |
80 TEST(FloatRoundedRectTest, circle) | 80 TEST(FloatRoundedRectTest, circle) |
81 { | 81 { |
82 FloatSize cornerRadii(50, 50); | 82 FloatSize cornerRadii(50, 50); |
83 FloatRoundedRect r(FloatRect(0, 0, 100, 100), cornerRadii, cornerRadii, corn
erRadii, cornerRadii); | 83 FloatRoundedRect r(FloatRect(0, 0, 100, 100), cornerRadii, cornerRadii, corn
erRadii, cornerRadii); |
84 | 84 |
85 EXPECT_EQ(FloatRect(0, 0, 100, 100), r.rect()); | 85 EXPECT_EQ(FloatRect(0, 0, 100, 100), r.rect()); |
86 EXPECT_EQ(cornerRadii, r.radii().topLeft()); | 86 EXPECT_EQ(cornerRadii, r.getRadii().topLeft()); |
87 EXPECT_EQ(cornerRadii, r.radii().topRight()); | 87 EXPECT_EQ(cornerRadii, r.getRadii().topRight()); |
88 EXPECT_EQ(cornerRadii, r.radii().bottomLeft()); | 88 EXPECT_EQ(cornerRadii, r.getRadii().bottomLeft()); |
89 EXPECT_EQ(cornerRadii, r.radii().bottomRight()); | 89 EXPECT_EQ(cornerRadii, r.getRadii().bottomRight()); |
90 EXPECT_FALSE(r.radii().isZero()); | 90 EXPECT_FALSE(r.getRadii().isZero()); |
91 EXPECT_TRUE(r.isRounded()); | 91 EXPECT_TRUE(r.isRounded()); |
92 EXPECT_FALSE(r.isEmpty()); | 92 EXPECT_FALSE(r.isEmpty()); |
93 | 93 |
94 EXPECT_EQ(FloatRect(0, 0, 50, 50), r.topLeftCorner()); | 94 EXPECT_EQ(FloatRect(0, 0, 50, 50), r.topLeftCorner()); |
95 EXPECT_EQ(FloatRect(50, 0, 50, 50), r.topRightCorner()); | 95 EXPECT_EQ(FloatRect(50, 0, 50, 50), r.topRightCorner()); |
96 EXPECT_EQ(FloatRect(0, 50, 50, 50), r.bottomLeftCorner()); | 96 EXPECT_EQ(FloatRect(0, 50, 50, 50), r.bottomLeftCorner()); |
97 EXPECT_EQ(FloatRect(50, 50, 50, 50), r.bottomRightCorner()); | 97 EXPECT_EQ(FloatRect(50, 50, 50, 50), r.bottomRightCorner()); |
98 | 98 |
99 TEST_INTERCEPTS(r, 0, 50, 50); | 99 TEST_INTERCEPTS(r, 0, 50, 50); |
100 TEST_INTERCEPTS(r, 25, 6.69873, 93.3013); | 100 TEST_INTERCEPTS(r, 25, 6.69873, 93.3013); |
(...skipping 25 matching lines...) Expand all Loading... |
126 { | 126 { |
127 FloatSize cornerSize(10, 20); | 127 FloatSize cornerSize(10, 20); |
128 FloatRoundedRect::Radii cornerRadii; | 128 FloatRoundedRect::Radii cornerRadii; |
129 cornerRadii.setTopLeft(FloatSize(10, 15)); | 129 cornerRadii.setTopLeft(FloatSize(10, 15)); |
130 cornerRadii.setTopRight(FloatSize(10, 20)); | 130 cornerRadii.setTopRight(FloatSize(10, 20)); |
131 cornerRadii.setBottomLeft(FloatSize(25, 15)); | 131 cornerRadii.setBottomLeft(FloatSize(25, 15)); |
132 cornerRadii.setBottomRight(FloatSize(20, 30)); | 132 cornerRadii.setBottomRight(FloatSize(20, 30)); |
133 | 133 |
134 FloatRoundedRect r(FloatRect(0, 0, 100, 100), cornerRadii); | 134 FloatRoundedRect r(FloatRect(0, 0, 100, 100), cornerRadii); |
135 | 135 |
136 EXPECT_EQ(r.radii(), FloatRoundedRect::Radii(FloatSize(10, 15), FloatSize(10
, 20), FloatSize(25, 15), FloatSize(20, 30))); | 136 EXPECT_EQ(r.getRadii(), FloatRoundedRect::Radii(FloatSize(10, 15), FloatSize
(10, 20), FloatSize(25, 15), FloatSize(20, 30))); |
137 EXPECT_EQ(r, FloatRoundedRect(FloatRect(0, 0, 100, 100), cornerRadii)); | 137 EXPECT_EQ(r, FloatRoundedRect(FloatRect(0, 0, 100, 100), cornerRadii)); |
138 | 138 |
139 EXPECT_EQ(FloatRect(0, 0, 10, 15), r.topLeftCorner()); | 139 EXPECT_EQ(FloatRect(0, 0, 10, 15), r.topLeftCorner()); |
140 EXPECT_EQ(FloatRect(90, 0, 10, 20), r.topRightCorner()); | 140 EXPECT_EQ(FloatRect(90, 0, 10, 20), r.topRightCorner()); |
141 EXPECT_EQ(FloatRect(0, 85, 25, 15), r.bottomLeftCorner()); | 141 EXPECT_EQ(FloatRect(0, 85, 25, 15), r.bottomLeftCorner()); |
142 EXPECT_EQ(FloatRect(80, 70, 20, 30), r.bottomRightCorner()); | 142 EXPECT_EQ(FloatRect(80, 70, 20, 30), r.bottomRightCorner()); |
143 | 143 |
144 TEST_INTERCEPTS(r, 5, 2.5464401, 96.61438); | 144 TEST_INTERCEPTS(r, 5, 2.5464401, 96.61438); |
145 TEST_INTERCEPTS(r, 15, 0, 99.682457); | 145 TEST_INTERCEPTS(r, 15, 0, 99.682457); |
146 TEST_INTERCEPTS(r, 20, 0, 100); | 146 TEST_INTERCEPTS(r, 20, 0, 100); |
(...skipping 21 matching lines...) Expand all Loading... |
168 FloatRoundedRect r1(collapsedRect); | 168 FloatRoundedRect r1(collapsedRect); |
169 EXPECT_TRUE(r1.radiusCenterRect().isEmpty()); | 169 EXPECT_TRUE(r1.radiusCenterRect().isEmpty()); |
170 | 170 |
171 FloatRoundedRect::Radii radiiWithTooLargeCorner(FloatSize(55, 55), FloatSize
(), FloatSize(), FloatSize()); | 171 FloatRoundedRect::Radii radiiWithTooLargeCorner(FloatSize(55, 55), FloatSize
(), FloatSize(), FloatSize()); |
172 FloatRoundedRect r2(FloatRect(0, 0, 100, 50), radiiWithTooLargeCorner); | 172 FloatRoundedRect r2(FloatRect(0, 0, 100, 50), radiiWithTooLargeCorner); |
173 EXPECT_TRUE(r2.radiusCenterRect().isEmpty()); | 173 EXPECT_TRUE(r2.radiusCenterRect().isEmpty()); |
174 } | 174 } |
175 | 175 |
176 } // namespace blink | 176 } // namespace blink |
177 | 177 |
OLD | NEW |