Index: ash/wm/workspace/workspace_window_resizer_unittest.cc |
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc |
index a0a8561f51e7ad676b0b71758201827669367994..6773ac1c2dbf99d84d36f4ffc14801beee86b5eb 100644 |
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc |
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc |
@@ -4,6 +4,7 @@ |
#include "ash/wm/workspace/workspace_window_resizer.h" |
+#include "ash/ash_constants.h" |
#include "ash/ash_switches.h" |
#include "ash/display/display_controller.h" |
#include "ash/root_window_controller.h" |
@@ -22,6 +23,7 @@ |
#include "base/strings/string_number_conversions.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/root_window.h" |
+#include "ui/aura/test/event_generator.h" |
#include "ui/aura/test/test_window_delegate.h" |
#include "ui/base/hit_test.h" |
#include "ui/gfx/insets.h" |
@@ -113,6 +115,7 @@ class WorkspaceWindowResizerTest : public test::AshTestBase { |
window2_.reset(); |
window3_.reset(); |
window4_.reset(); |
+ touch_resize_window_.reset(); |
AshTestBase::TearDown(); |
} |
@@ -151,6 +154,22 @@ class WorkspaceWindowResizerTest : public test::AshTestBase { |
return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
} |
+ void InitTouchResizeWindow(const gfx::Rect& bounds, int window_component) { |
+ touch_resize_delegate_.set_window_component(window_component); |
+ touch_resize_window_.reset( |
+ CreateTestWindowInShellWithDelegate(&touch_resize_delegate_, 0, |
+ bounds)); |
+ gfx::Insets mouse_insets = gfx::Insets(-ash::kResizeOutsideBoundsSize, |
+ -ash::kResizeOutsideBoundsSize, |
+ -ash::kResizeOutsideBoundsSize, |
+ -ash::kResizeOutsideBoundsSize); |
+ gfx::Insets touch_insets = mouse_insets.Scale( |
+ ash::kResizeOutsideBoundsScaleForTouch); |
+ touch_resize_window_->SetHitTestBoundsOverrideOuter(mouse_insets, |
+ touch_insets); |
+ touch_resize_window_->set_hit_test_bounds_override_inner(mouse_insets); |
+ } |
+ |
TestWindowDelegate delegate_; |
TestWindowDelegate delegate2_; |
TestWindowDelegate delegate3_; |
@@ -160,6 +179,9 @@ class WorkspaceWindowResizerTest : public test::AshTestBase { |
scoped_ptr<aura::Window> window3_; |
scoped_ptr<aura::Window> window4_; |
+ TestWindowDelegate touch_resize_delegate_; |
+ scoped_ptr<aura::Window> touch_resize_window_; |
+ |
private: |
DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); |
}; |
@@ -1605,5 +1627,154 @@ TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { |
EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
} |
+// The following variants test that windows are resized correctly to the edges |
+// of the screen using touch, when touch point is off of the window border. |
+TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_RIGHT) { |
+ shelf_layout_manager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
+ |
+ InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTRIGHT); |
+ int expected_height = kRootHeight - 200; |
+ EXPECT_EQ("100,100 600x" + base::IntToString(expected_height), |
sadrul
2013/06/04 19:17:24
This is better done using gfx::Rect(100, 100, 600,
mohsen
2013/06/04 19:30:08
What about directly comparing the gfx::Rects, inst
sadrul
2013/06/04 19:42:46
Direct Rect-comparisons don't show human-readable
mohsen
2013/06/04 20:13:33
I see. Done.
|
+ touch_resize_window_->bounds().ToString()); |
+ |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
+ touch_resize_window_.get()); |
+ |
+ // Drag out of the right border and resize leftward. |
+ generator.GestureScrollSequence(gfx::Point(720, kRootHeight / 2), |
+ gfx::Point(670, kRootHeight / 2), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 200; |
+ EXPECT_EQ("100,100 550x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ // Drag out of the right border and resize rightward. |
+ generator.GestureScrollSequence(gfx::Point(670, kRootHeight / 2), |
+ gfx::Point(770, kRootHeight / 2), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 200; |
+ EXPECT_EQ("100,100 666x" + base::IntToString(expected_height), |
sadrul
2013/06/04 19:17:24
Why should the height change when dragging towards
mohsen
2013/06/04 19:30:08
The height is not changing. It just depends on kRo
sadrul
2013/06/04 19:42:46
I mean in line 1656
mohsen
2013/06/04 20:13:33
I'm talking about the same line! The height of the
|
+ touch_resize_window_->bounds().ToString()); |
+ // Drag the right border and resize rightward to snap. |
+ generator.GestureScrollSequence(gfx::Point(766, kRootHeight / 2), |
+ gfx::Point(785, kRootHeight / 2), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 200; |
+ EXPECT_EQ("100,100 700x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+} |
+ |
+TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_LEFT) { |
+ shelf_layout_manager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
+ |
+ InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTLEFT); |
+ int expected_height = kRootHeight - 200; |
+ EXPECT_EQ("100,100 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
+ touch_resize_window_.get()); |
+ |
+ // Drag out of the left border and resize rightward. |
+ generator.GestureScrollSequence(gfx::Point(80, kRootHeight / 2), |
+ gfx::Point(130, kRootHeight / 2), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 200; |
+ EXPECT_EQ("150,100 550x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ // Drag out of the left border and resize leftward. |
+ generator.GestureScrollSequence(gfx::Point(130, kRootHeight / 2), |
+ gfx::Point(30, kRootHeight / 2), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 200; |
+ EXPECT_EQ("34,100 666x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ // Drag the left border and resize leftward to snap. |
+ generator.GestureScrollSequence(gfx::Point(34, kRootHeight / 2), |
+ gfx::Point(15, kRootHeight / 2), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 200; |
+ EXPECT_EQ("0,100 700x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+} |
+ |
+TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_TOP) { |
+ shelf_layout_manager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
+ |
+ InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTTOP); |
+ int expected_height = kRootHeight - 200; |
+ EXPECT_EQ("100,100 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
+ touch_resize_window_.get()); |
+ |
+ // Drag out of the top border and resize downward. |
+ generator.GestureScrollSequence(gfx::Point(400, 80), |
+ gfx::Point(400, 130), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 250; |
+ EXPECT_EQ("100,150 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ // Drag out of the top border and resize upward. |
+ generator.GestureScrollSequence(gfx::Point(400, 130), |
+ gfx::Point(400, 30), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 134; |
+ EXPECT_EQ("100,34 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ // Drag the top border and resize upward to snap. |
+ generator.GestureScrollSequence(gfx::Point(400, 34), |
+ gfx::Point(400, 15), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 100; |
+ EXPECT_EQ("100,0 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+} |
+ |
+TEST_F(WorkspaceWindowResizerTest, TouchResizeToEdge_BOTTOM) { |
+ shelf_layout_manager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
+ |
+ InitTouchResizeWindow(gfx::Rect(100, 100, 600, kRootHeight - 200), HTBOTTOM); |
+ int expected_height = kRootHeight - 200; |
+ EXPECT_EQ("100,100 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ |
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
+ touch_resize_window_.get()); |
+ |
+ // Drag out of the bottom border and resize upward. |
+ generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 80), |
+ gfx::Point(400, kRootHeight - 130), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 250; |
+ EXPECT_EQ("100,100 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ // Drag out of the bottom border and resize downward. |
+ generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 130), |
+ gfx::Point(400, kRootHeight - 30), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 134; |
+ EXPECT_EQ("100,100 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+ // Drag the bottom border and resize downward to snap. |
+ generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 34), |
+ gfx::Point(400, kRootHeight - 15), |
+ base::TimeDelta::FromMilliseconds(100), |
+ 1); |
+ expected_height = kRootHeight - 100; |
+ EXPECT_EQ("100,100 600x" + base::IntToString(expected_height), |
+ touch_resize_window_->bounds().ToString()); |
+} |
} // namespace internal |
} // namespace ash |