Chromium Code Reviews| Index: ash/mus/accelerators/accelerator_controller_unittest.cc |
| diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/mus/accelerators/accelerator_controller_unittest.cc |
| similarity index 66% |
| copy from ash/accelerators/accelerator_controller_unittest.cc |
| copy to ash/mus/accelerators/accelerator_controller_unittest.cc |
| index 32025f56a382f6113b9b08dff1fe174cacd7e2bb..51d2369aecfefa6160d5d2b4f98f42a69ba004e9 100644 |
| --- a/ash/accelerators/accelerator_controller_unittest.cc |
| +++ b/ash/mus/accelerators/accelerator_controller_unittest.cc |
| @@ -13,37 +13,25 @@ |
| #include "ash/common/system/brightness_control_delegate.h" |
| #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| #include "ash/common/system/tray/system_tray_delegate.h" |
| -#include "ash/common/test/test_shelf_delegate.h" |
| +#include "ash/common/test/ash_test.h" |
| #include "ash/common/wm/panels/panel_layout_manager.h" |
| #include "ash/common/wm/window_positioning_utils.h" |
| #include "ash/common/wm/window_state.h" |
| #include "ash/common/wm/wm_event.h" |
| +#include "ash/common/wm_lookup.h" |
| #include "ash/common/wm_shell.h" |
| #include "ash/common/wm_window.h" |
| +#include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h" |
| +#include "ash/mus/bridge/wm_shell_mus_test_api.h" |
| +#include "ash/mus/property_util.h" |
| +#include "ash/mus/test/wm_test_base.h" |
| #include "ash/public/cpp/shell_window_ids.h" |
| -#include "ash/shell.h" |
| -#include "ash/test/ash_test_base.h" |
| -#include "ash/test/lock_state_controller_test_api.h" |
| -#include "ash/test/test_screenshot_delegate.h" |
| -#include "ash/test/test_session_state_animator.h" |
| -#include "ash/wm/lock_state_controller.h" |
| -#include "ash/wm/window_state_aura.h" |
| -#include "ash/wm/window_util.h" |
| +#include "ash/root_window_controller.h" |
| #include "base/command_line.h" |
| #include "base/test/user_action_tester.cc" |
| -#include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| -#include "ui/app_list/presenter/app_list.h" |
| -#include "ui/app_list/presenter/test/test_app_list_presenter.h" |
| +#include "services/ui/public/interfaces/window_manager.mojom.h" |
| #include "ui/aura/client/aura_constants.h" |
| -#include "ui/aura/test/test_window_delegate.h" |
| -#include "ui/aura/test/test_windows.h" |
| #include "ui/aura/window.h" |
| -#include "ui/base/ime/chromeos/fake_ime_keyboard.h" |
| -#include "ui/base/ime/chromeos/ime_keyboard.h" |
| -#include "ui/base/ime/chromeos/input_method_manager.h" |
| -#include "ui/base/ime/chromeos/mock_input_method_manager.h" |
| -#include "ui/display/manager/display_manager.h" |
| -#include "ui/display/screen.h" |
| #include "ui/events/event.h" |
| #include "ui/events/event_processor.h" |
| #include "ui/events/test/event_generator.h" |
| @@ -205,9 +193,17 @@ bool TestTarget::CanHandleAccelerators() const { |
| return true; |
| } |
| +void ProcessAccelerator(ui::KeyboardCode key_code, int flags) { |
| + const ui::Accelerator accelerator(key_code, flags); |
| + if (!WmShell::Get()->accelerator_controller()->IsRegistered(accelerator)) |
| + return; |
| + |
| + mus::AcceleratorControllerRegistrarTestApi().ProcessAccelerator(accelerator); |
| +} |
| + |
| } // namespace |
| -class AcceleratorControllerTest : public test::AshTestBase { |
| +class AcceleratorControllerTest : public mus::WmTestBase { |
| public: |
| AcceleratorControllerTest() {} |
| ~AcceleratorControllerTest() override {} |
| @@ -255,14 +251,21 @@ class AcceleratorControllerTest : public test::AshTestBase { |
| static bool is_exiting(ExitWarningHandler* ewh) { |
| return ewh->state_ == ExitWarningHandler::EXITING; |
| } |
| - aura::Window* CreatePanel() { |
| - aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
| - NULL, ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(5, 5, 20, 20)); |
| - WmWindow* wm_window = WmWindow::Get(window); |
| - test::TestShelfDelegate::instance()->AddShelfItem(wm_window); |
| - PanelLayoutManager::Get(wm_window)->Relayout(); |
| + // TODO: needs support for TestShelfDelegate: http://crbug.com/632208. |
| + /* |
| + ui::Window* CreatePanel() { |
| + ui::Window* window = CreateTestWindow( |
| + gfx::Rect(5, 5, 20, 20), |
| + ui::wm::WINDOW_TYPE_PANEL); |
| + test::TestShelfDelegate* shelf_delegate = |
| + test::TestShelfDelegate::instance(); |
| + shelf_delegate->AddShelfItem(window); |
| + PanelLayoutManager* manager = |
| + PanelLayoutManager::Get(WmWindow::Get(window)); |
| + manager->Relayout(); |
| return window; |
| } |
| + */ |
| void SetBrightnessControlDelegate( |
| std::unique_ptr<BrightnessControlDelegate> delegate) { |
| @@ -282,6 +285,7 @@ AcceleratorController* AcceleratorControllerTest::GetController() { |
| return WmShell::Get()->accelerator_controller(); |
| } |
| +#if !defined(OS_WIN) |
| // Double press of exit shortcut => exiting |
| TEST_F(AcceleratorControllerTest, ExitWarningHandlerTestDoublePress) { |
| ui::Accelerator press(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
| @@ -337,6 +341,7 @@ TEST_F(AcceleratorControllerTest, LingeringExitWarningBubble) { |
| // Exit ash and there should be no crash |
| } |
| +#endif // !defined(OS_WIN) |
| TEST_F(AcceleratorControllerTest, Register) { |
| TestTarget target; |
| @@ -360,6 +365,7 @@ TEST_F(AcceleratorControllerTest, RegisterMultipleTarget) { |
| const ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
| TestTarget target1; |
| GetController()->Register({accelerator_a}, &target1); |
| + |
| TestTarget target2; |
| GetController()->Register({accelerator_a}, &target2); |
| @@ -371,9 +377,9 @@ TEST_F(AcceleratorControllerTest, RegisterMultipleTarget) { |
| } |
| TEST_F(AcceleratorControllerTest, Unregister) { |
| + TestTarget target; |
| const ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
| const ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_NONE); |
| - TestTarget target; |
| GetController()->Register({accelerator_a, accelerator_b}, &target); |
| // Unregistering a different accelerator does not affect the other |
| @@ -390,9 +396,9 @@ TEST_F(AcceleratorControllerTest, Unregister) { |
| } |
| TEST_F(AcceleratorControllerTest, UnregisterAll) { |
| + TestTarget target1; |
| const ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
| const ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_NONE); |
| - TestTarget target1; |
| GetController()->Register({accelerator_a, accelerator_b}, &target1); |
| const ui::Accelerator accelerator_c(ui::VKEY_C, ui::EF_NONE); |
| TestTarget target2; |
| @@ -435,43 +441,43 @@ TEST_F(AcceleratorControllerTest, IsRegistered) { |
| } |
| TEST_F(AcceleratorControllerTest, WindowSnap) { |
| - std::unique_ptr<aura::Window> window( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| + aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| + WmWindow* window = WmWindow::Get(aura_window); |
| + wm::WindowState* window_state = window->GetWindowState(); |
| window_state->Activate(); |
| { |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
| - WmWindow::Get(window.get())); |
| - EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| + gfx::Rect expected_bounds = |
| + wm::GetDefaultLeftSnappedWindowBoundsInParent(window); |
| + EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| } |
| { |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| - gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent( |
| - WmWindow::Get(window.get())); |
| - EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| + gfx::Rect expected_bounds = |
| + wm::GetDefaultRightSnappedWindowBoundsInParent(window); |
| + EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| } |
| { |
| gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); |
| GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| EXPECT_TRUE(window_state->IsMaximized()); |
| - EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString()); |
| + EXPECT_NE(normal_bounds.ToString(), window->GetBounds().ToString()); |
| GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| EXPECT_FALSE(window_state->IsMaximized()); |
| // Window gets restored to its restore bounds since side-maximized state |
| // is treated as a "maximized" state. |
| - EXPECT_EQ(normal_bounds.ToString(), window->bounds().ToString()); |
| + EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); |
| GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| EXPECT_FALSE(window_state->IsMaximized()); |
| GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| EXPECT_FALSE(window_state->IsMaximized()); |
| GetController()->PerformActionIfEnabled(TOGGLE_MAXIMIZED); |
| @@ -488,253 +494,51 @@ TEST_F(AcceleratorControllerTest, WindowSnap) { |
| } |
| } |
| -// Tests that when window docking is disabled, only snapping windows works. |
| +// Tests that window snapping works. |
| TEST_F(AcceleratorControllerTest, WindowSnapWithoutDocking) { |
| - ASSERT_FALSE(ash::switches::DockedWindowsEnabled()); |
| - std::unique_ptr<aura::Window> window( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - |
| - wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| + WmWindow* window = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| + wm::WindowState* window_state = window->GetWindowState(); |
| window_state->Activate(); |
| // Snap right. |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| gfx::Rect normal_bounds = window_state->GetRestoreBoundsInParent(); |
| - gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent( |
| - WmWindow::Get(window.get())); |
| - EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); |
| + gfx::Rect expected_bounds = |
| + wm::GetDefaultRightSnappedWindowBoundsInParent(window); |
| + EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| EXPECT_TRUE(window_state->IsSnapped()); |
| // Snap right again ->> becomes normal. |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| EXPECT_TRUE(window_state->IsNormalStateType()); |
| - EXPECT_FALSE(window_state->IsDocked()); |
| - EXPECT_EQ(normal_bounds.ToString(), window->bounds().ToString()); |
| + EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); |
| // Snap right. |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT); |
| EXPECT_TRUE(window_state->IsSnapped()); |
| - EXPECT_FALSE(window_state->IsDocked()); |
| // Snap left. |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| EXPECT_TRUE(window_state->IsSnapped()); |
| - EXPECT_FALSE(window_state->IsDocked()); |
| - expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
| - WmWindow::Get(window.get())); |
| - EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); |
| + expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(window); |
| + EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); |
| // Snap left again ->> becomes normal. |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| + GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); |
| EXPECT_TRUE(window_state->IsNormalStateType()); |
| - EXPECT_FALSE(window_state->IsDocked()); |
| - EXPECT_EQ(normal_bounds.ToString(), window->bounds().ToString()); |
| -} |
| - |
| -// Test class used for testing docked windows. |
| -class EnabledDockedWindowsAcceleratorControllerTest |
| - : public AcceleratorControllerTest { |
| - public: |
| - EnabledDockedWindowsAcceleratorControllerTest() = default; |
| - ~EnabledDockedWindowsAcceleratorControllerTest() override = default; |
| - |
| - void SetUp() override { |
| - base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| - ash::switches::kAshEnableDockedWindows); |
| - AcceleratorControllerTest::SetUp(); |
| - } |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(EnabledDockedWindowsAcceleratorControllerTest); |
| -}; |
| - |
| -TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| - WindowSnapLeftDockLeftRestore) { |
| - std::unique_ptr<aura::Window> window0( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - std::unique_ptr<aura::Window> window1( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| - window1_state->Activate(); |
| - |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
| - gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
| - WmWindow::Get(window1.get())); |
| - EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); |
| - EXPECT_TRUE(window1_state->IsSnapped()); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
| - EXPECT_TRUE(window1_state->IsDocked()); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - EXPECT_FALSE(window1_state->IsDocked()); |
| - EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); |
| -} |
| - |
| -TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| - WindowSnapRightDockRightRestore) { |
| - std::unique_ptr<aura::Window> window0( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - std::unique_ptr<aura::Window> window1( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - |
| - wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| - window1_state->Activate(); |
| - |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| - gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent(); |
| - gfx::Rect expected_bounds = wm::GetDefaultRightSnappedWindowBoundsInParent( |
| - WmWindow::Get(window1.get())); |
| - EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); |
| - EXPECT_TRUE(window1_state->IsSnapped()); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| - EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
| - EXPECT_TRUE(window1_state->IsDocked()); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| - EXPECT_FALSE(window1_state->IsDocked()); |
| - EXPECT_EQ(normal_bounds.ToString(), window1->bounds().ToString()); |
| -} |
| - |
| -TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| - WindowSnapLeftDockLeftSnapRight) { |
| - std::unique_ptr<aura::Window> window0( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - std::unique_ptr<aura::Window> window1( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - |
| - wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| - window1_state->Activate(); |
| - |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
| - WmWindow::Get(window1.get())); |
| - gfx::Rect expected_bounds2 = wm::GetDefaultRightSnappedWindowBoundsInParent( |
| - WmWindow::Get(window1.get())); |
| - EXPECT_EQ(expected_bounds.ToString(), window1->bounds().ToString()); |
| - EXPECT_TRUE(window1_state->IsSnapped()); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - EXPECT_FALSE(window1_state->IsNormalOrSnapped()); |
| - EXPECT_TRUE(window1_state->IsDocked()); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| - EXPECT_FALSE(window1_state->IsDocked()); |
| - EXPECT_TRUE(window1_state->IsSnapped()); |
| - EXPECT_EQ(expected_bounds2.ToString(), window1->bounds().ToString()); |
| -} |
| - |
| -TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| - WindowDockLeftMinimizeWindowWithRestore) { |
| - std::unique_ptr<aura::Window> window0( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - std::unique_ptr<aura::Window> window1( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - |
| - wm::WindowState* window1_state = wm::GetWindowState(window1.get()); |
| - window1_state->Activate(); |
| - |
| - std::unique_ptr<aura::Window> window2( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - |
| - wm::WindowState* window2_state = wm::GetWindowState(window2.get()); |
| - |
| - std::unique_ptr<aura::Window> window3( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - |
| - wm::WindowState* window3_state = wm::GetWindowState(window3.get()); |
| - window3_state->Activate(); |
| - |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - gfx::Rect window3_docked_bounds = window3->bounds(); |
| - |
| - window2_state->Activate(); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - window1_state->Activate(); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - |
| - EXPECT_TRUE(window3_state->IsDocked()); |
| - EXPECT_TRUE(window2_state->IsDocked()); |
| - EXPECT_TRUE(window1_state->IsDocked()); |
| - EXPECT_TRUE(window3_state->IsMinimized()); |
| - |
| - window1_state->Activate(); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - window2_state->Activate(); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - window3_state->Unminimize(); |
| - EXPECT_FALSE(window1_state->IsDocked()); |
| - EXPECT_FALSE(window2_state->IsDocked()); |
| - EXPECT_TRUE(window3_state->IsDocked()); |
| - EXPECT_EQ(window3_docked_bounds.ToString(), window3->bounds().ToString()); |
| -} |
| - |
| -TEST_F(EnabledDockedWindowsAcceleratorControllerTest, |
| - WindowPanelDockLeftDockRightRestore) { |
| - // TODO: http://crbug.com/632209. |
| - if (WmShell::Get()->IsRunningInMash()) |
| - return; |
| - std::unique_ptr<aura::Window> window0( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - |
| - std::unique_ptr<aura::Window> window(CreatePanel()); |
| - wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| - window_state->Activate(); |
| - |
| - gfx::Rect window_restore_bounds2 = window->bounds(); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); |
| - gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( |
| - WmWindow::Get(window.get())); |
| - gfx::Rect window_restore_bounds = window_state->GetRestoreBoundsInScreen(); |
| - EXPECT_NE(expected_bounds.ToString(), window->bounds().ToString()); |
| - EXPECT_FALSE(window_state->IsSnapped()); |
| - EXPECT_FALSE(window_state->IsNormalOrSnapped()); |
| - EXPECT_TRUE(window_state->IsDocked()); |
| - window_state->Restore(); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| - EXPECT_TRUE(window_state->IsDocked()); |
| - GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT); |
| - EXPECT_FALSE(window_state->IsDocked()); |
| - EXPECT_EQ(window_restore_bounds.ToString(), |
| - window_restore_bounds2.ToString()); |
| - EXPECT_EQ(window_restore_bounds.ToString(), window->bounds().ToString()); |
| -} |
| - |
| -TEST_F(EnabledDockedWindowsAcceleratorControllerTest, CenterWindowAccelerator) { |
| - std::unique_ptr<aura::Window> window( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - wm::WindowState* window_state = wm::GetWindowState(window.get()); |
| - window_state->Activate(); |
| - |
| - // Center the window using accelerator. |
| - GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); |
| - gfx::Rect work_area = display::Screen::GetScreen() |
| - ->GetDisplayNearestWindow(window.get()) |
| - .work_area(); |
| - gfx::Rect bounds = window->GetBoundsInScreen(); |
| - EXPECT_NEAR(bounds.x() - work_area.x(), work_area.right() - bounds.right(), |
| - 1); |
| - EXPECT_NEAR(bounds.y() - work_area.y(), work_area.bottom() - bounds.bottom(), |
| - 1); |
| - |
| - // Add the window to docked container and try to center it. |
| - window->SetBounds(gfx::Rect(0, 0, 20, 20)); |
| - const wm::WMEvent event(wm::WM_EVENT_DOCK); |
| - wm::GetWindowState(window.get())->OnWMEvent(&event); |
| - EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| - |
| - gfx::Rect docked_bounds = window->GetBoundsInScreen(); |
| - GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); |
| - // It should not get centered and should remain docked. |
| - EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| - EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| + EXPECT_EQ(normal_bounds.ToString(), window->GetBounds().ToString()); |
| } |
| +// This is commented out for two reasons: |
| +// . http://crbug.com/630683: ash doesn't see all key events. |
| +// . http://crbug.com/615033: EventGenerator doesn't work with ash. That can be |
|
oshima
2017/02/23 02:21:02
you meant "mash" ?
afakhry
2017/02/23 18:08:53
I didn't make these changes. I think rebasing didn
|
| +// worked around for the test, but no point until we decide on the first one. |
|
oshima
2017/02/23 02:21:02
I still don't quite Why this stopped working with
afakhry
2017/02/23 18:08:54
Please ignore this file.
|
| +/* |
|
oshima
2017/02/23 02:21:02
I prefer #if 0 as it allows nesting.
afakhry
2017/02/23 18:08:54
Please ignore this file.
|
| TEST_F(AcceleratorControllerTest, AutoRepeat) { |
| ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_CONTROL_DOWN); |
| accelerator_a.set_type(ui::ET_KEY_PRESSED); |
| TestTarget target_a; |
| - GetController()->Register({accelerator_a}, &target_a); |
| + GetController()->Register(accelerator_a, &target_a); |
| ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_CONTROL_DOWN); |
| accelerator_b.set_type(ui::ET_KEY_PRESSED); |
| TestTarget target_b; |
| - GetController()->Register({accelerator_b}, &target_b); |
| + GetController()->Register(accelerator_b, &target_b); |
| ui::test::EventGenerator& generator = GetEventGenerator(); |
| generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); |
| @@ -769,7 +573,10 @@ TEST_F(AcceleratorControllerTest, AutoRepeat) { |
| EXPECT_EQ(4, target_a.accelerator_pressed_count()); |
| EXPECT_EQ(4, target_a.accelerator_repeat_count()); |
| } |
| +*/ |
| +// TODO: update once http://crbug.com/630683 is resolved. |
| +/* |
| TEST_F(AcceleratorControllerTest, Previous) { |
| ui::test::EventGenerator& generator = GetEventGenerator(); |
| generator.PressKey(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); |
| @@ -784,6 +591,7 @@ TEST_F(AcceleratorControllerTest, Previous) { |
| EXPECT_EQ(ui::VKEY_TAB, GetPreviousAccelerator().key_code()); |
| EXPECT_EQ(ui::EF_CONTROL_DOWN, GetPreviousAccelerator().modifiers()); |
| } |
| +*/ |
| TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) { |
| const AcceleratorData accelerators[] = { |
| @@ -793,68 +601,35 @@ TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) { |
| GetController()->RegisterAccelerators(accelerators, arraysize(accelerators)); |
| views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| - params.context = CurrentContext(); |
| params.bounds = gfx::Rect(5, 5, 20, 20); |
| views::Widget* widget = new views::Widget; |
| + WmWindow::Get(GetPrimaryRootWindow()) |
| + ->GetRootWindowController() |
| + ->ConfigureWidgetInitParamsForContainer( |
| + widget, kShellWindowId_DefaultContainer, ¶ms); |
| widget->Init(params); |
| - widget->Show(); |
| - widget->Activate(); |
| widget->GetNativeView()->SetProperty(aura::client::kResizeBehaviorKey, |
| ui::mojom::kResizeBehaviorCanMaximize); |
| + widget->Show(); |
| + widget->Activate(); |
| - ui::test::EventGenerator& generator = GetEventGenerator(); |
| - wm::WindowState* window_state = wm::GetWindowState(widget->GetNativeView()); |
| + wm::WindowState* window_state = |
| + WmLookup::Get()->GetWindowForWidget(widget)->GetWindowState(); |
| // Toggling not suppressed. |
| - generator.PressKey(ui::VKEY_J, ui::EF_ALT_DOWN); |
| + ProcessAccelerator(ui::VKEY_J, ui::EF_ALT_DOWN); |
| EXPECT_TRUE(window_state->IsFullscreen()); |
| // The same accelerator - toggling suppressed. |
| - generator.PressKey(ui::VKEY_J, ui::EF_ALT_DOWN | ui::EF_IS_REPEAT); |
| + ProcessAccelerator(ui::VKEY_J, ui::EF_ALT_DOWN | ui::EF_IS_REPEAT); |
| EXPECT_TRUE(window_state->IsFullscreen()); |
| // Different accelerator. |
| - generator.PressKey(ui::VKEY_K, ui::EF_ALT_DOWN); |
| + ProcessAccelerator(ui::VKEY_K, ui::EF_ALT_DOWN); |
| EXPECT_FALSE(window_state->IsFullscreen()); |
| } |
| -// TODO(oshima): Fix this test to use EventGenerator. |
| -#if defined(USE_X11) |
| -TEST_F(AcceleratorControllerTest, ProcessOnce) { |
| - // The IME event filter interferes with the basic key event propagation we |
| - // attempt to do here, so we disable it. |
| - DisableIME(); |
| - ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
| - TestTarget target; |
| - GetController()->Register({accelerator_a}, &target); |
| - |
| - // The accelerator is processed only once. |
| - ui::EventProcessor* dispatcher = |
| - Shell::GetPrimaryRootWindow()->GetHost()->event_processor(); |
| - |
| - ui::ScopedXI2Event key_event; |
| - key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); |
| - ui::KeyEvent key_event1(key_event); |
| - ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event1); |
| - EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed); |
| - |
| - ui::KeyEvent key_event2('A', ui::VKEY_A, ui::EF_NONE); |
| - details = dispatcher->OnEventFromSource(&key_event2); |
| - EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed); |
| - |
| - key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); |
| - ui::KeyEvent key_event3(key_event); |
| - details = dispatcher->OnEventFromSource(&key_event3); |
| - EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); |
| - EXPECT_EQ(1, target.accelerator_pressed_count()); |
| -} |
| -#endif |
| - |
| TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
| - // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. |
| - if (WmShell::Get()->IsRunningInMash()) |
| - return; |
| - |
| // CycleBackward |
| EXPECT_TRUE(ProcessInController( |
| ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
| @@ -867,6 +642,8 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
| // The "Take Screenshot", "Take Partial Screenshot", volume, brightness, and |
| // keyboard brightness accelerators are only defined on ChromeOS. |
| + // TODO: needs ScreenShotDelegate converted: http://crbug.com/612331. |
| + /* |
| { |
| test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
| delegate->set_can_take_screenshot(false); |
| @@ -889,6 +666,7 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
| ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
| } |
| + */ |
| const ui::Accelerator volume_mute(ui::VKEY_VOLUME_MUTE, ui::EF_NONE); |
| const ui::Accelerator volume_down(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); |
| const ui::Accelerator volume_up(ui::VKEY_VOLUME_UP, ui::EF_NONE); |
| @@ -992,30 +770,27 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
| ui::Accelerator(ui::VKEY_M, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
| // Lock screen |
| - // NOTE: Accelerators that do not work on the lock screen need to be |
| - // tested before the sequence below is invoked because it causes a side |
| - // effect of locking the screen. |
| - EXPECT_TRUE( |
| + // TODO(derat): Reenable this once user sessions work in mash. |
| + EXPECT_FALSE( |
| ProcessInController(ui::Accelerator(ui::VKEY_L, ui::EF_COMMAND_DOWN))); |
| } |
| -TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { |
| - app_list::test::TestAppListPresenter test_app_list_presenter; |
| - WmShell::Get()->app_list()->SetAppListPresenter( |
| - test_app_list_presenter.CreateInterfacePtrAndBind()); |
| +// TODO: fails in mash, http://crbug.com/632180. |
| +TEST_F(AcceleratorControllerTest, DISABLED_GlobalAcceleratorsToggleAppList) { |
| AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
| + EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| - // The press event should not toggle the AppList, the release should instead. |
| + // The press event should not open the AppList, the release should instead. |
| EXPECT_FALSE( |
| ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| - RunAllPendingInMessageLoop(); |
| EXPECT_EQ(ui::VKEY_LWIN, GetCurrentAccelerator().key_code()); |
| - EXPECT_EQ(0u, test_app_list_presenter.toggle_count()); |
| + |
| + EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| EXPECT_TRUE( |
| ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| - RunAllPendingInMessageLoop(); |
| - EXPECT_EQ(1u, test_app_list_presenter.toggle_count()); |
| + EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| + |
| EXPECT_EQ(ui::VKEY_LWIN, GetPreviousAccelerator().key_code()); |
| // When spoken feedback is on, the AppList should not toggle. |
| @@ -1025,26 +800,30 @@ TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { |
| EXPECT_FALSE( |
| ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| - RunAllPendingInMessageLoop(); |
| - EXPECT_EQ(1u, test_app_list_presenter.toggle_count()); |
| + EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| - // Turning off spoken feedback should allow the AppList to toggle again. |
| EXPECT_FALSE( |
| ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| EXPECT_TRUE( |
| ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| - RunAllPendingInMessageLoop(); |
| - EXPECT_EQ(2u, test_app_list_presenter.toggle_count()); |
| + EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| + |
| + // When spoken feedback is on, the AppList should not toggle. |
| + delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| + EXPECT_FALSE( |
| + ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| + EXPECT_FALSE( |
| + ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| + delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| + EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| // The press of VKEY_BROWSER_SEARCH should toggle the AppList |
| EXPECT_TRUE(ProcessInController( |
| ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
| - RunAllPendingInMessageLoop(); |
| - EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); |
| + EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| EXPECT_FALSE(ProcessInController( |
| ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
| - RunAllPendingInMessageLoop(); |
| - EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); |
| + EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| } |
| TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { |
| @@ -1104,7 +883,6 @@ TEST_F(AcceleratorControllerTest, PreferredReservedAccelerators) { |
| ui::Accelerator(ui::VKEY_POWER, ui::EF_NONE))); |
| EXPECT_FALSE(GetController()->IsPreferred( |
| ui::Accelerator(ui::VKEY_POWER, ui::EF_NONE))); |
| - |
| // ALT+Tab are not reserved but preferred. |
| EXPECT_FALSE(GetController()->IsReserved( |
| ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); |
| @@ -1130,87 +908,9 @@ TEST_F(AcceleratorControllerTest, PreferredReservedAccelerators) { |
| GetController()->IsPreferred(ui::Accelerator(ui::VKEY_A, ui::EF_NONE))); |
| } |
| +/* |
| namespace { |
| -class TestInputMethodManager |
| - : public chromeos::input_method::MockInputMethodManager { |
| - public: |
| - TestInputMethodManager() = default; |
| - ~TestInputMethodManager() override = default; |
| - |
| - // MockInputMethodManager: |
| - chromeos::input_method::ImeKeyboard* GetImeKeyboard() override { |
| - return &keyboard_; |
| - } |
| - |
| - private: |
| - chromeos::input_method::FakeImeKeyboard keyboard_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(TestInputMethodManager); |
| -}; |
| - |
| -class ToggleCapsLockTest : public AcceleratorControllerTest { |
| - public: |
| - ToggleCapsLockTest() = default; |
| - ~ToggleCapsLockTest() override = default; |
| - |
| - void SetUp() override { |
| - AcceleratorControllerTest::SetUp(); |
| - chromeos::input_method::InputMethodManager::Initialize( |
| - new TestInputMethodManager); |
| - } |
| - |
| - void TearDown() override { |
| - chromeos::input_method::InputMethodManager::Shutdown(); |
| - AcceleratorControllerTest::TearDown(); |
| - } |
| - |
| - private: |
| - DISALLOW_COPY_AND_ASSIGN(ToggleCapsLockTest); |
| -}; |
| - |
| -// Tests the four combinations of the TOGGLE_CAPS_LOCK accelerator. |
| -TEST_F(ToggleCapsLockTest, ToggleCapsLockAccelerators) { |
| - chromeos::input_method::InputMethodManager* input_method_manager = |
| - chromeos::input_method::InputMethodManager::Get(); |
| - ASSERT_TRUE(input_method_manager); |
| - EXPECT_FALSE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| - |
| - // 1. Press Alt, Press Search, Release Search, Release Alt. |
| - // Note when you press Alt then press search, the key_code at this point is |
| - // VKEY_LWIN (for search) and Alt is the modifier. |
| - const ui::Accelerator press_alt_then_search(ui::VKEY_LWIN, ui::EF_ALT_DOWN); |
| - EXPECT_FALSE(ProcessInController(press_alt_then_search)); |
| - // When you release Search before Alt, the key_code is still VKEY_LWIN and |
| - // Alt is still the modifier. |
| - const ReleaseAccelerator release_search_before_alt(ui::VKEY_LWIN, |
| - ui::EF_ALT_DOWN); |
| - EXPECT_TRUE(ProcessInController(release_search_before_alt)); |
| - EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| - input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); |
| - |
| - // 2. Press Search, Press Alt, Release Search, Release Alt. |
| - const ui::Accelerator press_search_then_alt(ui::VKEY_MENU, |
| - ui::EF_COMMAND_DOWN); |
| - EXPECT_FALSE(ProcessInController(press_search_then_alt)); |
| - EXPECT_TRUE(ProcessInController(release_search_before_alt)); |
| - EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| - input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); |
| - |
| - // 3. Press Alt, Press Search, Release Alt, Release Search. |
| - EXPECT_FALSE(ProcessInController(press_alt_then_search)); |
| - const ReleaseAccelerator release_alt_before_search(ui::VKEY_MENU, |
| - ui::EF_COMMAND_DOWN); |
| - EXPECT_TRUE(ProcessInController(release_alt_before_search)); |
| - EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| - input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); |
| - |
| - // 4. Press Search, Press Alt, Release Alt, Release Search. |
| - EXPECT_FALSE(ProcessInController(press_search_then_alt)); |
| - EXPECT_TRUE(ProcessInController(release_alt_before_search)); |
| - EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| -} |
| - |
| class PreferredReservedAcceleratorsTest : public test::AshTestBase { |
| public: |
| PreferredReservedAcceleratorsTest() {} |
| @@ -1229,38 +929,28 @@ class PreferredReservedAcceleratorsTest : public test::AshTestBase { |
| } // namespace |
| +// TODO: needs LockStateController ported: http://crbug.com/632189. |
| TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { |
| - // TODO: needs LockStateController ported: http://crbug.com/632189. |
| - if (WmShell::Get()->IsRunningInMash()) |
| - return; |
| - |
| - aura::Window* w1 = CreateTestWindowInShellWithId(0); |
| - aura::Window* w2 = CreateTestWindowInShellWithId(1); |
| + WmWindow* w1 = WmWindow::Get(CreateTestWindow(gfx::Rect())); |
| + WmWindow* w2 = WmWindow::Get(CreateTestWindow(gfx::Rect())); |
| wm::ActivateWindow(w1); |
| wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); |
| - wm::WindowState* w1_state = wm::GetWindowState(w1); |
| + wm::WindowState* w1_state = w1->GetWindowState(); |
| w1_state->OnWMEvent(&fullscreen); |
| ASSERT_TRUE(w1_state->IsFullscreen()); |
| ui::test::EventGenerator& generator = GetEventGenerator(); |
| - |
| // Power key (reserved) should always be handled. |
| - test::LockStateControllerTestApi test_api( |
| + LockStateController::TestApi test_api( |
| Shell::GetInstance()->lock_state_controller()); |
| EXPECT_FALSE(test_api.is_animating_lock()); |
| generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); |
| EXPECT_TRUE(test_api.is_animating_lock()); |
| - auto press_and_release_alt_tab = [&generator]() { |
| - generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| - // Release the alt key to trigger the window activation. |
| - generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); |
| - }; |
| - |
| // A fullscreen window can consume ALT-TAB (preferred). |
| ASSERT_EQ(w1, wm::GetActiveWindow()); |
| - press_and_release_alt_tab(); |
| + generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| ASSERT_EQ(w1, wm::GetActiveWindow()); |
| ASSERT_NE(w2, wm::GetActiveWindow()); |
| @@ -1275,15 +965,13 @@ TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { |
| ASSERT_FALSE(w1_state->IsFullscreen()); |
| EXPECT_EQ(w1, wm::GetActiveWindow()); |
| - press_and_release_alt_tab(); |
| + generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| ASSERT_NE(w1, wm::GetActiveWindow()); |
| ASSERT_EQ(w2, wm::GetActiveWindow()); |
| } |
| +// TODO: needs LockStateController ported: http://crbug.com/632189. |
| TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) { |
| - // TODO: needs LockStateController ported: http://crbug.com/632189. |
| - if (WmShell::Get()->IsRunningInMash()) |
| - return; |
| aura::Window* w1 = CreateTestWindowInShellWithId(0); |
| aura::Window* w2 = CreateTestWindowInShellWithId(1); |
| wm::ActivateWindow(w1); |
| @@ -1296,9 +984,8 @@ TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) { |
| } |
| ui::test::EventGenerator& generator = GetEventGenerator(); |
| - |
| // Power key (reserved) should always be handled. |
| - test::LockStateControllerTestApi test_api( |
| + LockStateController::TestApi test_api( |
| Shell::GetInstance()->lock_state_controller()); |
| EXPECT_FALSE(test_api.is_animating_lock()); |
| generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); |
| @@ -1311,12 +998,9 @@ TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) { |
| ASSERT_EQ(w1, wm::GetActiveWindow()); |
| ASSERT_NE(w2, wm::GetActiveWindow()); |
| } |
| +*/ |
| TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
| - // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. |
| - if (WmShell::Get()->IsRunningInMash()) |
| - return; |
| - |
| std::set<AcceleratorAction> all_actions; |
| for (size_t i = 0; i < kAcceleratorDataLength; ++i) |
| all_actions.insert(kAcceleratorData[i].action); |
| @@ -1338,9 +1022,8 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
| << " not found in kAcceleratorData, kDebugAcceleratorData or" |
| << " kDeveloperAcceleratorData action: " << action; |
| } |
| - std::unique_ptr<aura::Window> window( |
| - CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - wm::ActivateWindow(window.get()); |
| + WmWindow* window = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
| + window->Activate(); |
| WmShell::Get()->SimulateModalWindowOpenForTesting(true); |
| for (const auto& action : all_actions) { |
| if (actionsAllowedAtModalWindow.find(action) == |
| @@ -1353,27 +1036,32 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
| // when a modal window is open |
| // |
| // Screenshot |
| - { |
| - test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
| - delegate->set_can_take_screenshot(false); |
| - EXPECT_TRUE(ProcessInController( |
| - ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN))); |
| - EXPECT_TRUE( |
| - ProcessInController(ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); |
| - EXPECT_TRUE(ProcessInController(ui::Accelerator( |
| - ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| - delegate->set_can_take_screenshot(true); |
| - EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| - EXPECT_TRUE(ProcessInController( |
| - ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN))); |
| - EXPECT_EQ(1, delegate->handle_take_screenshot_count()); |
| - EXPECT_TRUE( |
| - ProcessInController(ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); |
| - EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
| - EXPECT_TRUE(ProcessInController(ui::Accelerator( |
| - ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| - EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
| - } |
| + // TODO: needs ScreenShotDelegate converted: http://crbug.com/612331. |
| + /* |
| + { |
| + test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
| + delegate->set_can_take_screenshot(false); |
| + EXPECT_TRUE(ProcessInController( |
| + ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN))); |
| + EXPECT_TRUE( |
| + ProcessInController(ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); |
| + EXPECT_TRUE(ProcessInController(ui::Accelerator( |
| + ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | |
| + ui::EF_CONTROL_DOWN))); |
| + delegate->set_can_take_screenshot(true); |
| + EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| + EXPECT_TRUE(ProcessInController( |
| + ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN))); |
| + EXPECT_EQ(1, delegate->handle_take_screenshot_count()); |
| + EXPECT_TRUE( |
| + ProcessInController(ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); |
| + EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
| + EXPECT_TRUE(ProcessInController(ui::Accelerator( |
| + ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN | |
| + ui::EF_CONTROL_DOWN))); |
| + EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
| + } |
| + */ |
| // Brightness |
| const ui::Accelerator brightness_down(ui::VKEY_BRIGHTNESS_DOWN, ui::EF_NONE); |
| const ui::Accelerator brightness_up(ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE); |
| @@ -1416,7 +1104,9 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
| } |
| } |
| -TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { |
| +// TODO: reenable. Disabled because shelf asynchronously created: |
| +// http://crbug.com/632192. |
| +TEST_F(AcceleratorControllerTest, DISABLED_DisallowedWithNoWindow) { |
| AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
| for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| @@ -1427,23 +1117,24 @@ TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { |
| } |
| // Make sure we don't alert if we do have a window. |
| - std::unique_ptr<aura::Window> window; |
| for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| - window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - wm::ActivateWindow(window.get()); |
| + aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| + WmWindow::Get(aura_window)->Activate(); |
| delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
| EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| + delete aura_window; |
| } |
| // Don't alert if we have a minimized window either. |
| for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| - window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| - wm::ActivateWindow(window.get()); |
| + aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| + WmWindow::Get(aura_window)->Activate(); |
| GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
| delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
| EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| + delete aura_window; |
| } |
| } |
| @@ -1455,6 +1146,10 @@ class DeprecatedAcceleratorTester : public AcceleratorControllerTest { |
| DeprecatedAcceleratorTester() {} |
| ~DeprecatedAcceleratorTester() override {} |
| + // TODO: this override should be removed and put in WmTestBase. |
| + // http://crbug.com/632200. |
| + void UnblockUserSession() {} |
| + |
| void SetUp() override { |
| AcceleratorControllerTest::SetUp(); |
| @@ -1501,11 +1196,10 @@ class DeprecatedAcceleratorTester : public AcceleratorControllerTest { |
| } // namespace |
| -TEST_F(DeprecatedAcceleratorTester, TestDeprecatedAcceleratorsBehavior) { |
| - // TODO: disabled because of UnblockUserSession() not working: |
| - // http://crbug.com/632201. |
| - if (WmShell::Get()->IsRunningInMash()) |
| - return; |
| +// TODO: disabled because of UnblockUserSession() not working: |
| +// http://crbug.com/632201. |
| +TEST_F(DeprecatedAcceleratorTester, |
| + DISABLED_TestDeprecatedAcceleratorsBehavior) { |
| for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { |
| const AcceleratorData& entry = kDeprecatedAccelerators[i]; |
| @@ -1531,7 +1225,9 @@ TEST_F(DeprecatedAcceleratorTester, TestDeprecatedAcceleratorsBehavior) { |
| } |
| } |
| -TEST_F(DeprecatedAcceleratorTester, TestNewAccelerators) { |
| +// TODO: disabled because of UnblockUserSession() not working: |
| +// http://crbug.com/632201. |
| +TEST_F(DeprecatedAcceleratorTester, DISABLED_TestNewAccelerators) { |
| // Add below the new accelerators that replaced the deprecated ones (if any). |
| const AcceleratorData kNewAccelerators[] = { |
| {true, ui::VKEY_L, ui::EF_COMMAND_DOWN, LOCK_SCREEN}, |