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

Unified Diff: ash/wm/workspace/workspace_event_handler_unittest.cc

Issue 239213003: Revert of Prevents double-clicks on a tab close button from aslo maximizing the browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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/wm/workspace/workspace_event_handler_unittest.cc
diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc
index ce69947fd044a9ae7fb69874c3e4c6cd033314e8..fe9ec8c2ce583c441ba85d2fc6a5eeb3f5d05d34 100644
--- a/ash/wm/workspace/workspace_event_handler_unittest.cc
+++ b/ash/wm/workspace/workspace_event_handler_unittest.cc
@@ -85,8 +85,8 @@
// Double clicking the vertical resize edge of a window should maximize it
// vertically.
gfx::Rect restored_bounds(10, 10, 50, 50);
- aura::test::TestWindowDelegate delegate;
- scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds));
+ aura::test::TestWindowDelegate wd;
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
wm::ActivateWindow(window.get());
@@ -97,7 +97,7 @@
window.get());
// Double-click the top resize edge.
- delegate.set_window_component(HTTOP);
+ wd.set_window_component(HTTOP);
// On X a double click actually generates a drag between each press/release.
// Explicitly trigger this path since we had bugs in dealing with it
// correctly.
@@ -126,7 +126,7 @@
EXPECT_FALSE(window_state->HasRestoreBounds());
// Double clicking the left resize edge should maximize horizontally.
- delegate.set_window_component(HTLEFT);
+ wd.set_window_component(HTLEFT);
generator.DoubleClickLeftButton();
bounds_in_screen = window->GetBoundsInScreen();
EXPECT_EQ(restored_bounds.y(), bounds_in_screen.y());
@@ -149,14 +149,14 @@
// Verify the double clicking the resize edge works on 2nd display too.
UpdateDisplay("200x200,400x300");
gfx::Rect work_area2 = ScreenUtil::GetSecondaryDisplay().work_area();
- restored_bounds.SetRect(220, 20, 50, 50);
+ restored_bounds.SetRect(220,20, 50, 50);
window->SetBoundsInScreen(restored_bounds, ScreenUtil::GetSecondaryDisplay());
aura::Window* second_root = Shell::GetAllRootWindows()[1];
EXPECT_EQ(second_root, window->GetRootWindow());
aura::test::EventGenerator generator2(second_root, window.get());
// Y-axis maximization.
- delegate.set_window_component(HTTOP);
+ wd.set_window_component(HTTOP);
generator2.PressLeftButton();
generator2.ReleaseLeftButton();
generator2.set_flags(ui::EF_IS_DOUBLE_CLICK);
@@ -176,7 +176,7 @@
EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString());
// X-axis maximization.
- delegate.set_window_component(HTLEFT);
+ wd.set_window_component(HTLEFT);
generator2.DoubleClickLeftButton();
bounds_in_screen = window->GetBoundsInScreen();
EXPECT_EQ(restored_bounds.y(), bounds_in_screen.y());
@@ -193,8 +193,8 @@
// Tests the behavior when double clicking the border of a side snapped window.
TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisWhenSideSnapped) {
gfx::Rect restored_bounds(10, 10, 50, 50);
- aura::test::TestWindowDelegate delegate;
- scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds));
+ aura::test::TestWindowDelegate wd;
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
gfx::Rect work_area_in_screen = Shell::GetScreen()->GetDisplayNearestWindow(
window.get()).work_area();
@@ -214,7 +214,7 @@
// to the restored bounds would be weird).
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
window.get());
- delegate.set_window_component(HTTOP);
+ wd.set_window_component(HTTOP);
generator.DoubleClickLeftButton();
EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
EXPECT_EQ(snapped_bounds_in_screen.ToString(),
@@ -222,7 +222,7 @@
// Double clicking the right border should exit the side snapped state and
// make the window take up the entire work area.
- delegate.set_window_component(HTRIGHT);
+ wd.set_window_component(HTRIGHT);
generator.DoubleClickLeftButton();
EXPECT_TRUE(window_state->IsNormalStateType());
EXPECT_EQ(work_area_in_screen.ToString(),
@@ -232,20 +232,20 @@
TEST_F(WorkspaceEventHandlerTest,
DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) {
gfx::Rect restored_bounds(10, 10, 50, 50);
- aura::test::TestWindowDelegate delegate;
- scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds));
+ aura::test::TestWindowDelegate wd;
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
wm::ActivateWindow(window.get());
gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
window.get()).work_area();
- delegate.set_maximum_size(gfx::Size(0, 100));
+ wd.set_maximum_size(gfx::Size(0, 100));
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
window.get());
// Double-click the top resize edge.
- delegate.set_window_component(HTTOP);
+ wd.set_window_component(HTTOP);
generator.DoubleClickLeftButton();
// The size of the window should be unchanged.
@@ -256,20 +256,20 @@
TEST_F(WorkspaceEventHandlerTest,
DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) {
gfx::Rect restored_bounds(10, 10, 50, 50);
- aura::test::TestWindowDelegate delegate;
- scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, restored_bounds));
+ aura::test::TestWindowDelegate wd;
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
wm::ActivateWindow(window.get());
gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
window.get()).work_area();
- delegate.set_maximum_size(gfx::Size(100, 0));
+ wd.set_maximum_size(gfx::Size(100, 0));
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
window.get());
// Double-click the top resize edge.
- delegate.set_window_component(HTRIGHT);
+ wd.set_window_component(HTRIGHT);
generator.DoubleClickLeftButton();
// The size of the window should be unchanged.
@@ -279,14 +279,14 @@
TEST_F(WorkspaceEventHandlerTest,
DoubleClickOrTapWithModalChildDoesntMaximize) {
- aura::test::TestWindowDelegate delegate1;
- aura::test::TestWindowDelegate delegate2;
+ aura::test::TestWindowDelegate wd1;
+ aura::test::TestWindowDelegate wd2;
scoped_ptr<aura::Window> window(
- CreateTestWindow(&delegate1, gfx::Rect(10, 20, 30, 40)));
+ CreateTestWindow(&wd1, gfx::Rect(10, 20, 30, 40)));
scoped_ptr<aura::Window> child(
- CreateTestWindow(&delegate2, gfx::Rect(0, 0, 1, 1)));
+ CreateTestWindow(&wd2, gfx::Rect(0, 0, 1, 1)));
window->SetProperty(aura::client::kCanMaximizeKey, true);
- delegate1.set_window_component(HTCAPTION);
+ wd1.set_window_component(HTCAPTION);
child->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
::wm::AddTransientChild(window.get(), child.get());
@@ -308,9 +308,9 @@
// Test the behavior as a result of double clicking the window header.
TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
- aura::test::TestWindowDelegate delegate;
+ aura::test::TestWindowDelegate wd;
scoped_ptr<aura::Window> window(
- CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
+ CreateTestWindow(&wd, gfx::Rect(1, 2, 30, 40)));
window->SetProperty(aura::client::kCanMaximizeKey, true);
wm::WindowState* window_state = wm::GetWindowState(window.get());
@@ -321,22 +321,19 @@
EXPECT_FALSE(window_state->IsMaximized());
// 1) Double clicking a normal window should maximize.
- delegate.set_window_component(HTCAPTION);
+ wd.set_window_component(HTCAPTION);
aura::Window* root = Shell::GetPrimaryRootWindow();
aura::test::EventGenerator generator(root, window.get());
- generator.ClickLeftButton();
generator.DoubleClickLeftButton();
EXPECT_NE(restore_bounds.ToString(), window->bounds().ToString());
EXPECT_TRUE(window_state->IsMaximized());
- generator.ClickLeftButton();
generator.DoubleClickLeftButton();
EXPECT_TRUE(window_state->IsNormalStateType());
EXPECT_EQ(restore_bounds.ToString(), window->bounds().ToString());
// 2) Double clicking a horizontally maximized window should maximize.
- delegate.set_window_component(HTLEFT);
- generator.ClickLeftButton();
+ wd.set_window_component(HTLEFT);
generator.DoubleClickLeftButton();
EXPECT_TRUE(window_state->IsNormalStateType());
EXPECT_EQ(work_area_in_parent.x(), window->bounds().x());
@@ -344,12 +341,10 @@
EXPECT_EQ(work_area_in_parent.width(), window->bounds().width());
EXPECT_EQ(restore_bounds.height(), window->bounds().height());
- delegate.set_window_component(HTCAPTION);
- generator.ClickLeftButton();
+ wd.set_window_component(HTCAPTION);
generator.DoubleClickLeftButton();
EXPECT_TRUE(window_state->IsMaximized());
- generator.ClickLeftButton();
generator.DoubleClickLeftButton();
EXPECT_TRUE(window_state->IsNormalStateType());
EXPECT_EQ(restore_bounds.ToString(), window->bounds().ToString());
@@ -359,11 +354,9 @@
window_state->OnWMEvent(&snap_event);
EXPECT_TRUE(window_state->IsSnapped());
generator.MoveMouseTo(window->GetBoundsInRootWindow().CenterPoint());
- generator.ClickLeftButton();
generator.DoubleClickLeftButton();
EXPECT_TRUE(window_state->IsMaximized());
- generator.ClickLeftButton();
generator.DoubleClickLeftButton();
EXPECT_TRUE(window_state->IsNormalStateType());
EXPECT_EQ(restore_bounds.ToString(), window->bounds().ToString());
@@ -373,11 +366,11 @@
// toggle the maximized state.
TEST_F(WorkspaceEventHandlerTest,
DoubleClickMiddleButtonDoesNotToggleMaximize) {
- aura::test::TestWindowDelegate delegate;
+ aura::test::TestWindowDelegate wd;
scoped_ptr<aura::Window> window(
- CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
+ CreateTestWindow(&wd, gfx::Rect(1, 2, 30, 40)));
window->SetProperty(aura::client::kCanMaximizeKey, true);
- delegate.set_window_component(HTCAPTION);
+ wd.set_window_component(HTCAPTION);
aura::Window* root = Shell::GetPrimaryRootWindow();
aura::test::EventGenerator generator(root, window.get());
@@ -402,11 +395,11 @@
}
TEST_F(WorkspaceEventHandlerTest, DoubleTapCaptionTogglesMaximize) {
- aura::test::TestWindowDelegate delegate;
+ aura::test::TestWindowDelegate wd;
gfx::Rect bounds(10, 20, 30, 40);
- scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds));
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
window->SetProperty(aura::client::kCanMaximizeKey, true);
- delegate.set_window_component(HTCAPTION);
+ wd.set_window_component(HTCAPTION);
wm::WindowState* window_state = wm::GetWindowState(window.get());
EXPECT_FALSE(window_state->IsMaximized());
@@ -429,14 +422,14 @@
TEST_F(WorkspaceEventHandlerTest, DeleteWhenDragging) {
// Create a large window in the background. This is necessary so that when we
// delete |window| WorkspaceEventHandler is still the active event handler.
- aura::test::TestWindowDelegate delegate2;
+ aura::test::TestWindowDelegate wd2;
scoped_ptr<aura::Window> window2(
- CreateTestWindow(&delegate2, gfx::Rect(0, 0, 500, 500)));
-
- aura::test::TestWindowDelegate delegate;
+ CreateTestWindow(&wd2, gfx::Rect(0, 0, 500, 500)));
+
+ aura::test::TestWindowDelegate wd;
const gfx::Rect bounds(10, 20, 30, 40);
- scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds));
- delegate.set_window_component(HTCAPTION);
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
+ wd.set_window_component(HTCAPTION);
aura::test::EventGenerator generator(window->GetRootWindow());
generator.MoveMouseToCenterOf(window.get());
generator.PressLeftButton();
@@ -448,10 +441,10 @@
// Verifies deleting the window while in a run loop doesn't crash.
TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) {
- aura::test::TestWindowDelegate delegate;
+ aura::test::TestWindowDelegate wd;
const gfx::Rect bounds(10, 20, 30, 40);
- scoped_ptr<aura::Window> window(CreateTestWindow(&delegate, bounds));
- delegate.set_window_component(HTCAPTION);
+ scoped_ptr<aura::Window> window(CreateTestWindow(&wd, bounds));
+ wd.set_window_component(HTCAPTION);
ASSERT_TRUE(aura::client::GetWindowMoveClient(window->GetRootWindow()));
base::MessageLoop::current()->DeleteSoon(FROM_HERE, window.get());
@@ -461,91 +454,4 @@
aura::client::WINDOW_MOVE_SOURCE_MOUSE);
}
-// Verifies that double clicking in the header does not maximize if the target
-// component has changed.
-TEST_F(WorkspaceEventHandlerTest,
- DoubleClickTwoDifferentTargetsDoesntMaximize) {
- aura::test::TestWindowDelegate delegate;
- scoped_ptr<aura::Window> window(
- CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
- window->SetProperty(aura::client::kCanMaximizeKey, true);
-
- wm::WindowState* window_state = wm::GetWindowState(window.get());
- gfx::Rect restore_bounds = window->bounds();
- gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
- window.get());
-
- EXPECT_FALSE(window_state->IsMaximized());
-
- // First click will go to a client
- delegate.set_window_component(HTCLIENT);
- aura::Window* root = Shell::GetPrimaryRootWindow();
- aura::test::EventGenerator generator(root, window.get());
- generator.ClickLeftButton();
- EXPECT_FALSE(window_state->IsMaximized());
-
- // Second click will go to the header
- delegate.set_window_component(HTCAPTION);
- generator.DoubleClickLeftButton();
- EXPECT_FALSE(window_state->IsMaximized());
-}
-
-// Verifies that double tapping in the header does not maximize if the target
-// component has changed.
-TEST_F(WorkspaceEventHandlerTest, DoubleTapTwoDifferentTargetsDoesntMaximize) {
- aura::test::TestWindowDelegate delegate;
- scoped_ptr<aura::Window> window(
- CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
- window->SetProperty(aura::client::kCanMaximizeKey, true);
-
- wm::WindowState* window_state = wm::GetWindowState(window.get());
- gfx::Rect restore_bounds = window->bounds();
- gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
- window.get());
-
- EXPECT_FALSE(window_state->IsMaximized());
-
- // First tap will go to a client
- delegate.set_window_component(HTCLIENT);
- aura::Window* root = Shell::GetPrimaryRootWindow();
- aura::test::EventGenerator generator(root, window.get());
- generator.GestureTapAt(gfx::Point(25, 25));
- EXPECT_FALSE(window_state->IsMaximized());
-
- // Second tap will go to the header
- delegate.set_window_component(HTCAPTION);
- generator.GestureTapAt(gfx::Point(25, 25));
- EXPECT_FALSE(window_state->IsMaximized());
-}
-
-TEST_F(WorkspaceEventHandlerTest,
- RightClickDuringDoubleClickDoesntMaximize) {
- aura::test::TestWindowDelegate delegate;
- scoped_ptr<aura::Window> window(
- CreateTestWindow(&delegate, gfx::Rect(1, 2, 30, 40)));
- window->SetProperty(aura::client::kCanMaximizeKey, true);
-
- wm::WindowState* window_state = wm::GetWindowState(window.get());
- gfx::Rect restore_bounds = window->bounds();
- gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
- window.get());
-
- EXPECT_FALSE(window_state->IsMaximized());
-
- // First click will go to a client
- delegate.set_window_component(HTCLIENT);
- aura::Window* root = Shell::GetPrimaryRootWindow();
- aura::test::EventGenerator generator(root, window.get());
- generator.ClickLeftButton();
- EXPECT_FALSE(window_state->IsMaximized());
-
- // Second click will go to the header
- delegate.set_window_component(HTCAPTION);
- generator.PressRightButton();
- generator.ReleaseRightButton();
- EXPECT_FALSE(window_state->IsMaximized());
- generator.DoubleClickLeftButton();
- EXPECT_FALSE(window_state->IsMaximized());
-}
-
} // namespace ash
« no previous file with comments | « ash/wm/workspace/workspace_event_handler.cc ('k') | ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698