Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: Source/core/rendering/shapes/BoxShapeTest.cpp

Issue 815933006: Change all uses of the RoundedRect class to use FloatRoundedRect instead. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderThemeChromiumMac.mm ('k') | Source/core/rendering/shapes/Shape.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
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 31
32 #include "core/rendering/shapes/BoxShape.h" 32 #include "core/rendering/shapes/BoxShape.h"
33 33
34 #include "platform/geometry/RoundedRect.h" 34 #include "platform/geometry/FloatRoundedRect.h"
35 35
36 #include <gtest/gtest.h> 36 #include <gtest/gtest.h>
37 37
38 namespace blink { 38 namespace blink {
39 39
40 class BoxShapeTest : public ::testing::Test { 40 class BoxShapeTest : public ::testing::Test {
41 protected: 41 protected:
42 BoxShapeTest() { } 42 BoxShapeTest() { }
43 43
44 PassOwnPtr<Shape> createBoxShape(const RoundedRect& bounds, float shapeMargi n) 44 PassOwnPtr<Shape> createBoxShape(const FloatRoundedRect& bounds, float shape Margin)
45 { 45 {
46 return Shape::createLayoutBoxShape(bounds, TopToBottomWritingMode, shape Margin); 46 return Shape::createLayoutBoxShape(bounds, TopToBottomWritingMode, shape Margin);
47 } 47 }
48 }; 48 };
49 49
50 } // namespace blink 50 } // namespace blink
51 51
52 namespace { 52 namespace {
53 53
54 using namespace blink; 54 using namespace blink;
(...skipping 18 matching lines...) Expand all
73 * so the shapeMarginBoundingBox rectangle is 120x70 at -10,-10: 73 * so the shapeMarginBoundingBox rectangle is 120x70 at -10,-10:
74 * 74 *
75 * -10,-10 110,-10 75 * -10,-10 110,-10
76 * +--------+ 76 * +--------+
77 * | | 77 * | |
78 * +--------+ 78 * +--------+
79 * -10,60 60,60 79 * -10,60 60,60
80 */ 80 */
81 TEST_F(BoxShapeTest, zeroRadii) 81 TEST_F(BoxShapeTest, zeroRadii)
82 { 82 {
83 OwnPtr<Shape> shape = createBoxShape(RoundedRect(0, 0, 100, 50), 10); 83 OwnPtr<Shape> shape = createBoxShape(FloatRoundedRect(0, 0, 100, 50), 10);
84 EXPECT_FALSE(shape->isEmpty()); 84 EXPECT_FALSE(shape->isEmpty());
85 85
86 EXPECT_EQ(LayoutRect(-10, -10, 120, 70), shape->shapeMarginLogicalBoundingBo x()); 86 EXPECT_EQ(LayoutRect(-10, -10, 120, 70), shape->shapeMarginLogicalBoundingBo x());
87 87
88 // A BoxShape's bounds include the top edge but not the bottom edge. 88 // A BoxShape's bounds include the top edge but not the bottom edge.
89 // Similarly a "line", specified as top,height to the overlap methods, 89 // Similarly a "line", specified as top,height to the overlap methods,
90 // is defined as top <= y < top + height. 90 // is defined as top <= y < top + height.
91 91
92 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(-9, 1)); 92 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(-9, 1));
93 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(-10, 0)); 93 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(-10, 0));
(...skipping 23 matching lines...) Expand all
117 * (--+---------+--) 117 * (--+---------+--)
118 * y=15 +--| |-+ y=20 118 * y=15 +--| |-+ y=20
119 * | | 119 * | |
120 * | | 120 * | |
121 * y=85 + -| |- + y=70 121 * y=85 + -| |- + y=70
122 * (--+---------+--) 122 * (--+---------+--)
123 * (25, 15) x=25 x=80 (20, 30) 123 * (25, 15) x=25 x=80 (20, 30)
124 */ 124 */
125 TEST_F(BoxShapeTest, getIntervals) 125 TEST_F(BoxShapeTest, getIntervals)
126 { 126 {
127 const RoundedRect::Radii cornerRadii(IntSize(10, 15), IntSize(10, 20), IntSi ze(25, 15), IntSize(20, 30)); 127 const FloatRoundedRect::Radii cornerRadii(IntSize(10, 15), IntSize(10, 20), IntSize(25, 15), IntSize(20, 30));
128 OwnPtr<Shape> shape = createBoxShape(RoundedRect(IntRect(0, 0, 100, 100), co rnerRadii), 0); 128 OwnPtr<Shape> shape = createBoxShape(FloatRoundedRect(IntRect(0, 0, 100, 100 ), cornerRadii), 0);
129 EXPECT_FALSE(shape->isEmpty()); 129 EXPECT_FALSE(shape->isEmpty());
130 130
131 EXPECT_EQ(LayoutRect(0, 0, 100, 100), shape->shapeMarginLogicalBoundingBox() ); 131 EXPECT_EQ(LayoutRect(0, 0, 100, 100), shape->shapeMarginLogicalBoundingBox() );
132 132
133 TEST_EXCLUDED_INTERVAL(shape, 10, 95, 0, 100); 133 TEST_EXCLUDED_INTERVAL(shape, 10, 95, 0, 100);
134 TEST_EXCLUDED_INTERVAL(shape, 5, 25, 0, 100); 134 TEST_EXCLUDED_INTERVAL(shape, 5, 25, 0, 100);
135 TEST_EXCLUDED_INTERVAL(shape, 15, 6, 0, 100); 135 TEST_EXCLUDED_INTERVAL(shape, 15, 6, 0, 100);
136 TEST_EXCLUDED_INTERVAL(shape, 20, 50, 0, 100); 136 TEST_EXCLUDED_INTERVAL(shape, 20, 50, 0, 100);
137 TEST_EXCLUDED_INTERVAL(shape, 69, 5, 0, 100); 137 TEST_EXCLUDED_INTERVAL(shape, 69, 5, 0, 100);
138 TEST_EXCLUDED_INTERVAL(shape, 85, 10, 0, 97.320511f); 138 TEST_EXCLUDED_INTERVAL(shape, 85, 10, 0, 97.320511f);
139 } 139 }
140 140
141 } // namespace 141 } // namespace
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderThemeChromiumMac.mm ('k') | Source/core/rendering/shapes/Shape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698