| 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..23de0c90c2e8de780a8dd1cc39aef492aebb2d90 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,138 @@ 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 550, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 666, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 700, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(150, 100, 550, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(34, 100, 666, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(0, 100, 700, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 150, 600, kRootHeight - 250).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 34, 600, kRootHeight - 134).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 0, 600, kRootHeight - 100).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 200).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 250).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 134).ToString(),
|
| + 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);
|
| + EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
|
| + touch_resize_window_->bounds().ToString());
|
| +}
|
| } // namespace internal
|
| } // namespace ash
|
|
|