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

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

Issue 1285413007: Unify geometry test printers in a test support target. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: PrintTo instead of operator<< Created 5 years, 4 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/platform/geometry/FloatRoundedRect.h ('k') | Source/platform/geometry/FloatSize.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 16 matching lines...) Expand all
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 #include "platform/geometry/FloatRoundedRect.h" 31 #include "platform/geometry/FloatRoundedRect.h"
32 32
33 #include <gtest/gtest.h> 33 #include <gtest/gtest.h>
34 34
35 namespace blink { 35 namespace blink {
36 36
37 void PrintTo(const FloatSize& size, std::ostream* os)
38 {
39 *os << "FloatSize("
40 << size.width() << ", "
41 << size.height() << ")";
42 }
43
44 void PrintTo(const FloatRect& rect, std::ostream* os)
45 {
46 *os << "FloatRect("
47 << rect.x() << ", "
48 << rect.y() << ", "
49 << rect.width() << ", "
50 << rect.height() << ")";
51 }
52
53 void PrintTo(const FloatRoundedRect::Radii& radii, std::ostream* os)
54 {
55 *os << "FloatRoundedRect::Radii("
56 << ::testing::PrintToString(radii.topLeft()) << ", "
57 << ::testing::PrintToString(radii.topRight()) << ", "
58 << ::testing::PrintToString(radii.bottomRight()) << ", "
59 << ::testing::PrintToString(radii.bottomLeft()) << ")";
60 }
61
62 void PrintTo(const FloatRoundedRect& roundedRect, std::ostream* os)
63 {
64 *os << "FloatRoundedRect("
65 << ::testing::PrintToString(roundedRect.rect()) << ", "
66 << ::testing::PrintToString(roundedRect.radii()) << ")";
67 }
68
69 #define TEST_INTERCEPTS(roundedRect, yCoordinate, expectedMinXIntercept, expecte dMaxXIntercept) \ 37 #define TEST_INTERCEPTS(roundedRect, yCoordinate, expectedMinXIntercept, expecte dMaxXIntercept) \
70 { \ 38 { \
71 float minXIntercept; \ 39 float minXIntercept; \
72 float maxXIntercept; \ 40 float maxXIntercept; \
73 EXPECT_TRUE(roundedRect.xInterceptsAtY(yCoordinate, minXIntercept, maxXInter cept)); \ 41 EXPECT_TRUE(roundedRect.xInterceptsAtY(yCoordinate, minXIntercept, maxXInter cept)); \
74 EXPECT_FLOAT_EQ(expectedMinXIntercept, minXIntercept); \ 42 EXPECT_FLOAT_EQ(expectedMinXIntercept, minXIntercept); \
75 EXPECT_FLOAT_EQ(expectedMaxXIntercept, maxXIntercept); \ 43 EXPECT_FLOAT_EQ(expectedMaxXIntercept, maxXIntercept); \
76 } 44 }
77 45
78 TEST(FloatRoundedRectTest, zeroRadii) 46 TEST(FloatRoundedRectTest, zeroRadii)
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 FloatRoundedRect r1(collapsedRect); 169 FloatRoundedRect r1(collapsedRect);
202 EXPECT_TRUE(r1.radiusCenterRect().isEmpty()); 170 EXPECT_TRUE(r1.radiusCenterRect().isEmpty());
203 171
204 FloatRoundedRect::Radii radiiWithTooLargeCorner(FloatSize(55, 55), FloatSize (), FloatSize(), FloatSize()); 172 FloatRoundedRect::Radii radiiWithTooLargeCorner(FloatSize(55, 55), FloatSize (), FloatSize(), FloatSize());
205 FloatRoundedRect r2(FloatRect(0, 0, 100, 50), radiiWithTooLargeCorner); 173 FloatRoundedRect r2(FloatRect(0, 0, 100, 50), radiiWithTooLargeCorner);
206 EXPECT_TRUE(r2.radiusCenterRect().isEmpty()); 174 EXPECT_TRUE(r2.radiusCenterRect().isEmpty());
207 } 175 }
208 176
209 } // namespace blink 177 } // namespace blink
210 178
OLDNEW
« no previous file with comments | « Source/platform/geometry/FloatRoundedRect.h ('k') | Source/platform/geometry/FloatSize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698