| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 wm::WindowState* window_state = window->GetWindowState(); | 112 wm::WindowState* window_state = window->GetWindowState(); |
| 113 | 113 |
| 114 // This will not be used for un-minimizing window. | 114 // This will not be used for un-minimizing window. |
| 115 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 115 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
| 116 window_state->Minimize(); | 116 window_state->Minimize(); |
| 117 window_state->Restore(); | 117 window_state->Restore(); |
| 118 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); | 118 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); |
| 119 EXPECT_EQ("10,15 25x35", window->GetBounds().ToString()); | 119 EXPECT_EQ("10,15 25x35", window->GetBounds().ToString()); |
| 120 | 120 |
| 121 if (!SupportsMultipleDisplays()) | |
| 122 return; | |
| 123 | |
| 124 UpdateDisplay("400x300,500x400"); | 121 UpdateDisplay("400x300,500x400"); |
| 125 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); | 122 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); |
| 126 EXPECT_EQ(WmShell::Get()->GetAllRootWindows()[1], window->GetRootWindow()); | 123 EXPECT_EQ(WmShell::Get()->GetAllRootWindows()[1], window->GetRootWindow()); |
| 127 window_state->Minimize(); | 124 window_state->Minimize(); |
| 128 // This will not be used for un-minimizing window. | 125 // This will not be used for un-minimizing window. |
| 129 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 126 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
| 130 window_state->Restore(); | 127 window_state->Restore(); |
| 131 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); | 128 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); |
| 132 | 129 |
| 133 // Make sure the unminimized window moves inside the display when | 130 // Make sure the unminimized window moves inside the display when |
| 134 // 2nd display is disconnected. | 131 // 2nd display is disconnected. |
| 135 window_state->Minimize(); | 132 window_state->Minimize(); |
| 136 UpdateDisplay("400x300"); | 133 UpdateDisplay("400x300"); |
| 137 window_state->Restore(); | 134 window_state->Restore(); |
| 138 EXPECT_EQ(WmShell::Get()->GetPrimaryRootWindow(), window->GetRootWindow()); | 135 EXPECT_EQ(WmShell::Get()->GetPrimaryRootWindow(), window->GetRootWindow()); |
| 139 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 136 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
| 140 window->GetBounds())); | 137 window->GetBounds())); |
| 141 } | 138 } |
| 142 | 139 |
| 143 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { | 140 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { |
| 144 if (!SupportsMultipleDisplays()) | |
| 145 return; | |
| 146 | |
| 147 UpdateDisplay("300x400,400x500"); | 141 UpdateDisplay("300x400,400x500"); |
| 148 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 142 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); |
| 149 | 143 |
| 150 if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0)) | 144 if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0)) |
| 151 return; | 145 return; |
| 152 | 146 |
| 153 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 147 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 154 display::test::CreateDisplayLayout(display_manager(), | 148 display::test::CreateDisplayLayout(display_manager(), |
| 155 display::DisplayPlacement::TOP, 0)); | 149 display::DisplayPlacement::TOP, 0)); |
| 156 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); | 150 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds()); | 206 EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds()); |
| 213 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); | 207 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); |
| 214 window_state->Restore(); | 208 window_state->Restore(); |
| 215 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 209 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
| 216 window->GetBounds())); | 210 window->GetBounds())); |
| 217 // Y bounds should not be negative. | 211 // Y bounds should not be negative. |
| 218 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); | 212 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); |
| 219 } | 213 } |
| 220 | 214 |
| 221 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { | 215 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { |
| 222 if (!SupportsMultipleDisplays()) | |
| 223 return; | |
| 224 UpdateDisplay("300x400,400x500"); | 216 UpdateDisplay("300x400,400x500"); |
| 225 | 217 |
| 226 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 218 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); |
| 227 | 219 |
| 228 std::unique_ptr<WindowOwner> window_owner( | 220 std::unique_ptr<WindowOwner> window_owner( |
| 229 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 221 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); |
| 230 WmWindow* window = window_owner->window(); | 222 WmWindow* window = window_owner->window(); |
| 231 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 223 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 232 | 224 |
| 233 wm::WindowState* window_state = window->GetWindowState(); | 225 wm::WindowState* window_state = window->GetWindowState(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 EXPECT_EQ( | 266 EXPECT_EQ( |
| 275 gfx::Rect(300, 0, 400, 500 - GetShelfConstant(SHELF_SIZE)).ToString(), | 267 gfx::Rect(300, 0, 400, 500 - GetShelfConstant(SHELF_SIZE)).ToString(), |
| 276 w1->GetWindowBoundsInScreen().ToString()); | 268 w1->GetWindowBoundsInScreen().ToString()); |
| 277 w1->Restore(); | 269 w1->Restore(); |
| 278 EXPECT_EQ(root_windows[1], | 270 EXPECT_EQ(root_windows[1], |
| 279 wm_lookup->GetWindowForWidget(w1.get())->GetRootWindow()); | 271 wm_lookup->GetWindowForWidget(w1.get())->GetRootWindow()); |
| 280 EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString()); | 272 EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString()); |
| 281 } | 273 } |
| 282 | 274 |
| 283 TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) { | 275 TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) { |
| 284 if (!SupportsMultipleDisplays()) | |
| 285 return; | |
| 286 UpdateDisplay("300x400,400x500"); | 276 UpdateDisplay("300x400,400x500"); |
| 287 | 277 |
| 288 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 278 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); |
| 289 | 279 |
| 290 std::unique_ptr<WindowOwner> window_owner( | 280 std::unique_ptr<WindowOwner> window_owner( |
| 291 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 281 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); |
| 292 WmWindow* window = window_owner->window(); | 282 WmWindow* window = window_owner->window(); |
| 293 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 283 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
| 294 | 284 |
| 295 wm::WindowState* window_state = window->GetWindowState(); | 285 wm::WindowState* window_state = window->GetWindowState(); |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 changed_window_bounds.Offset(0, -shift); | 1309 changed_window_bounds.Offset(0, -shift); |
| 1320 // Window should be shifted up. | 1310 // Window should be shifted up. |
| 1321 EXPECT_EQ(changed_window_bounds, window->GetBounds()); | 1311 EXPECT_EQ(changed_window_bounds, window->GetBounds()); |
| 1322 | 1312 |
| 1323 kb_controller->HideKeyboard( | 1313 kb_controller->HideKeyboard( |
| 1324 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 1314 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 1325 EXPECT_EQ(orig_window_bounds, window->GetBounds()); | 1315 EXPECT_EQ(orig_window_bounds, window->GetBounds()); |
| 1326 } | 1316 } |
| 1327 | 1317 |
| 1328 } // namespace ash | 1318 } // namespace ash |
| OLD | NEW |