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/skia_util.h" | 8 #include "ui/gfx/skia_util.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
11 | 11 |
12 TEST(RectTest, Contains) { | 12 TEST(RectTest, Contains) { |
13 static const struct ContainsCase { | 13 static const struct ContainsCase { |
14 int rect_x; | 14 int rect_x; |
15 int rect_y; | 15 int rect_y; |
16 int rect_width; | 16 int rect_width; |
17 int rect_height; | 17 int rect_height; |
18 int point_x; | 18 int point_x; |
19 int point_y; | 19 int point_y; |
20 bool contained; | 20 bool contained; |
21 } contains_cases[] = { | 21 } contains_cases[] = { |
22 {0, 0, 10, 10, 0, 0, true}, | 22 {0, 0, 10, 10, 0, 0, true}, |
23 {0, 0, 10, 10, 5, 5, true}, | 23 {0, 0, 10, 10, 5, 5, true}, |
24 {0, 0, 10, 10, 9, 9, true}, | 24 {0, 0, 10, 10, 9, 9, true}, |
25 {0, 0, 10, 10, 5, 10, false}, | 25 {0, 0, 10, 10, 5, 10, false}, |
26 {0, 0, 10, 10, 10, 5, false}, | 26 {0, 0, 10, 10, 10, 5, false}, |
27 {0, 0, 10, 10, -1, -1, false}, | 27 {0, 0, 10, 10, -1, -1, false}, |
28 {0, 0, 10, 10, 50, 50, false}, | 28 {0, 0, 10, 10, 50, 50, false}, |
29 #ifdef NDEBUG | 29 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
30 {0, 0, -10, -10, 0, 0, false}, | 30 {0, 0, -10, -10, 0, 0, false}, |
31 #endif // NDEBUG | 31 #endif |
32 }; | 32 }; |
33 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(contains_cases); ++i) { | 33 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(contains_cases); ++i) { |
34 const ContainsCase& value = contains_cases[i]; | 34 const ContainsCase& value = contains_cases[i]; |
35 gfx::Rect rect(value.rect_x, value.rect_y, | 35 gfx::Rect rect(value.rect_x, value.rect_y, |
36 value.rect_width, value.rect_height); | 36 value.rect_width, value.rect_height); |
37 EXPECT_EQ(value.contained, rect.Contains(value.point_x, value.point_y)); | 37 EXPECT_EQ(value.contained, rect.Contains(value.point_x, value.point_y)); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 TEST(RectTest, Intersects) { | 41 TEST(RectTest, Intersects) { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 #if defined(OS_WIN) | 323 #if defined(OS_WIN) |
324 TEST(RectTest, ConstructAndAssign) { | 324 TEST(RectTest, ConstructAndAssign) { |
325 const RECT rect_1 = { 0, 0, 10, 10 }; | 325 const RECT rect_1 = { 0, 0, 10, 10 }; |
326 const RECT rect_2 = { 0, 0, -10, -10 }; | 326 const RECT rect_2 = { 0, 0, -10, -10 }; |
327 gfx::Rect test1(rect_1); | 327 gfx::Rect test1(rect_1); |
328 gfx::Rect test2(rect_2); | 328 gfx::Rect test2(rect_2); |
329 } | 329 } |
330 #endif | 330 #endif |
331 | 331 |
332 } // namespace ui | 332 } // namespace ui |
OLD | NEW |