| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/gfx/geometry/rect.h" | 9 #include "ui/gfx/geometry/rect.h" |
| 10 #include "ui/gfx/geometry/rect_conversions.h" | 10 #include "ui/gfx/geometry/rect_conversions.h" |
| 11 #include "ui/gfx/test/gfx_util.h" | 11 #include "ui/gfx/test/gfx_util.h" |
| 12 | 12 |
| 13 #if defined(OS_WIN) | |
| 14 #include <windows.h> | |
| 15 #endif | |
| 16 | |
| 17 namespace gfx { | 13 namespace gfx { |
| 18 | 14 |
| 19 TEST(RectTest, Contains) { | 15 TEST(RectTest, Contains) { |
| 20 static const struct ContainsCase { | 16 static const struct ContainsCase { |
| 21 int rect_x; | 17 int rect_x; |
| 22 int rect_y; | 18 int rect_y; |
| 23 int rect_width; | 19 int rect_width; |
| 24 int rect_height; | 20 int rect_height; |
| 25 int point_x; | 21 int point_x; |
| 26 int point_y; | 22 int point_y; |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 689 } |
| 694 }; | 690 }; |
| 695 | 691 |
| 696 for (size_t i = 0; i < arraysize(tests); ++i) { | 692 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 697 Rect result = ScaleToEnclosingRect(tests[i].input_rect, | 693 Rect result = ScaleToEnclosingRect(tests[i].input_rect, |
| 698 tests[i].input_scale); | 694 tests[i].input_scale); |
| 699 EXPECT_EQ(tests[i].expected_rect, result); | 695 EXPECT_EQ(tests[i].expected_rect, result); |
| 700 } | 696 } |
| 701 } | 697 } |
| 702 | 698 |
| 703 #if defined(OS_WIN) | |
| 704 TEST(RectTest, ConstructAndAssign) { | |
| 705 const RECT rect_1 = { 0, 0, 10, 10 }; | |
| 706 const RECT rect_2 = { 0, 0, -10, -10 }; | |
| 707 Rect test1(rect_1); | |
| 708 Rect test2(rect_2); | |
| 709 } | |
| 710 #endif | |
| 711 | |
| 712 TEST(RectTest, ToRectF) { | 699 TEST(RectTest, ToRectF) { |
| 713 // Check that implicit conversion from integer to float compiles. | 700 // Check that implicit conversion from integer to float compiles. |
| 714 Rect a(10, 20, 30, 40); | 701 Rect a(10, 20, 30, 40); |
| 715 RectF b(10, 20, 30, 40); | 702 RectF b(10, 20, 30, 40); |
| 716 | 703 |
| 717 RectF intersect = IntersectRects(a, b); | 704 RectF intersect = IntersectRects(a, b); |
| 718 EXPECT_EQ(b, intersect); | 705 EXPECT_EQ(b, intersect); |
| 719 | 706 |
| 720 EXPECT_EQ(a, b); | 707 EXPECT_EQ(a, b); |
| 721 EXPECT_EQ(b, a); | 708 EXPECT_EQ(b, a); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 1.1f, 1.0f))); | 901 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 1.1f, 1.0f))); |
| 915 EXPECT_FLOAT_EQ( | 902 EXPECT_FLOAT_EQ( |
| 916 0.1f + kEpsilon, | 903 0.1f + kEpsilon, |
| 917 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.4f, 1.0f))); | 904 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.4f, 1.0f))); |
| 918 EXPECT_FLOAT_EQ( | 905 EXPECT_FLOAT_EQ( |
| 919 kEpsilon, | 906 kEpsilon, |
| 920 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f))); | 907 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f))); |
| 921 } | 908 } |
| 922 | 909 |
| 923 } // namespace gfx | 910 } // namespace gfx |
| OLD | NEW |