Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: ash/mus/accelerators/accelerator_controller_unittest.cc

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Rebase and fix 1 test Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/mus/accelerators/accelerator_controller_unittest.cc
diff --git a/ash/mus/accelerators/accelerator_controller_unittest.cc b/ash/mus/accelerators/accelerator_controller_unittest.cc
index 8366f06b2627aec693723b6cfde94e2997cfddb8..51d2369aecfefa6160d5d2b4f98f42a69ba004e9 100644
--- a/ash/mus/accelerators/accelerator_controller_unittest.cc
+++ b/ash/mus/accelerators/accelerator_controller_unittest.cc
@@ -448,13 +448,13 @@ TEST_F(AcceleratorControllerTest, WindowSnap) {
window_state->Activate();
{
- GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
+ 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);
+ GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_RIGHT);
gfx::Rect expected_bounds =
wm::GetDefaultRightSnappedWindowBoundsInParent(window);
EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString());
@@ -473,11 +473,11 @@ TEST_F(AcceleratorControllerTest, WindowSnap) {
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);
@@ -494,239 +494,37 @@ 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());
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(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->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(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->GetBounds().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) {
- CreateTestWindow(gfx::Rect(5, 5, 20, 20));
- WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)));
- wm::WindowState* window1_state = window1->GetWindowState();
- window1_state->Activate();
-
- GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
- gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
- gfx::Rect expected_bounds =
- wm::GetDefaultLeftSnappedWindowBoundsInParent(window1);
- EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().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->GetBounds().ToString());
-}
-
-TEST_F(EnabledDockedWindowsAcceleratorControllerTest,
- WindowSnapRightDockRightRestore) {
- CreateTestWindow(gfx::Rect(5, 5, 20, 20));
- WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)));
-
- wm::WindowState* window1_state = window1->GetWindowState();
- window1_state->Activate();
-
- GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_RIGHT);
- gfx::Rect normal_bounds = window1_state->GetRestoreBoundsInParent();
- gfx::Rect expected_bounds =
- wm::GetDefaultRightSnappedWindowBoundsInParent(window1);
- EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().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->GetBounds().ToString());
-}
-
-TEST_F(EnabledDockedWindowsAcceleratorControllerTest,
- WindowSnapLeftDockLeftSnapRight) {
- CreateTestWindow(gfx::Rect(5, 5, 20, 20));
- WmWindow* window1 = WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20)));
-
- wm::WindowState* window1_state = window1->GetWindowState();
- window1_state->Activate();
-
- GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
- gfx::Rect expected_bounds =
- wm::GetDefaultLeftSnappedWindowBoundsInParent(window1);
- gfx::Rect expected_bounds2 =
- wm::GetDefaultRightSnappedWindowBoundsInParent(window1);
- EXPECT_EQ(expected_bounds.ToString(), window1->GetBounds().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->GetBounds().ToString());
-}
-
-TEST_F(EnabledDockedWindowsAcceleratorControllerTest,
- WindowDockLeftMinimizeWindowWithRestore) {
- WindowOwner window_owner(
- WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))));
- WindowOwner window1_owner(
- WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))));
- WmWindow* window1 = window1_owner.window();
-
- wm::WindowState* window1_state = window1->GetWindowState();
- window1_state->Activate();
-
- WindowOwner window2_owner(
- WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))));
- WmWindow* window2 = window2_owner.window();
-
- wm::WindowState* window2_state = window2->GetWindowState();
-
- WindowOwner window3_owner(
- WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))));
- WmWindow* window3 = window3_owner.window();
-
- wm::WindowState* window3_state = window3->GetWindowState();
- window3_state->Activate();
-
- GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
- GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
- gfx::Rect window3_docked_bounds = window3->GetBounds();
-
- 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->GetBounds().ToString());
-}
-
-// TODO: Needs CreatePanel(): http://crbug.com/632209.
-/*
-TEST_F(EnabledDockedWindowsAcceleratorControllerTest,
- WindowPanelDockLeftDockRightRestore) {
- WmWndow* window0 =
- WmWindow::Get(CreateTestWindow(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) {
- WindowOwner window_owner(
- WmWindow::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))));
- WmWindow* window = window_owner.window();
- wm::WindowState* window_state = window->GetWindowState();
- window_state->Activate();
-
- // Center the window using accelerator.
- GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER);
- gfx::Rect work_area = window->GetDisplayNearestWindow().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);
- window->GetWindowState()->OnWMEvent(&event);
- EXPECT_EQ(kShellWindowId_DockedContainer,
- window->GetParent()->GetShellWindowId());
-
- 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->GetParent()->GetShellWindowId());
- EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().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

Powered by Google App Engine
This is Rietveld 408576698