| OLD | NEW |
| 1 // Copyright (c) 2010 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 "app/win/win_util.h" | 5 #include "views/window/window_win.h" |
| 6 |
| 6 #include "gfx/rect.h" | 7 #include "gfx/rect.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 9 |
| 9 namespace app { | 10 namespace views { |
| 10 namespace win { | |
| 11 | 11 |
| 12 TEST(WinUtilTest, EnsureRectIsVisibleInRect) { | 12 TEST(WindowWinTest, EnsureRectIsVisibleInRect) { |
| 13 gfx::Rect parent_rect(0, 0, 500, 400); | 13 gfx::Rect parent_rect(0, 0, 500, 400); |
| 14 | 14 |
| 15 { | 15 { |
| 16 // Child rect x < 0 | 16 // Child rect x < 0 |
| 17 gfx::Rect child_rect(-50, 20, 100, 100); | 17 gfx::Rect child_rect(-50, 20, 100, 100); |
| 18 EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); | 18 internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); |
| 19 EXPECT_EQ(gfx::Rect(10, 20, 100, 100), child_rect); | 19 EXPECT_EQ(gfx::Rect(10, 20, 100, 100), child_rect); |
| 20 } | 20 } |
| 21 | 21 |
| 22 { | 22 { |
| 23 // Child rect y < 0 | 23 // Child rect y < 0 |
| 24 gfx::Rect child_rect(20, -50, 100, 100); | 24 gfx::Rect child_rect(20, -50, 100, 100); |
| 25 EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); | 25 internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); |
| 26 EXPECT_EQ(gfx::Rect(20, 10, 100, 100), child_rect); | 26 EXPECT_EQ(gfx::Rect(20, 10, 100, 100), child_rect); |
| 27 } | 27 } |
| 28 | 28 |
| 29 { | 29 { |
| 30 // Child rect right > parent_rect.right | 30 // Child rect right > parent_rect.right |
| 31 gfx::Rect child_rect(450, 20, 100, 100); | 31 gfx::Rect child_rect(450, 20, 100, 100); |
| 32 EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); | 32 internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); |
| 33 EXPECT_EQ(gfx::Rect(390, 20, 100, 100), child_rect); | 33 EXPECT_EQ(gfx::Rect(390, 20, 100, 100), child_rect); |
| 34 } | 34 } |
| 35 | 35 |
| 36 { | 36 { |
| 37 // Child rect bottom > parent_rect.bottom | 37 // Child rect bottom > parent_rect.bottom |
| 38 gfx::Rect child_rect(20, 350, 100, 100); | 38 gfx::Rect child_rect(20, 350, 100, 100); |
| 39 EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); | 39 internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); |
| 40 EXPECT_EQ(gfx::Rect(20, 290, 100, 100), child_rect); | 40 EXPECT_EQ(gfx::Rect(20, 290, 100, 100), child_rect); |
| 41 } | 41 } |
| 42 | 42 |
| 43 { | 43 { |
| 44 // Child rect width > parent_rect.width | 44 // Child rect width > parent_rect.width |
| 45 gfx::Rect child_rect(20, 20, 700, 100); | 45 gfx::Rect child_rect(20, 20, 700, 100); |
| 46 EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); | 46 internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); |
| 47 EXPECT_EQ(gfx::Rect(20, 20, 480, 100), child_rect); | 47 EXPECT_EQ(gfx::Rect(20, 20, 480, 100), child_rect); |
| 48 } | 48 } |
| 49 | 49 |
| 50 { | 50 { |
| 51 // Child rect height > parent_rect.height | 51 // Child rect height > parent_rect.height |
| 52 gfx::Rect child_rect(20, 20, 100, 700); | 52 gfx::Rect child_rect(20, 20, 100, 700); |
| 53 EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); | 53 internal::EnsureRectIsVisibleInRect(parent_rect, &child_rect, 10); |
| 54 EXPECT_EQ(gfx::Rect(20, 20, 100, 380), child_rect); | 54 EXPECT_EQ(gfx::Rect(20, 20, 100, 380), child_rect); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace win | 58 } // namespace views |
| 59 } // namespace app | |
| OLD | NEW |