Chromium Code Reviews| 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/common/dock/docked_window_resizer.h" | 5 #include "ash/wm/common/dock/docked_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 std::unique_ptr<aura::Window> window( | 373 std::unique_ptr<aura::Window> window( |
| 374 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 374 CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
| 375 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 375 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
| 376 | 376 |
| 377 // The window should be docked at the right edge. | 377 // The window should be docked at the right edge. |
| 378 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 378 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
| 379 window->GetBoundsInScreen().right()); | 379 window->GetBoundsInScreen().right()); |
| 380 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 380 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 381 | 381 |
| 382 // set launcher shelf to be aligned on the right | 382 // set launcher shelf to be aligned on the right |
| 383 ash::Shell* shell = ash::Shell::GetInstance(); | 383 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_RIGHT); |
| 384 shell->SetShelfAlignment(wm::SHELF_ALIGNMENT_RIGHT, | |
| 385 shell->GetPrimaryRootWindow()); | |
| 386 // The window should have moved and get attached to the left dock. | 384 // The window should have moved and get attached to the left dock. |
| 387 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), | 385 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().x(), |
| 388 window->GetBoundsInScreen().x()); | 386 window->GetBoundsInScreen().x()); |
| 389 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 387 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 390 | 388 |
| 391 // set launcher shelf to be aligned on the left | 389 // set launcher shelf to be aligned on the left |
| 392 shell->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, | 390 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); |
| 393 shell->GetPrimaryRootWindow()); | |
| 394 // The window should have moved and get attached to the right edge. | 391 // The window should have moved and get attached to the right edge. |
| 395 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 392 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
| 396 window->GetBoundsInScreen().right()); | 393 window->GetBoundsInScreen().right()); |
| 397 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 394 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 398 | 395 |
| 399 // set launcher shelf to be aligned at the bottom | 396 // set launcher shelf to be aligned at the bottom |
| 400 shell->SetShelfAlignment(wm::SHELF_ALIGNMENT_BOTTOM, | 397 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM); |
| 401 shell->GetPrimaryRootWindow()); | |
| 402 // The window should stay in the right edge. | 398 // The window should stay in the right edge. |
| 403 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 399 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
| 404 window->GetBoundsInScreen().right()); | 400 window->GetBoundsInScreen().right()); |
| 405 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 401 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 406 } | 402 } |
| 407 | 403 |
| 408 // Dock on the right side, try to undock, then drag more to really undock | 404 // Dock on the right side, try to undock, then drag more to really undock |
| 409 TEST_P(DockedWindowResizerTest, AttachTryDetach) { | 405 TEST_P(DockedWindowResizerTest, AttachTryDetach) { |
| 410 if (!SupportsHostWindowResize()) | 406 if (!SupportsHostWindowResize()) |
| 411 return; | 407 return; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 ->GetDisplayNearestWindow(w1.get()) | 606 ->GetDisplayNearestWindow(w1.get()) |
| 611 .work_area(); | 607 .work_area(); |
| 612 DockedWindowLayoutManager* manager = | 608 DockedWindowLayoutManager* manager = |
| 613 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); | 609 DockedWindowLayoutManager::Get(wm::WmWindowAura::Get(w1.get())); |
| 614 | 610 |
| 615 // Docked window should be centered vertically in the work area. | 611 // Docked window should be centered vertically in the work area. |
| 616 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); | 612 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); |
| 617 // Docked background should extend to the bottom of work area. | 613 // Docked background should extend to the bottom of work area. |
| 618 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 614 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
| 619 | 615 |
| 620 // set launcher shelf to be aligned on the right | 616 // set launcher shelf to be aligned on the right |
|
msw
2016/05/27 22:36:41
nit: remove/update incorrect comment?
James Cook
2016/05/27 22:56:26
Updated.
| |
| 621 ash::Shell* shell = ash::Shell::GetInstance(); | 617 Shelf::ForPrimaryDisplay()->SetAutoHideBehavior( |
| 622 shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 618 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 623 shell->GetPrimaryRootWindow()); | |
| 624 work_area = display::Screen::GetScreen() | 619 work_area = display::Screen::GetScreen() |
| 625 ->GetDisplayNearestWindow(w1.get()) | 620 ->GetDisplayNearestWindow(w1.get()) |
| 626 .work_area(); | 621 .work_area(); |
| 627 // Docked window should be centered vertically in the work area. | 622 // Docked window should be centered vertically in the work area. |
| 628 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); | 623 EXPECT_EQ(work_area.CenterPoint().y(), w1->bounds().CenterPoint().y()); |
| 629 // Docked background should extend to the bottom of work area. | 624 // Docked background should extend to the bottom of work area. |
| 630 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); | 625 EXPECT_EQ(work_area.bottom(), manager->docked_bounds().bottom()); |
| 631 } | 626 } |
| 632 | 627 |
| 633 // Dock one window, try to dock another window on the opposite side (should not | 628 // Dock one window, try to dock another window on the opposite side (should not |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1618 EXPECT_TRUE(window_state->IsMaximized()); | 1613 EXPECT_TRUE(window_state->IsMaximized()); |
| 1619 } | 1614 } |
| 1620 | 1615 |
| 1621 // Tests run twice - on both panels and normal windows | 1616 // Tests run twice - on both panels and normal windows |
| 1622 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 1617 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
| 1623 DockedWindowResizerTest, | 1618 DockedWindowResizerTest, |
| 1624 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 1619 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
| 1625 ui::wm::WINDOW_TYPE_PANEL)); | 1620 ui::wm::WINDOW_TYPE_PANEL)); |
| 1626 | 1621 |
| 1627 } // namespace ash | 1622 } // namespace ash |
| OLD | NEW |