| 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/common/wm/window_positioning_utils.h" | 7 #include "ash/common/wm/window_positioning_utils.h" |
| 8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 11 #include "ash/wm/window_state_aura.h" | 11 #include "ash/wm/window_state_aura.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/display/manager/display_manager.h" | |
| 14 #include "ui/display/screen.h" | 13 #include "ui/display/screen.h" |
| 15 | 14 |
| 16 namespace ash { | 15 namespace ash { |
| 17 namespace wm { | 16 namespace wm { |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 std::string GetAdjustedBounds(const gfx::Rect& visible, | 20 std::string GetAdjustedBounds(const gfx::Rect& visible, |
| 22 gfx::Rect to_be_adjusted) { | 21 gfx::Rect to_be_adjusted) { |
| 23 AdjustBoundsToEnsureMinimumWindowVisibility(visible, &to_be_adjusted); | 22 AdjustBoundsToEnsureMinimumWindowVisibility(visible, &to_be_adjusted); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); | 33 CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100))); |
| 35 | 34 |
| 36 WindowState* window_state = GetWindowState(window.get()); | 35 WindowState* window_state = GetWindowState(window.get()); |
| 37 EXPECT_FALSE(window_state->bounds_changed_by_user()); | 36 EXPECT_FALSE(window_state->bounds_changed_by_user()); |
| 38 | 37 |
| 39 CenterWindow(WmWindow::Get(window.get())); | 38 CenterWindow(WmWindow::Get(window.get())); |
| 40 // Centring window is considered as a user's action. | 39 // Centring window is considered as a user's action. |
| 41 EXPECT_TRUE(window_state->bounds_changed_by_user()); | 40 EXPECT_TRUE(window_state->bounds_changed_by_user()); |
| 42 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); | 41 EXPECT_EQ("200,126 100x100", window->bounds().ToString()); |
| 43 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); | 42 EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); |
| 44 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), | 43 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); |
| 45 display_manager()->GetSecondaryDisplay()); | |
| 46 CenterWindow(WmWindow::Get(window.get())); | 44 CenterWindow(WmWindow::Get(window.get())); |
| 47 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); | 45 EXPECT_EQ("250,126 100x100", window->bounds().ToString()); |
| 48 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); | 46 EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); |
| 49 } | 47 } |
| 50 | 48 |
| 51 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { | 49 TEST_F(WindowUtilTest, AdjustBoundsToEnsureMinimumVisibility) { |
| 52 const gfx::Rect visible_bounds(0, 0, 100, 100); | 50 const gfx::Rect visible_bounds(0, 0, 100, 100); |
| 53 | 51 |
| 54 EXPECT_EQ("0,0 90x90", | 52 EXPECT_EQ("0,0 90x90", |
| 55 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); | 53 GetAdjustedBounds(visible_bounds, gfx::Rect(0, 0, 90, 90))); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 138 |
| 141 EXPECT_TRUE(MoveWindowToDisplay(window.get(), original_display_id)); | 139 EXPECT_TRUE(MoveWindowToDisplay(window.get(), original_display_id)); |
| 142 EXPECT_EQ(original_display_id, | 140 EXPECT_EQ(original_display_id, |
| 143 screen->GetDisplayNearestWindow(window.get()).id()); | 141 screen->GetDisplayNearestWindow(window.get()).id()); |
| 144 EXPECT_EQ(original_container_id, window->parent()->id()); | 142 EXPECT_EQ(original_container_id, window->parent()->id()); |
| 145 EXPECT_EQ(original_root, window->GetRootWindow()); | 143 EXPECT_EQ(original_root, window->GetRootWindow()); |
| 146 } | 144 } |
| 147 | 145 |
| 148 } // namespace wm | 146 } // namespace wm |
| 149 } // namespace ash | 147 } // namespace ash |
| OLD | NEW |