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

Side by Side Diff: third_party/WebKit/Source/core/layout/shapes/BoxShapeTest.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 "core/layout/shapes/BoxShape.h" 30 #include "core/layout/shapes/BoxShape.h"
31 31
32 #include "platform/geometry/FloatRoundedRect.h" 32 #include "platform/geometry/FloatRoundedRect.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include <memory>
35 34
36 namespace blink { 35 namespace blink {
37 36
38 class BoxShapeTest : public ::testing::Test { 37 class BoxShapeTest : public ::testing::Test {
39 protected: 38 protected:
40 BoxShapeTest() { } 39 BoxShapeTest() { }
41 40
42 std::unique_ptr<Shape> createBoxShape(const FloatRoundedRect& bounds, float shapeMargin) 41 PassOwnPtr<Shape> createBoxShape(const FloatRoundedRect& bounds, float shape Margin)
43 { 42 {
44 return Shape::createLayoutBoxShape(bounds, TopToBottomWritingMode, shape Margin); 43 return Shape::createLayoutBoxShape(bounds, TopToBottomWritingMode, shape Margin);
45 } 44 }
46 }; 45 };
47 46
48 namespace { 47 namespace {
49 48
50 #define TEST_EXCLUDED_INTERVAL(shapePtr, lineTop, lineHeight, expectedLeft, expe ctedRight) \ 49 #define TEST_EXCLUDED_INTERVAL(shapePtr, lineTop, lineHeight, expectedLeft, expe ctedRight) \
51 { \ 50 { \
52 LineSegment segment = shapePtr->getExcludedInterval(lineTop, lineHeight); \ 51 LineSegment segment = shapePtr->getExcludedInterval(lineTop, lineHeight); \
(...skipping 14 matching lines...) Expand all
67 * so the shapeMarginBoundingBox rectangle is 120x70 at -10,-10: 66 * so the shapeMarginBoundingBox rectangle is 120x70 at -10,-10:
68 * 67 *
69 * -10,-10 110,-10 68 * -10,-10 110,-10
70 * +--------+ 69 * +--------+
71 * | | 70 * | |
72 * +--------+ 71 * +--------+
73 * -10,60 60,60 72 * -10,60 60,60
74 */ 73 */
75 TEST_F(BoxShapeTest, zeroRadii) 74 TEST_F(BoxShapeTest, zeroRadii)
76 { 75 {
77 std::unique_ptr<Shape> shape = createBoxShape(FloatRoundedRect(0, 0, 100, 50 ), 10); 76 OwnPtr<Shape> shape = createBoxShape(FloatRoundedRect(0, 0, 100, 50), 10);
78 EXPECT_FALSE(shape->isEmpty()); 77 EXPECT_FALSE(shape->isEmpty());
79 78
80 EXPECT_EQ(LayoutRect(-10, -10, 120, 70), shape->shapeMarginLogicalBoundingBo x()); 79 EXPECT_EQ(LayoutRect(-10, -10, 120, 70), shape->shapeMarginLogicalBoundingBo x());
81 80
82 // A BoxShape's bounds include the top edge but not the bottom edge. 81 // A BoxShape's bounds include the top edge but not the bottom edge.
83 // Similarly a "line", specified as top,height to the overlap methods, 82 // Similarly a "line", specified as top,height to the overlap methods,
84 // is defined as top <= y < top + height. 83 // is defined as top <= y < top + height.
85 84
86 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(LayoutUnit(-9), LayoutUnit( 1))); 85 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(LayoutUnit(-9), LayoutUnit( 1)));
87 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(LayoutUnit(-10), LayoutUnit ())); 86 EXPECT_TRUE(shape->lineOverlapsShapeMarginBounds(LayoutUnit(-10), LayoutUnit ()));
(...skipping 24 matching lines...) Expand all
112 * y=15 +--| |-+ y=20 111 * y=15 +--| |-+ y=20
113 * | | 112 * | |
114 * | | 113 * | |
115 * y=85 + -| |- + y=70 114 * y=85 + -| |- + y=70
116 * (--+---------+--) 115 * (--+---------+--)
117 * (25, 15) x=25 x=80 (20, 30) 116 * (25, 15) x=25 x=80 (20, 30)
118 */ 117 */
119 TEST_F(BoxShapeTest, getIntervals) 118 TEST_F(BoxShapeTest, getIntervals)
120 { 119 {
121 const FloatRoundedRect::Radii cornerRadii(FloatSize(10, 15), FloatSize(10, 2 0), FloatSize(25, 15), FloatSize(20, 30)); 120 const FloatRoundedRect::Radii cornerRadii(FloatSize(10, 15), FloatSize(10, 2 0), FloatSize(25, 15), FloatSize(20, 30));
122 std::unique_ptr<Shape> shape = createBoxShape(FloatRoundedRect(IntRect(0, 0, 100, 100), cornerRadii), 0); 121 OwnPtr<Shape> shape = createBoxShape(FloatRoundedRect(IntRect(0, 0, 100, 100 ), cornerRadii), 0);
123 EXPECT_FALSE(shape->isEmpty()); 122 EXPECT_FALSE(shape->isEmpty());
124 123
125 EXPECT_EQ(LayoutRect(0, 0, 100, 100), shape->shapeMarginLogicalBoundingBox() ); 124 EXPECT_EQ(LayoutRect(0, 0, 100, 100), shape->shapeMarginLogicalBoundingBox() );
126 125
127 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(10), LayoutUnit(95), 0, 100); 126 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(10), LayoutUnit(95), 0, 100);
128 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(5), LayoutUnit(25), 0, 100); 127 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(5), LayoutUnit(25), 0, 100);
129 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(15), LayoutUnit(6), 0, 100); 128 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(15), LayoutUnit(6), 0, 100);
130 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(20), LayoutUnit(50), 0, 100); 129 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(20), LayoutUnit(50), 0, 100);
131 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(69), LayoutUnit(5), 0, 100); 130 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(69), LayoutUnit(5), 0, 100);
132 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(85), LayoutUnit(10), 0, 97.320511f) ; 131 TEST_EXCLUDED_INTERVAL(shape, LayoutUnit(85), LayoutUnit(10), 0, 97.320511f) ;
133 } 132 }
134 133
135 } // anonymous namespace 134 } // anonymous namespace
136 135
137 } // namespace blink 136 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698