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

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

Issue 11275089: SkRect to gfx::Rect type conversions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove unnecessary lines Created 8 years, 1 month 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 // 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 gfx::Rect just_below_no_edge(2, 8, 3, 2); // too narrow 388 gfx::Rect just_below_no_edge(2, 8, 3, 2); // too narrow
389 gfx::Rect just_left_no_edge(0, 3, 2, 6); // too tall 389 gfx::Rect just_left_no_edge(0, 3, 2, 6); // too tall
390 gfx::Rect just_right_no_edge(6, 3, 2, 4); // too short 390 gfx::Rect just_right_no_edge(6, 3, 2, 4); // too short
391 391
392 EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge)); 392 EXPECT_FALSE(r.SharesEdgeWith(just_above_no_edge));
393 EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge)); 393 EXPECT_FALSE(r.SharesEdgeWith(just_below_no_edge));
394 EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge)); 394 EXPECT_FALSE(r.SharesEdgeWith(just_left_no_edge));
395 EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge)); 395 EXPECT_FALSE(r.SharesEdgeWith(just_right_no_edge));
396 } 396 }
397 397
398 TEST(RectTest, SkRectToRect) { 398 TEST(RectTest, SkIRectToRect) {
399 gfx::Rect src(10, 20, 30, 40); 399 gfx::Rect src(10, 20, 30, 40);
400 SkRect skrect = gfx::RectToSkRect(src); 400 SkIRect skrect = gfx::RectToSkIRect(src);
401 EXPECT_EQ(src, gfx::SkRectToRect(skrect)); 401 EXPECT_EQ(src, gfx::SkIRectToRect(skrect));
402 } 402 }
403 403
404 // Similar to EXPECT_FLOAT_EQ, but lets NaN equal NaN 404 // Similar to EXPECT_FLOAT_EQ, but lets NaN equal NaN
405 #define EXPECT_FLOAT_AND_NAN_EQ(a, b) \ 405 #define EXPECT_FLOAT_AND_NAN_EQ(a, b) \
406 { if (a == a || b == b) { EXPECT_FLOAT_EQ(a, b); } } 406 { if (a == a || b == b) { EXPECT_FLOAT_EQ(a, b); } }
407 407
408 TEST(RectTest, ScaleRect) { 408 TEST(RectTest, ScaleRect) {
409 static const struct Test { 409 static const struct Test {
410 int x1; // source 410 int x1; // source
411 int y1; 411 int y1;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 gfx::RectF(-4.2f, -4.2f, 11.0f, 11.0f) } 665 gfx::RectF(-4.2f, -4.2f, 11.0f, 11.0f) }
666 }; 666 };
667 667
668 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i) { 668 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(float_tests); ++i) {
669 gfx::RectF actual = BoundingRect(float_tests[i].a, float_tests[i].b); 669 gfx::RectF actual = BoundingRect(float_tests[i].a, float_tests[i].b);
670 EXPECT_EQ(float_tests[i].expected.ToString(), actual.ToString()); 670 EXPECT_EQ(float_tests[i].expected.ToString(), actual.ToString());
671 } 671 }
672 } 672 }
673 673
674 } // namespace ui 674 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698