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 "ash/wm/window_util.h" | 5 #include "ash/wm/window_util.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 | 10 |
11 namespace ash { | 11 namespace ash { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 std::string GetAdjustedBounds(const gfx::Rect& visible, | 15 std::string GetAdjustedBounds(const gfx::Rect& visible, |
16 gfx::Rect to_be_adjusted) { | 16 gfx::Rect to_be_adjusted) { |
17 wm::AdjustBoundsToEnsureMinimumWindowVisibility(visible, &to_be_adjusted); | 17 wm::AdjustBoundsToEnsureMinimumWindowVisibility(visible, &to_be_adjusted); |
18 return to_be_adjusted.ToString(); | 18 return to_be_adjusted.ToString(); |
19 } | 19 } |
20 | 20 |
21 } | 21 } |
22 | 22 |
23 typedef test::AshTestBase WindowUtilTest; | 23 typedef test::AshTestBase WindowUtilTest; |
24 | 24 |
25 TEST_F(WindowUtilTest, CenterWindow) { | 25 TEST_F(WindowUtilTest, CenterWindow) { |
26 if (!SupportsMultipleDisplays()) | 26 if (!SupportsMultipleDisplays()) |
27 return; | 27 return; |
28 | 28 |
29 UpdateDisplay("500x400, 600x400"); | 29 UpdateDisplay("500x400, 600x400"); |
30 scoped_ptr<aura::Window> window( | 30 scoped_ptr<aura::Window> window( |
31 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); | 31 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); |
32 wm::CenterWindow(window.get()); | 32 wm::CenterWindow(window.get()); |
33 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); | 33 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); |
34 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); | 34 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); |
35 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), | 35 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), |
36 ScreenAsh::GetSecondaryDisplay()); | 36 ScreenUtil::GetSecondaryDisplay()); |
37 wm::CenterWindow(window.get()); | 37 wm::CenterWindow(window.get()); |
38 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); | 38 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); |
39 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); | 39 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); |
40 } | 40 } |
41 | 41 |
42 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { | 42 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { |
43 const gfx::Rect visible_bounds(0, 0, 100, 100); | 43 const gfx::Rect visible_bounds(0, 0, 100, 100); |
44 | 44 |
45 EXPECT_EQ("0,0 90x90", | 45 EXPECT_EQ("0,0 90x90", |
46 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); | 46 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-250, -40, 150, 150))); | 83 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-250, -40, 150, 150))); |
84 EXPECT_EQ( | 84 EXPECT_EQ( |
85 "-290,-50 100x100", | 85 "-290,-50 100x100", |
86 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-400, -60, 150, 150))); | 86 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-400, -60, 150, 150))); |
87 EXPECT_EQ( | 87 EXPECT_EQ( |
88 "-110,0 100x100", | 88 "-110,0 100x100", |
89 GetAdjustedBounds(visible_bounds_left, gfx::Rect(0, 0, 150, 150))); | 89 GetAdjustedBounds(visible_bounds_left, gfx::Rect(0, 0, 150, 150))); |
90 } | 90 } |
91 | 91 |
92 } // namespace ash | 92 } // namespace ash |
OLD | NEW |