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

Unified Diff: ash/wm/toplevel_window_event_handler_unittest.cc

Issue 11434004: ash: Refactor some code that snaps windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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
« no previous file with comments | « ash/wm/toplevel_window_event_handler.cc ('k') | ash/wm/window_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/toplevel_window_event_handler_unittest.cc
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index 036cabffcc2c5bef86f21841a3f781a78d5f4320..dc9b3a026411e2c3047fad8baad4809fd784c71e 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -404,39 +404,45 @@ TEST_F(ToplevelWindowEventHandlerTest, GestureDrag) {
gfx::Point location(5, 5);
target->SetProperty(aura::client::kCanMaximizeKey, true);
- // Snap right;
gfx::Point end = location;
- 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());
+ // Snap right;
{
+ // Get the expected snapped bounds before snapping.
internal::SnapSizer sizer(target.get(), location,
internal::SnapSizer::RIGHT_EDGE,
internal::SnapSizer::OTHER_INPUT);
- EXPECT_EQ(sizer.target_bounds().ToString(), target->bounds().ToString());
+ gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds());
+
+ 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());
}
old_bounds = target->bounds();
// Snap left.
- 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());
{
+ // Get the expected snapped bounds before snapping.
internal::SnapSizer sizer(target.get(), location,
internal::SnapSizer::LEFT_EDGE,
internal::SnapSizer::OTHER_INPUT);
- EXPECT_EQ(sizer.target_bounds().ToString(), target->bounds().ToString());
+ gfx::Rect snapped_bounds = sizer.GetSnapBounds(target->bounds());
+ 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());
}
old_bounds = target->bounds();
« no previous file with comments | « ash/wm/toplevel_window_event_handler.cc ('k') | ash/wm/window_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698