diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 13:29:37 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 13:29:37 +0000 |
commit | 489cdb18fcfe652146b9af9da6d794c2e9a02e25 (patch) | |
tree | e80ae3b729e743194d9a0cf9c1518e91f5ed549e /ash/wm/toplevel_window_event_handler_unittest.cc | |
parent | ca4b88e1c47918672c14412491c44633605b2ec0 (diff) | |
download | chromium_src-489cdb18fcfe652146b9af9da6d794c2e9a02e25.zip chromium_src-489cdb18fcfe652146b9af9da6d794c2e9a02e25.tar.gz chromium_src-489cdb18fcfe652146b9af9da6d794c2e9a02e25.tar.bz2 |
Refactor SnapSizer now that the --ash-multiple-snap-window-widths flag no longer exists
Notable changes:
Removes the window snapping functionality out of SnapSizer
Introduce SnapSizer::SnapLeftWithDefaultWidth()
SnapSizer::SnapRightWithDefaultWidth()
wm::GetLeftSnappedWindowBoundsInParent()
wm::GetRightSnappedWindowBoundsInParent()
Rename SnapSizer to TwoStepEdgeCycler and strip it down as much as possible. In a future CL I will clean up WorkspaceWindowResizer's use of TwoStepEdgeCycler.
BUG=343276
Review URL: https://codereview.chromium.org/178573002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/toplevel_window_event_handler_unittest.cc')
-rw-r--r-- | ash/wm/toplevel_window_event_handler_unittest.cc | 109 |
1 files changed, 39 insertions, 70 deletions
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc index 5b65e75..506cfd4 100644 --- a/ash/wm/toplevel_window_event_handler_unittest.cc +++ b/ash/wm/toplevel_window_event_handler_unittest.cc @@ -13,7 +13,6 @@ #include "ash/wm/resize_shadow_controller.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" -#include "ash/wm/workspace/snap_sizer.h" #include "ash/wm/workspace_controller.h" #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -411,43 +410,28 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) { gfx::Point end = location; // Snap right; - { - // Get the expected snapped bounds before snapping. - internal::SnapSizer sizer(window_state, location, - internal::SnapSizer::RIGHT_EDGE, - internal::SnapSizer::OTHER_INPUT); - gfx::Rect snapped_bounds = sizer.target_bounds(); - - end.Offset(100, 0); - generator.GestureScrollSequence(location, end, - base::TimeDelta::FromMilliseconds(5), - 10); - RunAllPendingInMessageLoop(); + end.Offset(100, 0); + generator.GestureScrollSequence(location, end, + base::TimeDelta::FromMilliseconds(5), + 10); + RunAllPendingInMessageLoop(); - // Verify that the window has moved after the gesture. - EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); - EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); - } + // Verify that the window has moved after the gesture. + EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); + EXPECT_EQ(wm::SHOW_TYPE_RIGHT_SNAPPED, window_state->window_show_type()); old_bounds = target->bounds(); // Snap left. - { - // Get the expected snapped bounds before snapping. - internal::SnapSizer sizer(window_state, location, - internal::SnapSizer::LEFT_EDGE, - internal::SnapSizer::OTHER_INPUT); - gfx::Rect snapped_bounds = sizer.target_bounds(); - end = location = target->GetBoundsInRootWindow().CenterPoint(); - end.Offset(-100, 0); - generator.GestureScrollSequence(location, end, - base::TimeDelta::FromMilliseconds(5), - 10); - RunAllPendingInMessageLoop(); + end = location = target->GetBoundsInRootWindow().CenterPoint(); + end.Offset(-100, 0); + generator.GestureScrollSequence(location, end, + base::TimeDelta::FromMilliseconds(5), + 10); + RunAllPendingInMessageLoop(); - EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); - EXPECT_EQ(snapped_bounds.ToString(), target->bounds().ToString()); - } + EXPECT_NE(old_bounds.ToString(), target->bounds().ToString()); + EXPECT_EQ(wm::SHOW_TYPE_LEFT_SNAPPED, window_state->window_show_type()); gfx::Rect bounds_before_maximization = target->bounds(); bounds_before_maximization.Offset(0, 100); @@ -553,52 +537,37 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDragForUnresizableWindow) { gfx::Point end = location; // Try to snap right. The window is not resizable. So it should not snap. - { - // Get the expected snapped bounds before the gesture. - internal::SnapSizer sizer(window_state, location, - internal::SnapSizer::RIGHT_EDGE, - internal::SnapSizer::OTHER_INPUT); - gfx::Rect snapped_bounds = sizer.target_bounds(); - - end.Offset(100, 0); - generator.GestureScrollSequence(location, end, - base::TimeDelta::FromMilliseconds(5), - 10); - RunAllPendingInMessageLoop(); + end.Offset(100, 0); + generator.GestureScrollSequence(location, end, + base::TimeDelta::FromMilliseconds(5), + 10); + RunAllPendingInMessageLoop(); - // Verify that the window has moved after the gesture. - gfx::Rect expected_bounds(old_bounds); - expected_bounds.Offset(gfx::Vector2d(100, 0)); - EXPECT_EQ(expected_bounds.ToString(), target->bounds().ToString()); + // Verify that the window has moved after the gesture. + gfx::Rect expected_bounds(old_bounds); + expected_bounds.Offset(gfx::Vector2d(100, 0)); + EXPECT_EQ(expected_bounds.ToString(), target->bounds().ToString()); - // Verify that the window did not snap left. - EXPECT_NE(snapped_bounds.ToString(), target->bounds().ToString()); - } + // Verify that the window did not snap left. + EXPECT_TRUE(window_state->IsNormalShowType()); old_bounds = target->bounds(); // Try to snap left. It should not snap. - { - // Get the expected snapped bounds before the gesture. - internal::SnapSizer sizer(window_state, location, - internal::SnapSizer::LEFT_EDGE, - internal::SnapSizer::OTHER_INPUT); - gfx::Rect snapped_bounds = sizer.target_bounds(); - end = location = target->GetBoundsInRootWindow().CenterPoint(); - end.Offset(-100, 0); - generator.GestureScrollSequence(location, end, - base::TimeDelta::FromMilliseconds(5), - 10); - RunAllPendingInMessageLoop(); + end = location = target->GetBoundsInRootWindow().CenterPoint(); + end.Offset(-100, 0); + generator.GestureScrollSequence(location, end, + base::TimeDelta::FromMilliseconds(5), + 10); + RunAllPendingInMessageLoop(); - // Verify that the window has moved after the gesture. - gfx::Rect expected_bounds(old_bounds); - expected_bounds.Offset(gfx::Vector2d(-100, 0)); - EXPECT_EQ(expected_bounds.ToString(), target->bounds().ToString()); + // Verify that the window has moved after the gesture. + expected_bounds = old_bounds; + expected_bounds.Offset(gfx::Vector2d(-100, 0)); + EXPECT_EQ(expected_bounds.ToString(), target->bounds().ToString()); - // Verify that the window did not snap left. - EXPECT_NE(snapped_bounds.ToString(), target->bounds().ToString()); - } + // Verify that the window did not snap left. + EXPECT_TRUE(window_state->IsNormalShowType()); } // Tests that dragging multiple windows at the same time is not allowed. |