| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/wm/workspace/workspace_layout_manager.h" | 5 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 wm::WindowState* window_state = window->GetWindowState(); | 101 wm::WindowState* window_state = window->GetWindowState(); |
| 102 | 102 |
| 103 // This will not be used for un-minimizing window. | 103 // This will not be used for un-minimizing window. |
| 104 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 104 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
| 105 window_state->Minimize(); | 105 window_state->Minimize(); |
| 106 window_state->Restore(); | 106 window_state->Restore(); |
| 107 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); | 107 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); |
| 108 EXPECT_EQ("10,15 25x35", window->GetBounds().ToString()); | 108 EXPECT_EQ("10,15 25x35", window->GetBounds().ToString()); |
| 109 | 109 |
| 110 if (!SupportsMultipleDisplays()) | |
| 111 return; | |
| 112 | |
| 113 UpdateDisplay("400x300,500x400"); | 110 UpdateDisplay("400x300,500x400"); |
| 114 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); | 111 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); |
| 115 EXPECT_EQ(WmShell::Get()->GetAllRootWindows()[1], window->GetRootWindow()); | 112 EXPECT_EQ(WmShell::Get()->GetAllRootWindows()[1], window->GetRootWindow()); |
| 116 window_state->Minimize(); | 113 window_state->Minimize(); |
| 117 // This will not be used for un-minimizing window. | 114 // This will not be used for un-minimizing window. |
| 118 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 115 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
| 119 window_state->Restore(); | 116 window_state->Restore(); |
| 120 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); | 117 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); |
| 121 | 118 |
| 122 // Make sure the unminimized window moves inside the display when | 119 // Make sure the unminimized window moves inside the display when |
| 123 // 2nd display is disconnected. | 120 // 2nd display is disconnected. |
| 124 window_state->Minimize(); | 121 window_state->Minimize(); |
| 125 UpdateDisplay("400x300"); | 122 UpdateDisplay("400x300"); |
| 126 window_state->Restore(); | 123 window_state->Restore(); |
| 127 EXPECT_EQ(WmShell::Get()->GetPrimaryRootWindow(), window->GetRootWindow()); | 124 EXPECT_EQ(WmShell::Get()->GetPrimaryRootWindow(), window->GetRootWindow()); |
| 128 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 125 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
| 129 window->GetBounds())); | 126 window->GetBounds())); |
| 130 } | 127 } |
| 131 | 128 |
| 132 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { | 129 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { |
| 133 if (!SupportsMultipleDisplays()) | |
| 134 return; | |
| 135 | |
| 136 UpdateDisplay("300x400,400x500"); | 130 UpdateDisplay("300x400,400x500"); |
| 137 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 131 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); |
| 138 | 132 |
| 139 if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0)) | 133 if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0)) |
| 140 return; | 134 return; |
| 141 | 135 |
| 142 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); | 136 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); |
| 143 | 137 |
| 144 std::unique_ptr<WindowOwner> window1_owner( | 138 std::unique_ptr<WindowOwner> window1_owner( |
| 145 CreateTestWindow(gfx::Rect(10, -400, 200, 200))); | 139 CreateTestWindow(gfx::Rect(10, -400, 200, 200))); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds()); | 192 EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds()); |
| 199 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); | 193 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); |
| 200 window_state->Restore(); | 194 window_state->Restore(); |
| 201 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 195 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
| 202 window->GetBounds())); | 196 window->GetBounds())); |
| 203 // Y bounds should not be negative. | 197 // Y bounds should not be negative. |
| 204 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); | 198 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); |
| 205 } | 199 } |
| 206 | 200 |
| 207 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { | 201 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { |
| 208 if (!SupportsMultipleDisplays()) | |
| 209 return; | |
| 210 UpdateDisplay("300x400,400x500"); | 202 UpdateDisplay("300x400,400x500"); |
| 211 | 203 |
| 212 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 204 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); |
| 213 | 205 |
| 214 std::unique_ptr<WindowOwner> window_owner( | 206 std::unique_ptr<WindowOwner> window_owner( |
| 215 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 207 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); |
| 216 WmWindow* window = window_owner->window(); | 208 WmWindow* window = window_owner->window(); |
| 217 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 209 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 218 | 210 |
| 219 wm::WindowState* window_state = window->GetWindowState(); | 211 wm::WindowState* window_state = window->GetWindowState(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 EXPECT_EQ( | 252 EXPECT_EQ( |
| 261 gfx::Rect(300, 0, 400, 500 - GetShelfConstant(SHELF_SIZE)).ToString(), | 253 gfx::Rect(300, 0, 400, 500 - GetShelfConstant(SHELF_SIZE)).ToString(), |
| 262 w1->GetWindowBoundsInScreen().ToString()); | 254 w1->GetWindowBoundsInScreen().ToString()); |
| 263 w1->Restore(); | 255 w1->Restore(); |
| 264 EXPECT_EQ(root_windows[1], | 256 EXPECT_EQ(root_windows[1], |
| 265 wm_lookup->GetWindowForWidget(w1.get())->GetRootWindow()); | 257 wm_lookup->GetWindowForWidget(w1.get())->GetRootWindow()); |
| 266 EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString()); | 258 EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString()); |
| 267 } | 259 } |
| 268 | 260 |
| 269 TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) { | 261 TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) { |
| 270 if (!SupportsMultipleDisplays()) | |
| 271 return; | |
| 272 UpdateDisplay("300x400,400x500"); | 262 UpdateDisplay("300x400,400x500"); |
| 273 | 263 |
| 274 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 264 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); |
| 275 | 265 |
| 276 std::unique_ptr<WindowOwner> window_owner( | 266 std::unique_ptr<WindowOwner> window_owner( |
| 277 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 267 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); |
| 278 WmWindow* window = window_owner->window(); | 268 WmWindow* window = window_owner->window(); |
| 279 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 269 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 280 | 270 |
| 281 wm::WindowState* window_state = window->GetWindowState(); | 271 wm::WindowState* window_state = window->GetWindowState(); |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 window->SetBounds(keyboard_bounds()); | 1256 window->SetBounds(keyboard_bounds()); |
| 1267 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); | 1257 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); |
| 1268 window->Activate(); | 1258 window->Activate(); |
| 1269 | 1259 |
| 1270 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1260 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1271 ShowKeyboard(); | 1261 ShowKeyboard(); |
| 1272 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1262 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1273 } | 1263 } |
| 1274 | 1264 |
| 1275 } // namespace ash | 1265 } // namespace ash |
| OLD | NEW |