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

Side by Side Diff: Source/platform/geometry/FloatPolygonTest.cpp

Issue 1182703002: Fix unit test style in Source/platform/, part 1. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
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 10 matching lines...) Expand all
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/FloatPolygon.h" 31 #include "platform/geometry/FloatPolygon.h"
33 32
34 #include <gtest/gtest.h> 33 #include <gtest/gtest.h>
35 34
36 namespace blink { 35 namespace blink {
37 36
38 class FloatPolygonTestValue { 37 class FloatPolygonTestValue {
39 public: 38 public:
40 FloatPolygonTestValue(const float* coordinates, unsigned coordinatesLength, WindRule fillRule) 39 FloatPolygonTestValue(const float* coordinates, unsigned coordinatesLength, WindRule fillRule)
41 { 40 {
42 ASSERT(!(coordinatesLength % 2)); 41 ASSERT(!(coordinatesLength % 2));
43 OwnPtr<Vector<FloatPoint>> vertices = adoptPtr(new Vector<FloatPoint>(co ordinatesLength / 2)); 42 OwnPtr<Vector<FloatPoint>> vertices = adoptPtr(new Vector<FloatPoint>(co ordinatesLength / 2));
44 for (unsigned i = 0; i < coordinatesLength; i += 2) 43 for (unsigned i = 0; i < coordinatesLength; i += 2)
45 (*vertices)[i / 2] = FloatPoint(coordinates[i], coordinates[i + 1]); 44 (*vertices)[i / 2] = FloatPoint(coordinates[i], coordinates[i + 1]);
46 m_polygon = adoptPtr(new FloatPolygon(vertices.release(), fillRule)); 45 m_polygon = adoptPtr(new FloatPolygon(vertices.release(), fillRule));
47 } 46 }
48 47
49 const FloatPolygon& polygon() const { return *m_polygon; } 48 const FloatPolygon& polygon() const { return *m_polygon; }
50 49
51 private: 50 private:
52 OwnPtr<FloatPolygon> m_polygon; 51 OwnPtr<FloatPolygon> m_polygon;
53 }; 52 };
54 53
55 } // namespace blink
56
57 namespace { 54 namespace {
58 55
59 using namespace blink; 56 bool compareEdgeIndex(const FloatPolygonEdge* edge1, const FloatPolygonEdge* edg e2)
60
61 static bool compareEdgeIndex(const FloatPolygonEdge* edge1, const FloatPolygonEd ge* edge2)
62 { 57 {
63 return edge1->edgeIndex() < edge2->edgeIndex(); 58 return edge1->edgeIndex() < edge2->edgeIndex();
64 } 59 }
65 60
66 static Vector<const FloatPolygonEdge*> sortedOverlappingEdges(const FloatPolygon & polygon, float minY, float maxY) 61 Vector<const FloatPolygonEdge*> sortedOverlappingEdges(const FloatPolygon& polyg on, float minY, float maxY)
67 { 62 {
68 Vector<const FloatPolygonEdge*> result; 63 Vector<const FloatPolygonEdge*> result;
69 polygon.overlappingEdges(minY, maxY, result); 64 polygon.overlappingEdges(minY, maxY, result);
70 std::sort(result.begin(), result.end(), compareEdgeIndex); 65 std::sort(result.begin(), result.end(), compareEdgeIndex);
71 return result; 66 return result;
72 } 67 }
73 68
69 } // anonymous namespace
70
74 #define SIZEOF_ARRAY(p) (sizeof(p) / sizeof(p[0])) 71 #define SIZEOF_ARRAY(p) (sizeof(p) / sizeof(p[0]))
75 72
76 /** 73 /**
77 * Checks a right triangle. This test covers all of the trivial FloatPolygon acc essors. 74 * Checks a right triangle. This test covers all of the trivial FloatPolygon acc essors.
78 * 75 *
79 * 200,100 76 * 200,100
80 * /| 77 * /|
81 * / | 78 * / |
82 * / | 79 * / |
83 * ----- 80 * -----
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 EXPECT_FALSE(h.contains(FloatPoint(251, 100))); 318 EXPECT_FALSE(h.contains(FloatPoint(251, 100)));
322 EXPECT_FALSE(h.contains(FloatPoint(151, 100))); 319 EXPECT_FALSE(h.contains(FloatPoint(151, 100)));
323 EXPECT_FALSE(h.contains(FloatPoint(199, 100))); 320 EXPECT_FALSE(h.contains(FloatPoint(199, 100)));
324 EXPECT_FALSE(h.contains(FloatPoint(175, 125))); 321 EXPECT_FALSE(h.contains(FloatPoint(175, 125)));
325 EXPECT_FALSE(h.contains(FloatPoint(151, 250))); 322 EXPECT_FALSE(h.contains(FloatPoint(151, 250)));
326 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); 323 EXPECT_FALSE(h.contains(FloatPoint(199, 250)));
327 EXPECT_FALSE(h.contains(FloatPoint(199, 250))); 324 EXPECT_FALSE(h.contains(FloatPoint(199, 250)));
328 EXPECT_FALSE(h.contains(FloatPoint(175, 225))); 325 EXPECT_FALSE(h.contains(FloatPoint(175, 225)));
329 } 326 }
330 327
331 } // namespace 328 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698