| 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/config.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 12 #include "ash/session/session_controller.h" | 13 #include "ash/session/session_controller.h" |
| 13 #include "ash/shelf/shelf_constants.h" | 14 #include "ash/shelf/shelf_constants.h" |
| 14 #include "ash/shelf/shelf_layout_manager.h" | 15 #include "ash/shelf/shelf_layout_manager.h" |
| 15 #include "ash/shelf/wm_shelf.h" | 16 #include "ash/shelf/wm_shelf.h" |
| 16 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 17 #include "ash/shell_observer.h" | 18 #include "ash/shell_observer.h" |
| 18 #include "ash/shell_port.h" | 19 #include "ash/shell_port.h" |
| 19 #include "ash/test/ash_test.h" | 20 #include "ash/test/ash_test.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 window->Show(); | 391 window->Show(); |
| 391 gfx::Rect work_area( | 392 gfx::Rect work_area( |
| 392 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 393 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 393 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); | 394 EXPECT_EQ(work_area.ToString(), window->GetBoundsInScreen().ToString()); |
| 394 } | 395 } |
| 395 | 396 |
| 396 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { | 397 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) { |
| 397 // TODO: fix. This test verifies that when a window is added the bounds are | 398 // 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 | 399 // adjusted. CreateTestWindow() for mus adds, then sets the bounds (this comes |
| 399 // from NativeWidgetAura), which means this test now fails for aura-mus. | 400 // from NativeWidgetAura), which means this test now fails for aura-mus. |
| 400 if (ShellPort::Get()->IsRunningInMash()) | 401 if (Shell::GetAshConfig() == Config::MASH) |
| 401 return; | 402 return; |
| 402 | 403 |
| 403 // Normal window bounds shouldn't be changed. | 404 // Normal window bounds shouldn't be changed. |
| 404 gfx::Rect window_bounds(100, 100, 200, 200); | 405 gfx::Rect window_bounds(100, 100, 200, 200); |
| 405 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); | 406 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); |
| 406 WmWindow* window = window_owner->window(); | 407 WmWindow* window = window_owner->window(); |
| 407 EXPECT_EQ(window_bounds, window->GetBounds()); | 408 EXPECT_EQ(window_bounds, window->GetBounds()); |
| 408 | 409 |
| 409 // If the window is out of the workspace, it would be moved on screen. | 410 // If the window is out of the workspace, it would be moved on screen. |
| 410 gfx::Rect root_window_bounds = | 411 gfx::Rect root_window_bounds = |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // Normal window bounds shouldn't be changed. | 476 // Normal window bounds shouldn't be changed. |
| 476 gfx::Size work_area( | 477 gfx::Size work_area( |
| 477 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); | 478 display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size()); |
| 478 const gfx::Rect window_bounds(100, 101, work_area.width() + 1, | 479 const gfx::Rect window_bounds(100, 101, work_area.width() + 1, |
| 479 work_area.height() + 2); | 480 work_area.height() + 2); |
| 480 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); | 481 std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds)); |
| 481 WmWindow* window = window_owner->window(); | 482 WmWindow* window = window_owner->window(); |
| 482 // TODO: fix. This test verifies that when a window is added the bounds are | 483 // 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 | 484 // adjusted. CreateTestWindow() for mus adds, then sets the bounds (this comes |
| 484 // from NativeWidgetAura), which means this test now fails for aura-mus. | 485 // from NativeWidgetAura), which means this test now fails for aura-mus. |
| 485 if (!ShellPort::Get()->IsRunningInMash()) { | 486 if (Shell::GetAshConfig() != Config::MASH) { |
| 486 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 487 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
| 487 window->GetBounds().ToString()); | 488 window->GetBounds().ToString()); |
| 488 } | 489 } |
| 489 | 490 |
| 490 // Directly setting the bounds triggers a slightly different code path. Verify | 491 // Directly setting the bounds triggers a slightly different code path. Verify |
| 491 // that too. | 492 // that too. |
| 492 window->SetBounds(window_bounds); | 493 window->SetBounds(window_bounds); |
| 493 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), | 494 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), |
| 494 window->GetBounds().ToString()); | 495 window->GetBounds().ToString()); |
| 495 } | 496 } |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 window->SetBounds(keyboard_bounds()); | 1276 window->SetBounds(keyboard_bounds()); |
| 1276 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); | 1277 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); |
| 1277 window->Activate(); | 1278 window->Activate(); |
| 1278 | 1279 |
| 1279 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1280 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1280 ShowKeyboard(); | 1281 ShowKeyboard(); |
| 1281 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); | 1282 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); |
| 1282 } | 1283 } |
| 1283 | 1284 |
| 1284 } // namespace ash | 1285 } // namespace ash |
| OLD | NEW |