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/wm/workspace/workspace_layout_manager.h" | 5 #include "ash/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/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
12 #include "ash/session/session_controller.h" | 12 #include "ash/session/session_controller.h" |
13 #include "ash/shelf/shelf_constants.h" | 13 #include "ash/shelf/shelf_constants.h" |
14 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
15 #include "ash/shelf/wm_shelf.h" | 15 #include "ash/shelf/wm_shelf.h" |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
17 #include "ash/shell_observer.h" | 17 #include "ash/shell_observer.h" |
| 18 #include "ash/shell_port.h" |
18 #include "ash/test/ash_test.h" | 19 #include "ash/test/ash_test.h" |
19 #include "ash/test/ash_test_base.h" | 20 #include "ash/test/ash_test_base.h" |
20 #include "ash/test/test_session_controller_client.h" | 21 #include "ash/test/test_session_controller_client.h" |
21 #include "ash/wm/fullscreen_window_finder.h" | 22 #include "ash/wm/fullscreen_window_finder.h" |
22 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" | 23 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" |
23 #include "ash/wm/window_state.h" | 24 #include "ash/wm/window_state.h" |
24 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
25 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
26 #include "ash/wm/wm_event.h" | 27 #include "ash/wm/wm_event.h" |
27 #include "ash/wm/wm_screen_util.h" | 28 #include "ash/wm/wm_screen_util.h" |
28 #include "ash/wm/workspace/workspace_window_resizer.h" | 29 #include "ash/wm/workspace/workspace_window_resizer.h" |
29 #include "ash/wm_shell.h" | |
30 #include "ash/wm_window.h" | 30 #include "ash/wm_window.h" |
31 #include "base/command_line.h" | 31 #include "base/command_line.h" |
32 #include "base/run_loop.h" | 32 #include "base/run_loop.h" |
33 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
34 #include "ui/base/ui_base_switches.h" | 34 #include "ui/base/ui_base_switches.h" |
35 #include "ui/base/ui_base_types.h" | 35 #include "ui/base/ui_base_types.h" |
36 #include "ui/compositor/layer_type.h" | 36 #include "ui/compositor/layer_type.h" |
37 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 37 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
38 #include "ui/display/display.h" | 38 #include "ui/display/display.h" |
39 #include "ui/display/screen.h" | 39 #include "ui/display/screen.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // This will not be used for un-minimizing window. | 108 // This will not be used for un-minimizing window. |
109 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 109 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
110 window_state->Minimize(); | 110 window_state->Minimize(); |
111 window_state->Restore(); | 111 window_state->Restore(); |
112 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); | 112 EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString()); |
113 EXPECT_EQ("10,15 25x35", window->GetBounds().ToString()); | 113 EXPECT_EQ("10,15 25x35", window->GetBounds().ToString()); |
114 | 114 |
115 UpdateDisplay("400x300,500x400"); | 115 UpdateDisplay("400x300,500x400"); |
116 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); | 116 window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay()); |
117 EXPECT_EQ(WmShell::Get()->GetAllRootWindows()[1], window->GetRootWindow()); | 117 EXPECT_EQ(ShellPort::Get()->GetAllRootWindows()[1], window->GetRootWindow()); |
118 window_state->Minimize(); | 118 window_state->Minimize(); |
119 // This will not be used for un-minimizing window. | 119 // This will not be used for un-minimizing window. |
120 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); | 120 window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100)); |
121 window_state->Restore(); | 121 window_state->Restore(); |
122 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); | 122 EXPECT_EQ("600,0 100x100", window->GetBoundsInScreen().ToString()); |
123 | 123 |
124 // Make sure the unminimized window moves inside the display when | 124 // Make sure the unminimized window moves inside the display when |
125 // 2nd display is disconnected. | 125 // 2nd display is disconnected. |
126 window_state->Minimize(); | 126 window_state->Minimize(); |
127 UpdateDisplay("400x300"); | 127 UpdateDisplay("400x300"); |
128 window_state->Restore(); | 128 window_state->Restore(); |
129 EXPECT_EQ(WmShell::Get()->GetPrimaryRootWindow(), window->GetRootWindow()); | 129 EXPECT_EQ(ShellPort::Get()->GetPrimaryRootWindow(), window->GetRootWindow()); |
130 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 130 EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
131 window->GetBounds())); | 131 window->GetBounds())); |
132 } | 132 } |
133 | 133 |
134 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { | 134 TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) { |
135 UpdateDisplay("300x400,400x500"); | 135 UpdateDisplay("300x400,400x500"); |
136 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 136 WmWindow::Windows root_windows = ShellPort::Get()->GetAllRootWindows(); |
137 | 137 |
138 if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0)) | 138 if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0)) |
139 return; | 139 return; |
140 | 140 |
141 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); | 141 EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString()); |
142 | 142 |
143 std::unique_ptr<WindowOwner> window1_owner( | 143 std::unique_ptr<WindowOwner> window1_owner( |
144 CreateTestWindow(gfx::Rect(10, -400, 200, 200))); | 144 CreateTestWindow(gfx::Rect(10, -400, 200, 200))); |
145 EXPECT_EQ("10,-400 200x200", | 145 EXPECT_EQ("10,-400 200x200", |
146 window1_owner->window()->GetBoundsInScreen().ToString()); | 146 window1_owner->window()->GetBoundsInScreen().ToString()); |
(...skipping 19 matching lines...) Expand all Loading... |
166 TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) { | 166 TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) { |
167 std::unique_ptr<WindowOwner> window_owner( | 167 std::unique_ptr<WindowOwner> window_owner( |
168 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 168 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); |
169 WmWindow* window = window_owner->window(); | 169 WmWindow* window = window_owner->window(); |
170 wm::WindowState* window_state = window->GetWindowState(); | 170 wm::WindowState* window_state = window->GetWindowState(); |
171 | 171 |
172 // Maximized -> Normal transition. | 172 // Maximized -> Normal transition. |
173 window_state->Maximize(); | 173 window_state->Maximize(); |
174 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); | 174 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); |
175 window_state->Restore(); | 175 window_state->Restore(); |
176 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 176 EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
177 window->GetBounds())); | 177 window->GetBounds())); |
178 // Y bounds should not be negative. | 178 // Y bounds should not be negative. |
179 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); | 179 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); |
180 | 180 |
181 // Minimized -> Normal transition. | 181 // Minimized -> Normal transition. |
182 window->SetBounds(gfx::Rect(-100, -100, 30, 40)); | 182 window->SetBounds(gfx::Rect(-100, -100, 30, 40)); |
183 window_state->Minimize(); | 183 window_state->Minimize(); |
184 EXPECT_FALSE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 184 EXPECT_FALSE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
185 window->GetBounds())); | 185 window->GetBounds())); |
186 EXPECT_EQ("-100,-100 30x40", window->GetBounds().ToString()); | 186 EXPECT_EQ("-100,-100 30x40", window->GetBounds().ToString()); |
187 window->Show(); | 187 window->Show(); |
188 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 188 EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
189 window->GetBounds())); | 189 window->GetBounds())); |
190 // Y bounds should not be negative. | 190 // Y bounds should not be negative. |
191 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); | 191 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); |
192 | 192 |
193 // Fullscreen -> Normal transition. | 193 // Fullscreen -> Normal transition. |
194 window->SetBounds(gfx::Rect(0, 0, 30, 40)); // reset bounds. | 194 window->SetBounds(gfx::Rect(0, 0, 30, 40)); // reset bounds. |
195 ASSERT_EQ("0,0 30x40", window->GetBounds().ToString()); | 195 ASSERT_EQ("0,0 30x40", window->GetBounds().ToString()); |
196 window->SetShowState(ui::SHOW_STATE_FULLSCREEN); | 196 window->SetShowState(ui::SHOW_STATE_FULLSCREEN); |
197 EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds()); | 197 EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds()); |
198 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); | 198 window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40)); |
199 window_state->Restore(); | 199 window_state->Restore(); |
200 EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( | 200 EXPECT_TRUE(ShellPort::Get()->GetPrimaryRootWindow()->GetBounds().Intersects( |
201 window->GetBounds())); | 201 window->GetBounds())); |
202 // Y bounds should not be negative. | 202 // Y bounds should not be negative. |
203 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); | 203 EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString()); |
204 } | 204 } |
205 | 205 |
206 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { | 206 TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) { |
207 UpdateDisplay("300x400,400x500"); | 207 UpdateDisplay("300x400,400x500"); |
208 | 208 |
209 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 209 WmWindow::Windows root_windows = ShellPort::Get()->GetAllRootWindows(); |
210 | 210 |
211 std::unique_ptr<WindowOwner> window_owner( | 211 std::unique_ptr<WindowOwner> window_owner( |
212 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 212 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); |
213 WmWindow* window = window_owner->window(); | 213 WmWindow* window = window_owner->window(); |
214 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 214 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
215 | 215 |
216 wm::WindowState* window_state = window->GetWindowState(); | 216 wm::WindowState* window_state = window->GetWindowState(); |
217 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); | 217 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); |
218 // Maximize the window in 2nd display as the restore bounds | 218 // Maximize the window in 2nd display as the restore bounds |
219 // is inside 2nd display. | 219 // is inside 2nd display. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 w1->GetWindowBoundsInScreen().ToString()); | 258 w1->GetWindowBoundsInScreen().ToString()); |
259 w1->Restore(); | 259 w1->Restore(); |
260 EXPECT_EQ(root_windows[1], | 260 EXPECT_EQ(root_windows[1], |
261 WmWindow::Get(w1->GetNativeWindow())->GetRootWindow()); | 261 WmWindow::Get(w1->GetNativeWindow())->GetRootWindow()); |
262 EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString()); | 262 EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString()); |
263 } | 263 } |
264 | 264 |
265 TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) { | 265 TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) { |
266 UpdateDisplay("300x400,400x500"); | 266 UpdateDisplay("300x400,400x500"); |
267 | 267 |
268 WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows(); | 268 WmWindow::Windows root_windows = ShellPort::Get()->GetAllRootWindows(); |
269 | 269 |
270 std::unique_ptr<WindowOwner> window_owner( | 270 std::unique_ptr<WindowOwner> window_owner( |
271 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); | 271 CreateTestWindow(gfx::Rect(1, 2, 30, 40))); |
272 WmWindow* window = window_owner->window(); | 272 WmWindow* window = window_owner->window(); |
273 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 273 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
274 | 274 |
275 wm::WindowState* window_state = window->GetWindowState(); | 275 wm::WindowState* window_state = window->GetWindowState(); |
276 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); | 276 window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40)); |
277 // Maximize the window in 2nd display as the restore bounds | 277 // Maximize the window in 2nd display as the restore bounds |
278 // is inside 2nd display. | 278 // is inside 2nd display. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 377 } |
378 | 378 |
379 // Verifies a window created with maximized state has the maximized | 379 // Verifies a window created with maximized state has the maximized |
380 // bounds. | 380 // bounds. |
381 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { | 381 TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) { |
382 std::unique_ptr<aura::Window> window( | 382 std::unique_ptr<aura::Window> window( |
383 base::MakeUnique<aura::Window>(nullptr, ui::wm::WINDOW_TYPE_NORMAL)); | 383 base::MakeUnique<aura::Window>(nullptr, ui::wm::WINDOW_TYPE_NORMAL)); |
384 window->Init(ui::LAYER_TEXTURED); | 384 window->Init(ui::LAYER_TEXTURED); |
385 wm::GetWindowState(window.get())->Maximize(); | 385 wm::GetWindowState(window.get())->Maximize(); |
386 WmWindow* default_container = | 386 WmWindow* default_container = |
387 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( | 387 ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer( |
388 kShellWindowId_DefaultContainer); | 388 kShellWindowId_DefaultContainer); |
389 default_container->aura_window()->AddChild(window.get()); | 389 default_container->aura_window()->AddChild(window.get()); |
390 window->Show(); | 390 window->Show(); |
391 gfx::Rect work_area( | 391 gfx::Rect work_area( |
392 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 392 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
393 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 393 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
394 } | 394 } |
395 | 395 |
396 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { | 396 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { |
397 // TODO: fix. This test verifies that when a window is added the bounds are | 397 // TODO: fix. This test verifies that when a window is added the bounds are |
398 // adjusted. CreateTestWindow() for mus adds, then sets the bounds (this comes | 398 // adjusted. CreateTestWindow() for mus adds, then sets the bounds (this comes |
399 // from NativeWidgetAura), which means this test now fails for aura-mus. | 399 // from NativeWidgetAura), which means this test now fails for aura-mus. |
400 if (WmShell::Get()->IsRunningInMash()) | 400 if (ShellPort::Get()->IsRunningInMash()) |
401 return; | 401 return; |
402 | 402 |
403 // Normal window bounds shouldn't be changed. | 403 // Normal window bounds shouldn't be changed. |
404 gfx::Rect window_bounds(100, 100, 200, 200); | 404 gfx::Rect window_bounds(100, 100, 200, 200); |
405 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); | 405 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); |
406 WmWindow* window = window_owner->window(); | 406 WmWindow* window = window_owner->window(); |
407 EXPECT_EQ(window_bounds, window->GetBounds()); | 407 EXPECT_EQ(window_bounds, window->GetBounds()); |
408 | 408 |
409 // If the window is out of the workspace, it would be moved on screen. | 409 // If the window is out of the workspace, it would be moved on screen. |
410 gfx::Rect root_window_bounds = | 410 gfx::Rect root_window_bounds = |
411 WmShell::Get()->GetPrimaryRootWindow()->GetBounds(); | 411 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(); |
412 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); | 412 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); |
413 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); | 413 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); |
414 std::unique_ptr<WindowOwner> out_window_owner( | 414 std::unique_ptr<WindowOwner> out_window_owner( |
415 CreateTestWindow(window_bounds)); | 415 CreateTestWindow(window_bounds)); |
416 WmWindow* out_window = out_window_owner->window(); | 416 WmWindow* out_window = out_window_owner->window(); |
417 EXPECT_EQ(window_bounds.size(), out_window->GetBounds().size()); | 417 EXPECT_EQ(window_bounds.size(), out_window->GetBounds().size()); |
418 gfx::Rect bounds = out_window->GetBounds(); | 418 gfx::Rect bounds = out_window->GetBounds(); |
419 bounds.Intersect(root_window_bounds); | 419 bounds.Intersect(root_window_bounds); |
420 | 420 |
421 // 30% of the window edge must be visible. | 421 // 30% of the window edge must be visible. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 // Normal window bounds shouldn't be changed. | 475 // Normal window bounds shouldn't be changed. |
476 gfx::Size work_area( | 476 gfx::Size work_area( |
477 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); | 477 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); |
478 const gfx::Rect window_bounds(100, 101, work_area.width() + 1, | 478 const gfx::Rect window_bounds(100, 101, work_area.width() + 1, |
479 work_area.height() + 2); | 479 work_area.height() + 2); |
480 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); | 480 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); |
481 WmWindow* window = window_owner->window(); | 481 WmWindow* window = window_owner->window(); |
482 // TODO: fix. This test verifies that when a window is added the bounds are | 482 // TODO: fix. This test verifies that when a window is added the bounds are |
483 // adjusted. CreateTestWindow() for mus adds, then sets the bounds (this comes | 483 // adjusted. CreateTestWindow() for mus adds, then sets the bounds (this comes |
484 // from NativeWidgetAura), which means this test now fails for aura-mus. | 484 // from NativeWidgetAura), which means this test now fails for aura-mus. |
485 if (!WmShell::Get()->IsRunningInMash()) { | 485 if (!ShellPort::Get()->IsRunningInMash()) { |
486 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 486 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
487 window->GetBounds().ToString()); | 487 window->GetBounds().ToString()); |
488 } | 488 } |
489 | 489 |
490 // Directly setting the bounds triggers a slightly different code path. Verify | 490 // Directly setting the bounds triggers a slightly different code path. Verify |
491 // that too. | 491 // that too. |
492 window->SetBounds(window_bounds); | 492 window->SetBounds(window_bounds); |
493 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 493 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
494 window->GetBounds().ToString()); | 494 window->GetBounds().ToString()); |
495 } | 495 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 // area changed properly if window's layer is doing animation. We should use | 539 // area changed properly if window's layer is doing animation. We should use |
540 // GetTargetBounds to check if snapped bounds need to be changed. | 540 // GetTargetBounds to check if snapped bounds need to be changed. |
541 TEST_F(WorkspaceLayoutManagerTest, | 541 TEST_F(WorkspaceLayoutManagerTest, |
542 SnappedWindowMayNotAdjustBoundsOnWorkAreaChanged) { | 542 SnappedWindowMayNotAdjustBoundsOnWorkAreaChanged) { |
543 UpdateDisplay("300x400"); | 543 UpdateDisplay("300x400"); |
544 std::unique_ptr<WindowOwner> window_owner( | 544 std::unique_ptr<WindowOwner> window_owner( |
545 CreateTestWindow(gfx::Rect(10, 20, 100, 200))); | 545 CreateTestWindow(gfx::Rect(10, 20, 100, 200))); |
546 WmWindow* window = window_owner->window(); | 546 WmWindow* window = window_owner->window(); |
547 wm::WindowState* window_state = window->GetWindowState(); | 547 wm::WindowState* window_state = window->GetWindowState(); |
548 gfx::Insets insets(0, 0, 50, 0); | 548 gfx::Insets insets(0, 0, 50, 0); |
549 WmShell::Get()->SetDisplayWorkAreaInsets(window, insets); | 549 ShellPort::Get()->SetDisplayWorkAreaInsets(window, insets); |
550 const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT); | 550 const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT); |
551 window_state->OnWMEvent(&snap_left); | 551 window_state->OnWMEvent(&snap_left); |
552 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); | 552 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); |
553 const gfx::Rect kWorkAreaBounds = | 553 const gfx::Rect kWorkAreaBounds = |
554 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); | 554 display::Screen::GetScreen()->GetPrimaryDisplay().work_area(); |
555 gfx::Rect expected_bounds = | 555 gfx::Rect expected_bounds = |
556 gfx::Rect(kWorkAreaBounds.x(), kWorkAreaBounds.y(), | 556 gfx::Rect(kWorkAreaBounds.x(), kWorkAreaBounds.y(), |
557 kWorkAreaBounds.width() / 2, kWorkAreaBounds.height()); | 557 kWorkAreaBounds.width() / 2, kWorkAreaBounds.height()); |
558 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 558 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
559 | 559 |
560 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 560 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
561 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 561 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
562 // The following two SetDisplayWorkAreaInsets calls simulate the case of | 562 // The following two SetDisplayWorkAreaInsets calls simulate the case of |
563 // crbug.com/673803 that work area first becomes fullscreen and then returns | 563 // crbug.com/673803 that work area first becomes fullscreen and then returns |
564 // to the original state. | 564 // to the original state. |
565 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets(0, 0, 0, 0)); | 565 ShellPort::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets(0, 0, 0, 0)); |
566 ui::LayerAnimator* animator = window->GetLayer()->GetAnimator(); | 566 ui::LayerAnimator* animator = window->GetLayer()->GetAnimator(); |
567 EXPECT_TRUE(animator->is_animating()); | 567 EXPECT_TRUE(animator->is_animating()); |
568 WmShell::Get()->SetDisplayWorkAreaInsets(window, insets); | 568 ShellPort::Get()->SetDisplayWorkAreaInsets(window, insets); |
569 animator->StopAnimating(); | 569 animator->StopAnimating(); |
570 EXPECT_FALSE(animator->is_animating()); | 570 EXPECT_FALSE(animator->is_animating()); |
571 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 571 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
572 } | 572 } |
573 | 573 |
574 // Do not adjust window bounds to ensure minimum visibility for transient | 574 // Do not adjust window bounds to ensure minimum visibility for transient |
575 // windows (crbug.com/624806). | 575 // windows (crbug.com/624806). |
576 TEST_F(WorkspaceLayoutManagerTest, | 576 TEST_F(WorkspaceLayoutManagerTest, |
577 DoNotAdjustTransientWindowBoundsToEnsureMinimumVisibility) { | 577 DoNotAdjustTransientWindowBoundsToEnsureMinimumVisibility) { |
578 UpdateDisplay("300x400"); | 578 UpdateDisplay("300x400"); |
579 std::unique_ptr<aura::Window> window( | 579 std::unique_ptr<aura::Window> window( |
580 base::MakeUnique<aura::Window>(nullptr, ui::wm::WINDOW_TYPE_NORMAL)); | 580 base::MakeUnique<aura::Window>(nullptr, ui::wm::WINDOW_TYPE_NORMAL)); |
581 window->Init(ui::LAYER_TEXTURED); | 581 window->Init(ui::LAYER_TEXTURED); |
582 window->SetBounds(gfx::Rect(10, 0, 100, 200)); | 582 window->SetBounds(gfx::Rect(10, 0, 100, 200)); |
583 ParentWindowInPrimaryRootWindow(WmWindow::Get(window.get())); | 583 ParentWindowInPrimaryRootWindow(WmWindow::Get(window.get())); |
584 window->Show(); | 584 window->Show(); |
585 | 585 |
586 std::unique_ptr<WindowOwner> window2_owner( | 586 std::unique_ptr<WindowOwner> window2_owner( |
587 CreateTestWindow(gfx::Rect(10, 0, 40, 20))); | 587 CreateTestWindow(gfx::Rect(10, 0, 40, 20))); |
588 WmWindow* window2 = window2_owner->window(); | 588 WmWindow* window2 = window2_owner->window(); |
589 AddTransientChild(WmWindow::Get(window.get()), window2); | 589 AddTransientChild(WmWindow::Get(window.get()), window2); |
590 window2->Show(); | 590 window2->Show(); |
591 | 591 |
592 gfx::Rect expected_bounds = window2->GetBounds(); | 592 gfx::Rect expected_bounds = window2->GetBounds(); |
593 WmShell::Get()->SetDisplayWorkAreaInsets(WmWindow::Get(window.get()), | 593 ShellPort::Get()->SetDisplayWorkAreaInsets(WmWindow::Get(window.get()), |
594 gfx::Insets(50, 0, 0, 0)); | 594 gfx::Insets(50, 0, 0, 0)); |
595 EXPECT_EQ(expected_bounds.ToString(), window2->GetBounds().ToString()); | 595 EXPECT_EQ(expected_bounds.ToString(), window2->GetBounds().ToString()); |
596 } | 596 } |
597 | 597 |
598 // Following "Solo" tests were originally written for BaseLayoutManager. | 598 // Following "Solo" tests were originally written for BaseLayoutManager. |
599 using WorkspaceLayoutManagerSoloTest = test::AshTestBase; | 599 using WorkspaceLayoutManagerSoloTest = test::AshTestBase; |
600 | 600 |
601 // Tests normal->maximize->normal. | 601 // Tests normal->maximize->normal. |
602 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { | 602 TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) { |
603 gfx::Rect bounds(100, 100, 200, 200); | 603 gfx::Rect bounds(100, 100, 200, 200); |
604 std::unique_ptr<aura::Window> window_owner( | 604 std::unique_ptr<aura::Window> window_owner( |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 | 944 |
945 class WorkspaceLayoutManagerBackdropTest : public AshTest { | 945 class WorkspaceLayoutManagerBackdropTest : public AshTest { |
946 public: | 946 public: |
947 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {} | 947 WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {} |
948 ~WorkspaceLayoutManagerBackdropTest() override {} | 948 ~WorkspaceLayoutManagerBackdropTest() override {} |
949 | 949 |
950 void SetUp() override { | 950 void SetUp() override { |
951 AshTest::SetUp(); | 951 AshTest::SetUp(); |
952 UpdateDisplay("800x600"); | 952 UpdateDisplay("800x600"); |
953 default_container_ = | 953 default_container_ = |
954 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( | 954 ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer( |
955 kShellWindowId_DefaultContainer); | 955 kShellWindowId_DefaultContainer); |
956 } | 956 } |
957 | 957 |
958 // Turn the top window back drop on / off. | 958 // Turn the top window back drop on / off. |
959 void ShowTopWindowBackdrop(bool show) { | 959 void ShowTopWindowBackdrop(bool show) { |
960 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop; | 960 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop; |
961 if (show) | 961 if (show) |
962 backdrop.reset(new WorkspaceBackdropDelegate(default_container_)); | 962 backdrop.reset(new WorkspaceBackdropDelegate(default_container_)); |
963 GetWorkspaceLayoutManager(default_container_) | 963 GetWorkspaceLayoutManager(default_container_) |
964 ->SetMaximizeBackdropDelegate(std::move(backdrop)); | 964 ->SetMaximizeBackdropDelegate(std::move(backdrop)); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 | 1127 |
1128 class WorkspaceLayoutManagerKeyboardTest : public AshTest { | 1128 class WorkspaceLayoutManagerKeyboardTest : public AshTest { |
1129 public: | 1129 public: |
1130 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} | 1130 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} |
1131 ~WorkspaceLayoutManagerKeyboardTest() override {} | 1131 ~WorkspaceLayoutManagerKeyboardTest() override {} |
1132 | 1132 |
1133 void SetUp() override { | 1133 void SetUp() override { |
1134 AshTest::SetUp(); | 1134 AshTest::SetUp(); |
1135 UpdateDisplay("800x600"); | 1135 UpdateDisplay("800x600"); |
1136 WmWindow* default_container = | 1136 WmWindow* default_container = |
1137 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( | 1137 ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer( |
1138 kShellWindowId_DefaultContainer); | 1138 kShellWindowId_DefaultContainer); |
1139 layout_manager_ = GetWorkspaceLayoutManager(default_container); | 1139 layout_manager_ = GetWorkspaceLayoutManager(default_container); |
1140 } | 1140 } |
1141 | 1141 |
1142 void ShowKeyboard() { | 1142 void ShowKeyboard() { |
1143 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); | 1143 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); |
1144 restore_work_area_insets_ = | 1144 restore_work_area_insets_ = |
1145 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); | 1145 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); |
1146 WmShell::Get()->SetDisplayWorkAreaInsets( | 1146 ShellPort::Get()->SetDisplayWorkAreaInsets( |
1147 WmShell::Get()->GetPrimaryRootWindow(), | 1147 ShellPort::Get()->GetPrimaryRootWindow(), |
1148 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); | 1148 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); |
1149 } | 1149 } |
1150 | 1150 |
1151 void HideKeyboard() { | 1151 void HideKeyboard() { |
1152 WmShell::Get()->SetDisplayWorkAreaInsets( | 1152 ShellPort::Get()->SetDisplayWorkAreaInsets( |
1153 WmShell::Get()->GetPrimaryRootWindow(), restore_work_area_insets_); | 1153 ShellPort::Get()->GetPrimaryRootWindow(), restore_work_area_insets_); |
1154 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); | 1154 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); |
1155 } | 1155 } |
1156 | 1156 |
1157 // Initializes the keyboard bounds using the bottom half of the work area. | 1157 // Initializes the keyboard bounds using the bottom half of the work area. |
1158 void InitKeyboardBounds() { | 1158 void InitKeyboardBounds() { |
1159 gfx::Rect work_area( | 1159 gfx::Rect work_area( |
1160 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1160 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
1161 keyboard_bounds_.SetRect(work_area.x(), | 1161 keyboard_bounds_.SetRect(work_area.x(), |
1162 work_area.y() + work_area.height() / 2, | 1162 work_area.y() + work_area.height() / 2, |
1163 work_area.width(), work_area.height() / 2); | 1163 work_area.width(), work_area.height() / 2); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 window->SetBounds(keyboard_bounds()); | 1275 window->SetBounds(keyboard_bounds()); |
1276 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); | 1276 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); |
1277 window->Activate(); | 1277 window->Activate(); |
1278 | 1278 |
1279 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1279 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
1280 ShowKeyboard(); | 1280 ShowKeyboard(); |
1281 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1281 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
1282 } | 1282 } |
1283 | 1283 |
1284 } // namespace ash | 1284 } // namespace ash |
OLD | NEW |