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/aura/wm_window_aura.h" |
7 #include "ash/common/wm/window_positioning_utils.h" | 8 #include "ash/common/wm/window_positioning_utils.h" |
8 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
9 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
10 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
11 #include "ash/wm/window_state_aura.h" | 12 #include "ash/wm/window_state_aura.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 | 14 |
14 namespace ash { | 15 namespace ash { |
15 | 16 |
16 namespace { | 17 namespace { |
(...skipping 11 matching lines...) Expand all Loading... |
28 if (!SupportsMultipleDisplays()) | 29 if (!SupportsMultipleDisplays()) |
29 return; | 30 return; |
30 | 31 |
31 UpdateDisplay("500x400, 600x400"); | 32 UpdateDisplay("500x400, 600x400"); |
32 std::unique_ptr<aura::Window> window( | 33 std::unique_ptr<aura::Window> window( |
33 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); | 34 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); |
34 | 35 |
35 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 36 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
36 EXPECT_FALSE(window_state->bounds_changed_by_user()); | 37 EXPECT_FALSE(window_state->bounds_changed_by_user()); |
37 | 38 |
38 wm::CenterWindow(window.get()); | 39 wm::CenterWindow(WmWindowAura::Get(window.get())); |
39 // Centring window is considered as a user's action. | 40 // Centring window is considered as a user's action. |
40 EXPECT_TRUE(window_state->bounds_changed_by_user()); | 41 EXPECT_TRUE(window_state->bounds_changed_by_user()); |
41 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); | 42 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); |
42 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); | 43 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); |
43 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), | 44 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), |
44 ScreenUtil::GetSecondaryDisplay()); | 45 ScreenUtil::GetSecondaryDisplay()); |
45 wm::CenterWindow(window.get()); | 46 wm::CenterWindow(WmWindowAura::Get(window.get())); |
46 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); | 47 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); |
47 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); | 48 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); |
48 } | 49 } |
49 | 50 |
50 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { | 51 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { |
51 const gfx::Rect visible_bounds(0, 0, 100, 100); | 52 const gfx::Rect visible_bounds(0, 0, 100, 100); |
52 | 53 |
53 EXPECT_EQ("0,0 90x90", | 54 EXPECT_EQ("0,0 90x90", |
54 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); | 55 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); |
55 EXPECT_EQ("0,0 100x100", | 56 EXPECT_EQ("0,0 100x100", |
(...skipping 29 matching lines...) Expand all Loading... |
85 "-250,-40 100x100", | 86 "-250,-40 100x100", |
86 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-250, -40, 150, 150))); | 87 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-250, -40, 150, 150))); |
87 EXPECT_EQ( | 88 EXPECT_EQ( |
88 "-275,-50 100x100", | 89 "-275,-50 100x100", |
89 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-400, -60, 150, 150))); | 90 GetAdjustedBounds(visible_bounds_left, gfx::Rect(-400, -60, 150, 150))); |
90 EXPECT_EQ("-125,0 100x100", | 91 EXPECT_EQ("-125,0 100x100", |
91 GetAdjustedBounds(visible_bounds_left, gfx::Rect(0, 0, 150, 150))); | 92 GetAdjustedBounds(visible_bounds_left, gfx::Rect(0, 0, 150, 150))); |
92 } | 93 } |
93 | 94 |
94 } // namespace ash | 95 } // namespace ash |
OLD | NEW |