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

Side by Side Diff: ui/gfx/rect_unittest.cc

Issue 11410024: ui: Remove gfx::Size::ClampToNonNegative, prevent negative sizes always. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: negative-width Created 7 years, 11 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 | « ui/gfx/rect_f.h ('k') | ui/gfx/size.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/rect.h" 7 #include "ui/gfx/rect.h"
8 #include "ui/gfx/rect_conversions.h" 8 #include "ui/gfx/rect_conversions.h"
9 #include "ui/gfx/skia_util.h" 9 #include "ui/gfx/skia_util.h"
10 10
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 std::numeric_limits<float>::quiet_NaN(), 434 std::numeric_limits<float>::quiet_NaN(),
435 std::numeric_limits<float>::quiet_NaN(), 435 std::numeric_limits<float>::quiet_NaN(),
436 std::numeric_limits<float>::quiet_NaN(), 436 std::numeric_limits<float>::quiet_NaN(),
437 std::numeric_limits<float>::quiet_NaN(), 437 std::numeric_limits<float>::quiet_NaN(),
438 std::numeric_limits<float>::quiet_NaN() }, 438 std::numeric_limits<float>::quiet_NaN() },
439 { 3, 3, 3, 3, 439 { 3, 3, 3, 3,
440 std::numeric_limits<float>::max(), 440 std::numeric_limits<float>::max(),
441 std::numeric_limits<float>::max(), 441 std::numeric_limits<float>::max(),
442 std::numeric_limits<float>::max(), 442 std::numeric_limits<float>::max(),
443 std::numeric_limits<float>::max(), 443 std::numeric_limits<float>::max(),
444 std::numeric_limits<float>::max() }, 444 std::numeric_limits<float>::max() }
445 { 3, 3, 3, 3,
446 -1.0f,
447 -3.0f, -3.0f, 0.0f, 0.0f }
448 }; 445 };
449 446
450 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 447 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
451 Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1); 448 Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
452 RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2); 449 RectF r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
453 450
454 RectF scaled = ScaleRect(r1, tests[i].scale); 451 RectF scaled = ScaleRect(r1, tests[i].scale);
455 EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x()); 452 EXPECT_FLOAT_AND_NAN_EQ(r2.x(), scaled.x());
456 EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y()); 453 EXPECT_FLOAT_AND_NAN_EQ(r2.y(), scaled.y());
457 EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width()); 454 EXPECT_FLOAT_AND_NAN_EQ(r2.width(), scaled.width());
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 EXPECT_EQ(Point(1, 6).ToString(), i.bottom_left().ToString()); 749 EXPECT_EQ(Point(1, 6).ToString(), i.bottom_left().ToString());
753 EXPECT_EQ(Point(4, 6).ToString(), i.bottom_right().ToString()); 750 EXPECT_EQ(Point(4, 6).ToString(), i.bottom_right().ToString());
754 751
755 EXPECT_EQ(PointF(1.1f, 2.1f).ToString(), f.origin().ToString()); 752 EXPECT_EQ(PointF(1.1f, 2.1f).ToString(), f.origin().ToString());
756 EXPECT_EQ(PointF(4.2f, 2.1f).ToString(), f.top_right().ToString()); 753 EXPECT_EQ(PointF(4.2f, 2.1f).ToString(), f.top_right().ToString());
757 EXPECT_EQ(PointF(1.1f, 6.2f).ToString(), f.bottom_left().ToString()); 754 EXPECT_EQ(PointF(1.1f, 6.2f).ToString(), f.bottom_left().ToString());
758 EXPECT_EQ(PointF(4.2f, 6.2f).ToString(), f.bottom_right().ToString()); 755 EXPECT_EQ(PointF(4.2f, 6.2f).ToString(), f.bottom_right().ToString());
759 } 756 }
760 757
761 } // namespace gfx 758 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/rect_f.h ('k') | ui/gfx/size.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698