OLD | NEW |
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 Loading... |
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 gfx::RectF b(10, 20, 30, 40); | 600 gfx::RectF b(10, 20, 30, 40); |
601 | 601 |
602 gfx::RectF intersect = gfx::IntersectRects(a, b); | 602 gfx::RectF intersect = gfx::IntersectRects(a, b); |
603 EXPECT_EQ(b.ToString(), intersect.ToString()); | 603 EXPECT_EQ(b.ToString(), intersect.ToString()); |
604 | 604 |
605 EXPECT_EQ(a, b); | 605 EXPECT_EQ(a, b); |
606 EXPECT_EQ(b, a); | 606 EXPECT_EQ(b, a); |
607 } | 607 } |
608 | 608 |
609 } // namespace ui | 609 } // namespace ui |
OLD | NEW |