Chromium Code Reviews| 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/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | |
| 8 #include "ash/common/accelerators/accelerator_table.h" | 7 #include "ash/common/accelerators/accelerator_table.h" |
| 9 #include "ash/common/accessibility_delegate.h" | 8 #include "ash/common/accessibility_delegate.h" |
| 10 #include "ash/common/accessibility_types.h" | 9 #include "ash/common/accessibility_types.h" |
| 11 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| 12 #include "ash/common/ime_control_delegate.h" | 11 #include "ash/common/ime_control_delegate.h" |
| 13 #include "ash/common/session/session_state_delegate.h" | 12 #include "ash/common/session/session_state_delegate.h" |
| 14 #include "ash/common/system/brightness_control_delegate.h" | 13 #include "ash/common/system/brightness_control_delegate.h" |
| 15 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 14 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 16 #include "ash/common/system/tray/system_tray_delegate.h" | 15 #include "ash/common/system/tray/system_tray_delegate.h" |
| 17 #include "ash/common/test/ash_test.h" | 16 #include "ash/common/test/ash_test.h" |
| 18 #include "ash/common/wm/panels/panel_layout_manager.h" | 17 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 19 #include "ash/common/wm/window_positioning_utils.h" | 18 #include "ash/common/wm/window_positioning_utils.h" |
| 20 #include "ash/common/wm/window_state.h" | 19 #include "ash/common/wm/window_state.h" |
| 21 #include "ash/common/wm/wm_event.h" | 20 #include "ash/common/wm/wm_event.h" |
| 22 #include "ash/common/wm_lookup.h" | 21 #include "ash/common/wm_lookup.h" |
| 23 #include "ash/common/wm_shell.h" | 22 #include "ash/common/wm_shell.h" |
| 23 #include "ash/common/wm_window.h" | |
| 24 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h" | 24 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h" |
| 25 #include "ash/mus/bridge/wm_shell_mus_test_api.h" | 25 #include "ash/mus/bridge/wm_shell_mus_test_api.h" |
| 26 #include "ash/mus/property_util.h" | 26 #include "ash/mus/property_util.h" |
| 27 #include "ash/mus/test/wm_test_base.h" | 27 #include "ash/mus/test/wm_test_base.h" |
| 28 #include "ash/public/cpp/shell_window_ids.h" | 28 #include "ash/public/cpp/shell_window_ids.h" |
| 29 #include "ash/root_window_controller.h" | 29 #include "ash/root_window_controller.h" |
| 30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 31 #include "base/test/user_action_tester.cc" | 31 #include "base/test/user_action_tester.cc" |
| 32 #include "services/ui/public/interfaces/window_manager.mojom.h" | 32 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 33 #include "ui/aura/client/aura_constants.h" | 33 #include "ui/aura/client/aura_constants.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 // TODO: needs support for TestShelfDelegate: http://crbug.com/632208. | 254 // TODO: needs support for TestShelfDelegate: http://crbug.com/632208. |
| 255 /* | 255 /* |
| 256 ui::Window* CreatePanel() { | 256 ui::Window* CreatePanel() { |
| 257 ui::Window* window = CreateTestWindow( | 257 ui::Window* window = CreateTestWindow( |
| 258 gfx::Rect(5, 5, 20, 20), | 258 gfx::Rect(5, 5, 20, 20), |
| 259 ui::wm::WINDOW_TYPE_PANEL); | 259 ui::wm::WINDOW_TYPE_PANEL); |
| 260 test::TestShelfDelegate* shelf_delegate = | 260 test::TestShelfDelegate* shelf_delegate = |
| 261 test::TestShelfDelegate::instance(); | 261 test::TestShelfDelegate::instance(); |
| 262 shelf_delegate->AddShelfItem(window); | 262 shelf_delegate->AddShelfItem(window); |
| 263 PanelLayoutManager* manager = | 263 PanelLayoutManager* manager = |
| 264 PanelLayoutManager::Get(WmWindowAura::Get(window)); | 264 PanelLayoutManager::Get(WmWindow::Get(window)); |
| 265 manager->Relayout(); | 265 manager->Relayout(); |
| 266 return window; | 266 return window; |
| 267 } | 267 } |
| 268 */ | 268 */ |
| 269 | 269 |
| 270 void SetBrightnessControlDelegate( | 270 void SetBrightnessControlDelegate( |
| 271 std::unique_ptr<BrightnessControlDelegate> delegate) { | 271 std::unique_ptr<BrightnessControlDelegate> delegate) { |
| 272 WmShell::Get()->brightness_control_delegate_ = std::move(delegate); | 272 WmShell::Get()->brightness_control_delegate_ = std::move(delegate); |
| 273 } | 273 } |
| 274 | 274 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 TestTarget target; | 428 TestTarget target; |
| 429 GetController()->Register(accelerator_a, &target); | 429 GetController()->Register(accelerator_a, &target); |
| 430 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); | 430 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); |
| 431 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); | 431 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); |
| 432 GetController()->UnregisterAll(&target); | 432 GetController()->UnregisterAll(&target); |
| 433 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); | 433 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); |
| 434 } | 434 } |
| 435 | 435 |
| 436 TEST_F(AcceleratorControllerTest, WindowSnap) { | 436 TEST_F(AcceleratorControllerTest, WindowSnap) { |
| 437 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 437 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| 438 WmWindow* window = WmWindowAura::Get(aura_window); | 438 WmWindow* window = WmWindow::Get(aura_window); |
| 439 wm::WindowState* window_state = window->GetWindowState(); | 439 wm::WindowState* window_state = window->GetWindowState(); |
| 440 | 440 |
| 441 window_state->Activate(); | 441 window_state->Activate(); |
| 442 | 442 |
| 443 { | 443 { |
| 444 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 444 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 445 gfx::Rect expected_bounds = | 445 gfx::Rect expected_bounds = |
| 446 wm::GetDefaultLeftSnappedWindowBoundsInParent(window); | 446 wm::GetDefaultLeftSnappedWindowBoundsInParent(window); |
| 447 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 447 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 448 } | 448 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 } | 483 } |
| 484 { | 484 { |
| 485 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 485 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
| 486 EXPECT_TRUE(window_state->IsMinimized()); | 486 EXPECT_TRUE(window_state->IsMinimized()); |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 // Tests that when window docking is disabled, only snapping windows works. | 490 // Tests that when window docking is disabled, only snapping windows works. |
| 491 TEST_F(AcceleratorControllerTest, WindowSnapWithoutDocking) { | 491 TEST_F(AcceleratorControllerTest, WindowSnapWithoutDocking) { |
| 492 ASSERT_FALSE(ash::switches::DockedWindowsEnabled()); | 492 ASSERT_FALSE(ash::switches::DockedWindowsEnabled()); |
| 493 WmWindow* window = | 493 WmWindow* window = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| 494 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 495 wm::WindowState* window_state = window->GetWindowState(); | 494 wm::WindowState* window_state = window->GetWindowState(); |
| 496 window_state->Activate(); | 495 window_state->Activate(); |
| 497 | 496 |
| 498 // Snap right. | 497 // Snap right. |
| 499 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 498 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| 500 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); | 499 gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); |
| 501 gfx::Rect expected_bounds = | 500 gfx::Rect expected_bounds = |
| 502 wm::GetDefaultRightSnappedWindowBoundsInParent(window); | 501 wm::GetDefaultRightSnappedWindowBoundsInParent(window); |
| 503 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); | 502 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| 504 EXPECT_TRUE(window_state->IsSnapped()); | 503 EXPECT_TRUE(window_state->IsSnapped()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 AcceleratorControllerTest::SetUp(); | 536 AcceleratorControllerTest::SetUp(); |
| 538 } | 537 } |
| 539 | 538 |
| 540 private: | 539 private: |
| 541 DISALLOW_COPY_AND_ASSIGN(EnabledDockedWindowsAcceleratorControllerTest); | 540 DISALLOW_COPY_AND_ASSIGN(EnabledDockedWindowsAcceleratorControllerTest); |
| 542 }; | 541 }; |
| 543 | 542 |
| 544 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 543 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| 545 WindowSnapLeftDockLeftRestore) { | 544 WindowSnapLeftDockLeftRestore) { |
| 546 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 545 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| 547 WmWindow* window1 = | 546 WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| 548 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 549 wm::WindowState* window1_state = window1->GetWindowState(); | 547 wm::WindowState* window1_state = window1->GetWindowState(); |
| 550 window1_state->Activate(); | 548 window1_state->Activate(); |
| 551 | 549 |
| 552 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 550 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 553 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | 551 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
| 554 gfx::Rect expected_bounds = | 552 gfx::Rect expected_bounds = |
| 555 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); | 553 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); |
| 556 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | 554 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); |
| 557 EXPECT_TRUE(window1_state->IsSnapped()); | 555 EXPECT_TRUE(window1_state->IsSnapped()); |
| 558 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 556 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 559 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 557 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
| 560 EXPECT_TRUE(window1_state->IsDocked()); | 558 EXPECT_TRUE(window1_state->IsDocked()); |
| 561 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 559 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 562 EXPECT_FALSE(window1_state->IsDocked()); | 560 EXPECT_FALSE(window1_state->IsDocked()); |
| 563 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); | 561 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); |
| 564 } | 562 } |
| 565 | 563 |
| 566 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 564 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| 567 WindowSnapRightDockRightRestore) { | 565 WindowSnapRightDockRightRestore) { |
| 568 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 566 CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| 569 WmWindow* window1 = | 567 WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| 570 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 571 | 568 |
| 572 wm::WindowState* window1_state = window1->GetWindowState(); | 569 wm::WindowState* window1_state = window1->GetWindowState(); |
| 573 window1_state->Activate(); | 570 window1_state->Activate(); |
| 574 | 571 |
| 575 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 572 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| 576 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); | 573 gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
| 577 gfx::Rect expected_bounds = | 574 gfx::Rect expected_bounds = |
| 578 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); | 575 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); |
| 579 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | 576 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); |
| 580 EXPECT_TRUE(window1_state->IsSnapped()); | 577 EXPECT_TRUE(window1_state->IsSnapped()); |
| 581 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 578 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| 582 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 579 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
| 583 EXPECT_TRUE(window1_state->IsDocked()); | 580 EXPECT_TRUE(window1_state->IsDocked()); |
| 584 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 581 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| 585 EXPECT_FALSE(window1_state->IsDocked()); | 582 EXPECT_FALSE(window1_state->IsDocked()); |
| 586 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); | 583 EXPECT_EQ(normal_bounds.ToString(), window1->GetBounds().ToString()); |
| 587 } | 584 } |
| 588 | 585 |
| 589 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 586 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| 590 WindowSnapLeftDockLeftSnapRight) { | 587 WindowSnapLeftDockLeftSnapRight) { |
| 591 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 588 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
|
James Cook
2017/01/12 20:45:57
Is the WmWindow::Get() required here?
sky
2017/01/12 20:58:27
Nope. Removed.
| |
| 592 WmWindow* window1 = | 589 WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| 593 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 594 | 590 |
| 595 wm::WindowState* window1_state = window1->GetWindowState(); | 591 wm::WindowState* window1_state = window1->GetWindowState(); |
| 596 window1_state->Activate(); | 592 window1_state->Activate(); |
| 597 | 593 |
| 598 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 594 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 599 gfx::Rect expected_bounds = | 595 gfx::Rect expected_bounds = |
| 600 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); | 596 wm::GetDefaultLeftSnappedWindowBoundsInParent(window1); |
| 601 gfx::Rect expected_bounds2 = | 597 gfx::Rect expected_bounds2 = |
| 602 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); | 598 wm::GetDefaultRightSnappedWindowBoundsInParent(window1); |
| 603 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); | 599 EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().ToString()); |
| 604 EXPECT_TRUE(window1_state->IsSnapped()); | 600 EXPECT_TRUE(window1_state->IsSnapped()); |
| 605 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 601 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 606 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); | 602 EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
| 607 EXPECT_TRUE(window1_state->IsDocked()); | 603 EXPECT_TRUE(window1_state->IsDocked()); |
| 608 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 604 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| 609 EXPECT_FALSE(window1_state->IsDocked()); | 605 EXPECT_FALSE(window1_state->IsDocked()); |
| 610 EXPECT_TRUE(window1_state->IsSnapped()); | 606 EXPECT_TRUE(window1_state->IsSnapped()); |
| 611 EXPECT_EQ(expected_bounds2.ToString(), window1->GetBounds().ToString()); | 607 EXPECT_EQ(expected_bounds2.ToString(), window1->GetBounds().ToString()); |
| 612 } | 608 } |
| 613 | 609 |
| 614 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 610 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| 615 WindowDockLeftMinimizeWindowWithRestore) { | 611 WindowDockLeftMinimizeWindowWithRestore) { |
| 616 WindowOwner window_owner( | 612 WindowOwner window_owner( |
| 617 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 613 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
| 618 WindowOwner window1_owner( | 614 WindowOwner window1_owner( |
| 619 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 615 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
| 620 WmWindow* window1 = window1_owner.window(); | 616 WmWindow* window1 = window1_owner.window(); |
| 621 | 617 |
| 622 wm::WindowState* window1_state = window1->GetWindowState(); | 618 wm::WindowState* window1_state = window1->GetWindowState(); |
| 623 window1_state->Activate(); | 619 window1_state->Activate(); |
| 624 | 620 |
| 625 WindowOwner window2_owner( | 621 WindowOwner window2_owner( |
| 626 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 622 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
| 627 WmWindow* window2 = window2_owner.window(); | 623 WmWindow* window2 = window2_owner.window(); |
| 628 | 624 |
| 629 wm::WindowState* window2_state = window2->GetWindowState(); | 625 wm::WindowState* window2_state = window2->GetWindowState(); |
| 630 | 626 |
| 631 WindowOwner window3_owner( | 627 WindowOwner window3_owner( |
| 632 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 628 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
| 633 WmWindow* window3 = window3_owner.window(); | 629 WmWindow* window3 = window3_owner.window(); |
| 634 | 630 |
| 635 wm::WindowState* window3_state = window3->GetWindowState(); | 631 wm::WindowState* window3_state = window3->GetWindowState(); |
| 636 window3_state->Activate(); | 632 window3_state->Activate(); |
| 637 | 633 |
| 638 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 634 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 639 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 635 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 640 gfx::Rect window3_docked_bounds = window3->GetBounds(); | 636 gfx::Rect window3_docked_bounds = window3->GetBounds(); |
| 641 | 637 |
| 642 window2_state->Activate(); | 638 window2_state->Activate(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 660 EXPECT_FALSE(window2_state->IsDocked()); | 656 EXPECT_FALSE(window2_state->IsDocked()); |
| 661 EXPECT_TRUE(window3_state->IsDocked()); | 657 EXPECT_TRUE(window3_state->IsDocked()); |
| 662 EXPECT_EQ(window3_docked_bounds.ToString(), window3->GetBounds().ToString()); | 658 EXPECT_EQ(window3_docked_bounds.ToString(), window3->GetBounds().ToString()); |
| 663 } | 659 } |
| 664 | 660 |
| 665 // TODO: Needs CreatePanel(): http://crbug.com/632209. | 661 // TODO: Needs CreatePanel(): http://crbug.com/632209. |
| 666 /* | 662 /* |
| 667 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, | 663 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| 668 WindowPanelDockLeftDockRightRestore) { | 664 WindowPanelDockLeftDockRightRestore) { |
| 669 WmWndow* window0 = | 665 WmWndow* window0 = |
| 670 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 666 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| 671 | 667 |
| 672 std::unique_ptr<aura::Window> window(CreatePanel()); | 668 std::unique_ptr<aura::Window> window(CreatePanel()); |
| 673 wm::WindowState* window_state = wm::GetWindowState(window.get()); | 669 wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| 674 window_state->Activate(); | 670 window_state->Activate(); |
| 675 | 671 |
| 676 gfx::Rect window_restore_bounds2 = window->bounds(); | 672 gfx::Rect window_restore_bounds2 = window->bounds(); |
| 677 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); | 673 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| 678 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( | 674 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
| 679 WmWindowAura::Get(window.get())); | 675 WmWindow::Get(window.get())); |
| 680 gfx::Rect window_restore_bounds = window_state->GetRestoreBoundsInScreen(); | 676 gfx::Rect window_restore_bounds = window_state->GetRestoreBoundsInScreen(); |
| 681 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); | 677 EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); |
| 682 EXPECT_FALSE(window_state->IsSnapped()); | 678 EXPECT_FALSE(window_state->IsSnapped()); |
| 683 EXPECT_FALSE(window_state->IsNormalOrSnapped()); | 679 EXPECT_FALSE(window_state->IsNormalOrSnapped()); |
| 684 EXPECT_TRUE(window_state->IsDocked()); | 680 EXPECT_TRUE(window_state->IsDocked()); |
| 685 window_state->Restore(); | 681 window_state->Restore(); |
| 686 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 682 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| 687 EXPECT_TRUE(window_state->IsDocked()); | 683 EXPECT_TRUE(window_state->IsDocked()); |
| 688 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); | 684 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| 689 EXPECT_FALSE(window_state->IsDocked()); | 685 EXPECT_FALSE(window_state->IsDocked()); |
| 690 EXPECT_EQ(window_restore_bounds.ToString(), | 686 EXPECT_EQ(window_restore_bounds.ToString(), |
| 691 window_restore_bounds2.ToString()); | 687 window_restore_bounds2.ToString()); |
| 692 EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); | 688 EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); |
| 693 } | 689 } |
| 694 */ | 690 */ |
| 695 | 691 |
| 696 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, CenterWindowAccelerator) { | 692 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, CenterWindowAccelerator) { |
| 697 WindowOwner window_owner( | 693 WindowOwner window_owner( |
| 698 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); | 694 WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)))); |
| 699 WmWindow* window = window_owner.window(); | 695 WmWindow* window = window_owner.window(); |
| 700 wm::WindowState* window_state = window->GetWindowState(); | 696 wm::WindowState* window_state = window->GetWindowState(); |
| 701 window_state->Activate(); | 697 window_state->Activate(); |
| 702 | 698 |
| 703 // Center the window using accelerator. | 699 // Center the window using accelerator. |
| 704 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); | 700 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); |
| 705 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area(); | 701 gfx::Rect work_area = window->GetDisplayNearestWindow().work_area(); |
| 706 gfx::Rect bounds = window->GetBoundsInScreen(); | 702 gfx::Rect bounds = window->GetBoundsInScreen(); |
| 707 EXPECT_NEAR(bounds.x() - work_area.x(), work_area.right() - bounds.right(), | 703 EXPECT_NEAR(bounds.x() - work_area.x(), work_area.right() - bounds.right(), |
| 708 1); | 704 1); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) { | 791 TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) { |
| 796 const AcceleratorData accelerators[] = { | 792 const AcceleratorData accelerators[] = { |
| 797 {true, ui::VKEY_J, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, | 793 {true, ui::VKEY_J, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, |
| 798 {true, ui::VKEY_K, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, | 794 {true, ui::VKEY_K, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, |
| 799 }; | 795 }; |
| 800 GetController()->RegisterAccelerators(accelerators, arraysize(accelerators)); | 796 GetController()->RegisterAccelerators(accelerators, arraysize(accelerators)); |
| 801 | 797 |
| 802 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 798 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 803 params.bounds = gfx::Rect(5, 5, 20, 20); | 799 params.bounds = gfx::Rect(5, 5, 20, 20); |
| 804 views::Widget* widget = new views::Widget; | 800 views::Widget* widget = new views::Widget; |
| 805 WmWindowAura::Get(GetPrimaryRootWindow()) | 801 WmWindow::Get(GetPrimaryRootWindow()) |
| 806 ->GetRootWindowController() | 802 ->GetRootWindowController() |
| 807 ->ConfigureWidgetInitParamsForContainer( | 803 ->ConfigureWidgetInitParamsForContainer( |
| 808 widget, kShellWindowId_DefaultContainer, ¶ms); | 804 widget, kShellWindowId_DefaultContainer, ¶ms); |
| 809 widget->Init(params); | 805 widget->Init(params); |
| 810 widget->GetNativeView()->SetProperty(aura::client::kResizeBehaviorKey, | 806 widget->GetNativeView()->SetProperty(aura::client::kResizeBehaviorKey, |
| 811 ui::mojom::kResizeBehaviorCanMaximize); | 807 ui::mojom::kResizeBehaviorCanMaximize); |
| 812 widget->Show(); | 808 widget->Show(); |
| 813 widget->Activate(); | 809 widget->Activate(); |
| 814 | 810 |
| 815 wm::WindowState* window_state = | 811 wm::WindowState* window_state = |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 } | 1133 } |
| 1138 | 1134 |
| 1139 private: | 1135 private: |
| 1140 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest); | 1136 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest); |
| 1141 }; | 1137 }; |
| 1142 | 1138 |
| 1143 } // namespace | 1139 } // namespace |
| 1144 | 1140 |
| 1145 // TODO: needs LockStateController ported: http://crbug.com/632189. | 1141 // TODO: needs LockStateController ported: http://crbug.com/632189. |
| 1146 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { | 1142 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { |
| 1147 WmWindow* w1 = WmWindowAura::Get(CreateTestWindow(gfx::Rect())); | 1143 WmWindow* w1 = WmWindow::Get(CreateTestWindow(gfx::Rect())); |
| 1148 WmWindow* w2 = WmWindowAura::Get(CreateTestWindow(gfx::Rect())); | 1144 WmWindow* w2 = WmWindow::Get(CreateTestWindow(gfx::Rect())); |
| 1149 wm::ActivateWindow(w1); | 1145 wm::ActivateWindow(w1); |
| 1150 | 1146 |
| 1151 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); | 1147 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); |
| 1152 wm::WindowState* w1_state = w1->GetWindowState(); | 1148 wm::WindowState* w1_state = w1->GetWindowState(); |
| 1153 w1_state->OnWMEvent(&fullscreen); | 1149 w1_state->OnWMEvent(&fullscreen); |
| 1154 ASSERT_TRUE(w1_state->IsFullscreen()); | 1150 ASSERT_TRUE(w1_state->IsFullscreen()); |
| 1155 | 1151 |
| 1156 ui::test::EventGenerator& generator = GetEventGenerator(); | 1152 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1157 #if defined(OS_CHROMEOS) | 1153 #if defined(OS_CHROMEOS) |
| 1158 // Power key (reserved) should always be handled. | 1154 // Power key (reserved) should always be handled. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1233 for (size_t k = 0; k < kActionsAllowedAtModalWindowLength; ++k) | 1229 for (size_t k = 0; k < kActionsAllowedAtModalWindowLength; ++k) |
| 1234 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); | 1230 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); |
| 1235 for (const auto& action : actionsAllowedAtModalWindow) { | 1231 for (const auto& action : actionsAllowedAtModalWindow) { |
| 1236 EXPECT_TRUE(all_actions.find(action) != all_actions.end() || | 1232 EXPECT_TRUE(all_actions.find(action) != all_actions.end() || |
| 1237 all_debug_actions.find(action) != all_debug_actions.end() || | 1233 all_debug_actions.find(action) != all_debug_actions.end() || |
| 1238 all_dev_actions.find(action) != all_dev_actions.end()) | 1234 all_dev_actions.find(action) != all_dev_actions.end()) |
| 1239 << " action from kActionsAllowedAtModalWindow" | 1235 << " action from kActionsAllowedAtModalWindow" |
| 1240 << " not found in kAcceleratorData, kDebugAcceleratorData or" | 1236 << " not found in kAcceleratorData, kDebugAcceleratorData or" |
| 1241 << " kDeveloperAcceleratorData action: " << action; | 1237 << " kDeveloperAcceleratorData action: " << action; |
| 1242 } | 1238 } |
| 1243 WmWindow* window = | 1239 WmWindow* window = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| 1244 WmWindowAura::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | |
| 1245 window->Activate(); | 1240 window->Activate(); |
| 1246 WmShell::Get()->SimulateModalWindowOpenForTesting(true); | 1241 WmShell::Get()->SimulateModalWindowOpenForTesting(true); |
| 1247 for (const auto& action : all_actions) { | 1242 for (const auto& action : all_actions) { |
| 1248 if (actionsAllowedAtModalWindow.find(action) == | 1243 if (actionsAllowedAtModalWindow.find(action) == |
| 1249 actionsAllowedAtModalWindow.end()) { | 1244 actionsAllowedAtModalWindow.end()) { |
| 1250 EXPECT_TRUE(GetController()->PerformActionIfEnabled(action)) | 1245 EXPECT_TRUE(GetController()->PerformActionIfEnabled(action)) |
| 1251 << " for action (disallowed at modal window): " << action; | 1246 << " for action (disallowed at modal window): " << action; |
| 1252 } | 1247 } |
| 1253 } | 1248 } |
| 1254 // Testing of top row (F5-F10) accelerators that should still work | 1249 // Testing of top row (F5-F10) accelerators that should still work |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1332 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1327 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1333 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1328 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1334 EXPECT_TRUE( | 1329 EXPECT_TRUE( |
| 1335 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); | 1330 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); |
| 1336 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1331 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| 1337 } | 1332 } |
| 1338 | 1333 |
| 1339 // Make sure we don't alert if we do have a window. | 1334 // Make sure we don't alert if we do have a window. |
| 1340 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1335 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1341 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 1336 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| 1342 WmWindowAura::Get(aura_window)->Activate(); | 1337 WmWindow::Get(aura_window)->Activate(); |
| 1343 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1338 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1344 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1339 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
| 1345 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1340 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| 1346 delete aura_window; | 1341 delete aura_window; |
| 1347 } | 1342 } |
| 1348 | 1343 |
| 1349 // Don't alert if we have a minimized window either. | 1344 // Don't alert if we have a minimized window either. |
| 1350 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1345 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1351 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 1346 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| 1352 WmWindowAura::Get(aura_window)->Activate(); | 1347 WmWindow::Get(aura_window)->Activate(); |
| 1353 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 1348 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
| 1354 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1349 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1355 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1350 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
| 1356 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1351 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| 1357 delete aura_window; | 1352 delete aura_window; |
| 1358 } | 1353 } |
| 1359 } | 1354 } |
| 1360 | 1355 |
| 1361 #if defined(OS_CHROMEOS) | 1356 #if defined(OS_CHROMEOS) |
| 1362 namespace { | 1357 namespace { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1465 EXPECT_TRUE(IsMessageCenterEmpty()); | 1460 EXPECT_TRUE(IsMessageCenterEmpty()); |
| 1466 | 1461 |
| 1467 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1462 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
| 1468 // screen before we proceed testing the rest of accelerators. | 1463 // screen before we proceed testing the rest of accelerators. |
| 1469 ResetStateIfNeeded(); | 1464 ResetStateIfNeeded(); |
| 1470 } | 1465 } |
| 1471 } | 1466 } |
| 1472 #endif // defined(OS_CHROMEOS) | 1467 #endif // defined(OS_CHROMEOS) |
| 1473 | 1468 |
| 1474 } // namespace ash | 1469 } // namespace ash |
| OLD | NEW |