summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash_switches.cc8
-rw-r--r--ash/ash_switches.h5
-rw-r--r--ash/wm/dock/docked_window_layout_manager.cc4
-rw-r--r--ash/wm/dock/docked_window_layout_manager_unittest.cc4
-rw-r--r--ash/wm/dock/docked_window_resizer_unittest.cc20
-rw-r--r--ash/wm/overview/window_selector_unittest.cc10
-rw-r--r--ash/wm/system_gesture_event_filter_unittest.cc4
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc18
-rw-r--r--ash/wm/workspace/workspace_window_resizer.h7
-rw-r--r--ash/wm/workspace/workspace_window_resizer_unittest.cc372
-rw-r--r--ash/wm/workspace_controller_unittest.cc14
-rw-r--r--chrome/app/generated_resources.grd8
-rw-r--r--chrome/browser/about_flags.cc4
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc4
14 files changed, 247 insertions, 235 deletions
diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc
index df876b7..2cfa6bd 100644
--- a/ash/ash_switches.cc
+++ b/ash/ash_switches.cc
@@ -93,8 +93,8 @@ const char kAshEnableAlternateFrameCaptionButtonStyle[] =
// main monitor as internal.
const char kAshEnableBrightnessControl[] = "ash-enable-brightness-control";
-// Enable the dock area on a desktop.
-const char kAshEnableDockedWindows[] = "ash-enable-docked-windows";
+// Disable ability to dock windows at the desktop edge.
+const char kAshDisableDockedWindows[] = "ash-disable-docked-windows";
// Disable dragging items off the shelf to unpin them.
const char kAshDisableDragOffShelf[] = "ash-disable-drag-off-shelf";
@@ -231,6 +231,10 @@ bool UseOverviewMode() {
return !CommandLine::ForCurrentProcess()->HasSwitch(kAshDisableOverviewMode);
}
+bool UseDockedWindows() {
+ return !CommandLine::ForCurrentProcess()->HasSwitch(kAshDisableDockedWindows);
+}
+
#if defined(OS_CHROMEOS)
bool ShowAudioDeviceMenu() {
return !CommandLine::ForCurrentProcess()->
diff --git a/ash/ash_switches.h b/ash/ash_switches.h
index 5880943..612083b 100644
--- a/ash/ash_switches.h
+++ b/ash/ash_switches.h
@@ -32,6 +32,7 @@ ASH_EXPORT extern const char kAshDisableAudioDeviceMenu[];
ASH_EXPORT extern const char kAshDisableAlternateFrameCaptionButtonStyle[];
ASH_EXPORT extern const char kAshDisableAutoMaximizing[];
ASH_EXPORT extern const char kAshDisableDisplayChangeLimiter[];
+ASH_EXPORT extern const char kAshDisableDockedWindows[];
ASH_EXPORT extern const char kAshDisableDragOffShelf[];
ASH_EXPORT extern const char kAshDisableOverviewMode[];
ASH_EXPORT extern const char kAshDisableDragAndDropAppListToLauncher[];
@@ -42,7 +43,6 @@ ASH_EXPORT extern const char kAshEnableAudioDeviceMenu[];
ASH_EXPORT extern const char kAshEnableAdvancedGestures[];
ASH_EXPORT extern const char kAshEnableAlternateFrameCaptionButtonStyle[];
ASH_EXPORT extern const char kAshEnableBrightnessControl[];
-ASH_EXPORT extern const char kAshEnableDockedWindows[];
#if defined(OS_CHROMEOS)
ASH_EXPORT extern const char kAshEnableFullMultiProfileMode[];
#endif
@@ -91,6 +91,9 @@ ASH_EXPORT bool UseFullMultiProfileMode();
// Returns true if overview mode should be activated for window switching.
ASH_EXPORT bool UseOverviewMode();
+// Returns true if docked windows feature is enabled.
+ASH_EXPORT bool UseDockedWindows();
+
#if defined(OS_CHROMEOS)
// Returns true if new audio handler should be used.
ASH_EXPORT bool UseNewAudioHandler();
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index 36f3b28..f244f1c 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -383,10 +383,8 @@ DockedAlignment DockedWindowLayoutManager::CalculateAlignment() const {
bool DockedWindowLayoutManager::CanDockWindow(aura::Window* window,
SnapType edge) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshEnableDockedWindows)) {
+ if (!switches::UseDockedWindows())
return false;
- }
// Don't allow interactive docking of windows with transient parents such as
// modal browser dialogs.
if (IsPopupOrTransient(window))
diff --git a/ash/wm/dock/docked_window_layout_manager_unittest.cc b/ash/wm/dock/docked_window_layout_manager_unittest.cc
index 6ec585f..4ea9dfc 100644
--- a/ash/wm/dock/docked_window_layout_manager_unittest.cc
+++ b/ash/wm/dock/docked_window_layout_manager_unittest.cc
@@ -46,10 +46,6 @@ class DockedWindowLayoutManagerTest
virtual ~DockedWindowLayoutManagerTest() {}
virtual void SetUp() OVERRIDE {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kAshEnableStickyEdges);
- CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kAshEnableDockedWindows);
AshTestBase::SetUp();
UpdateDisplay("600x600");
ASSERT_TRUE(test::TestLauncherDelegate::instance());
diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc
index d9ac13f..923d31c 100644
--- a/ash/wm/dock/docked_window_resizer_unittest.cc
+++ b/ash/wm/dock/docked_window_resizer_unittest.cc
@@ -43,10 +43,6 @@ class DockedWindowResizerTest
virtual ~DockedWindowResizerTest() {}
virtual void SetUp() OVERRIDE {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kAshEnableStickyEdges);
- CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kAshEnableDockedWindows);
AshTestBase::SetUp();
UpdateDisplay("600x400");
test::ShellTestApi test_api(Shell::GetInstance());
@@ -218,6 +214,10 @@ class DockedWindowResizerTest
return window_type_ == aura::client::WINDOW_TYPE_PANEL;
}
+ const gfx::Point& initial_location_in_parent() const {
+ return initial_location_in_parent_;
+ }
+
private:
scoped_ptr<WindowResizer> resizer_;
LauncherModel* model_;
@@ -322,11 +322,12 @@ TEST_P(DockedWindowResizerTest, AttachLeftUndershoot) {
return;
scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
+ gfx::Rect initial_bounds(window->bounds());
DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 1);
- // The window should be touching the screen edge but not docked.
- EXPECT_EQ(window->GetRootWindow()->bounds().x(),
- window->GetBoundsInScreen().x());
+ // The window should be crossing the screen edge but not docked.
+ int expected_x = initial_bounds.x() - initial_location_in_parent().x() + 1;
+ EXPECT_EQ(expected_x, window->GetBoundsInScreen().x());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
window->parent()->id());
}
@@ -550,6 +551,7 @@ TEST_P(DockedWindowResizerTest, AttachOnTwoSides) {
scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20);
+ gfx::Rect initial_bounds(w2->bounds());
DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w2.get(), 50);
// The first window should be attached and snapped to the right edge.
@@ -559,7 +561,9 @@ TEST_P(DockedWindowResizerTest, AttachOnTwoSides) {
// The second window should be near the left edge but not snapped.
// Normal window will get side-maximized while panels will not.
- EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x());
+ int expected_x = test_panels() ?
+ (initial_bounds.x() - initial_location_in_parent().x()) : 0;
+ EXPECT_EQ(expected_x, w2->GetBoundsInScreen().x());
EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
}
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index ba17961..375b7e4 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -790,8 +790,7 @@ TEST_F(WindowSelectorTest, CycleMultipleDisplaysCopiesWindows) {
unmoved1->SetName("unmoved1");
unmoved2->SetName("unmoved2");
moved1->SetName("moved1");
- moved1->SetProperty(aura::client::kModalKey,
- ui::MODAL_TYPE_WINDOW);
+ moved1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
moved1_trans_parent->AddTransientChild(moved1.get());
moved1_trans_parent->SetName("moved1_trans_parent");
@@ -830,9 +829,10 @@ TEST_F(WindowSelectorTest, CycleMultipleDisplaysCopiesWindows) {
// Verify that the bounds and transform of the copy match the original window
// but that it is on the other root window.
EXPECT_EQ(root_windows[1], copy1->GetRootWindow());
- EXPECT_EQ(moved1->GetBoundsInScreen(), copy1->GetBoundsInScreen());
- EXPECT_EQ(moved1->layer()->GetTargetTransform(),
- copy1->layer()->GetTargetTransform());
+ EXPECT_EQ(moved1->GetBoundsInScreen().ToString(),
+ copy1->GetBoundsInScreen().ToString());
+ EXPECT_EQ(moved1->layer()->GetTargetTransform().ToString(),
+ copy1->layer()->GetTargetTransform().ToString());
StopCycling();
// After cycling the copy windows should have been destroyed.
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index d4edc82..4630d22 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -202,9 +202,9 @@ class SystemGestureEventFilterTest
virtual void SetUp() OVERRIDE {
CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kAshEnableAdvancedGestures);
- if (docked_enabled_) {
+ if (!docked_enabled_) {
CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kAshEnableDockedWindows);
+ ash::switches::kAshDisableDockedWindows);
}
test::AshTestBase::SetUp();
// Enable brightness key.
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 731fcb3..e788b63 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -95,8 +95,7 @@ scoped_ptr<WindowResizer> CreateWindowResizer(
window_resizer = PanelWindowResizer::Create(
window_resizer, window, point_in_parent, window_component, source);
}
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshEnableDockedWindows) &&
+ if (switches::UseDockedWindows() &&
window_resizer && window->parent() &&
!window->transient_parent() &&
(window->parent()->id() == internal::kShellWindowId_DefaultContainer ||
@@ -120,9 +119,8 @@ const int kScreenEdgeInsetForTouchResize = 32;
// Returns true if the window should stick to the edge.
bool ShouldStickToEdge(int distance_from_edge, int sticky_size) {
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshEnableStickyEdges) ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshEnableDockedWindows)) {
+ switches::kAshEnableStickyEdges)) {
+ // TODO(varkha): Consider keeping snapping behavior for touch drag.
return distance_from_edge < 0 &&
distance_from_edge > -sticky_size;
}
@@ -273,6 +271,9 @@ const int WorkspaceWindowResizer::kScreenEdgeInset = 8;
// static
const int WorkspaceWindowResizer::kStickyDistancePixels = 64;
+// static
+WorkspaceWindowResizer* WorkspaceWindowResizer::instance_ = NULL;
+
// Represents the width or height of a window with constraints on its minimum
// and maximum size. 0 represents a lack of a constraint.
class WindowSize {
@@ -345,6 +346,8 @@ class WindowSize {
WorkspaceWindowResizer::~WorkspaceWindowResizer() {
Shell* shell = Shell::GetInstance();
shell->cursor_manager()->UnlockCursor();
+ if (instance_ == this)
+ instance_ = NULL;
}
// static
@@ -367,9 +370,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
if (event_flags & ui::EF_CONTROL_DOWN) {
sticky_size = 0;
} else if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshEnableStickyEdges) ||
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshEnableDockedWindows)) {
+ switches::kAshEnableStickyEdges)) {
sticky_size = kStickyDistancePixels;
} else if ((details_.bounds_change & kBoundsChange_Resizes) &&
details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
@@ -542,6 +543,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
total_initial_size_ += initial_size;
total_available += std::max(min_size, initial_size) - min_size;
}
+ instance_ = this;
}
gfx::Rect WorkspaceWindowResizer::GetFinalBounds(
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index 5acaf8e..1344f57 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -74,9 +74,7 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
const std::vector<aura::Window*>& attached_windows);
private:
- FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom);
- FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomSnapMaxSize);
- FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomWindowShow);
+ friend class WorkspaceWindowResizerTest;
// Returns the final bounds to place the window at. This differs from
// the current when snapping.
@@ -221,6 +219,9 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
// gets dragged into another browser window.
base::WeakPtrFactory<WorkspaceWindowResizer> weak_ptr_factory_;
+ // Current instance for use by the WorkspaceWindowResizerTest.
+ static WorkspaceWindowResizer* instance_;
+
DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer);
};
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index 1e75349..d19a1cf 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -98,9 +98,11 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate {
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
};
+} // namespace
+
class WorkspaceWindowResizerTest : public test::AshTestBase {
public:
- WorkspaceWindowResizerTest() {}
+ WorkspaceWindowResizerTest() : workspace_resizer_(NULL) {}
virtual ~WorkspaceWindowResizerTest() {}
virtual void SetUp() OVERRIDE {
@@ -168,7 +170,24 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
}
protected:
- gfx::Point CalculateDragPoint(const WorkspaceWindowResizer& resizer,
+ WindowResizer* CreateResizerForTest(
+ aura::Window* window,
+ const gfx::Point& point_in_parent,
+ int window_component) {
+ WindowResizer* resizer = CreateWindowResizer(
+ window,
+ point_in_parent,
+ window_component,
+ aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
+ workspace_resizer_ = WorkspaceWindowResizer::instance_;
+ return resizer;
+ }
+
+ PhantomWindowController* snap_phantom_window_controller() const {
+ return workspace_resizer_->snap_phantom_window_controller_.get();
+ }
+
+ gfx::Point CalculateDragPoint(const WindowResizer& resizer,
int delta_x,
int delta_y) const {
gfx::Point location = resizer.GetInitialLocation();
@@ -217,6 +236,7 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
TestWindowDelegate touch_resize_delegate_;
scoped_ptr<aura::Window> touch_resize_window_;
+ WorkspaceWindowResizer* workspace_resizer_;
private:
DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest);
@@ -237,8 +257,6 @@ class WorkspaceWindowResizerTestSticky : public WorkspaceWindowResizerTest {
DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTestSticky);
};
-} // namespace
-
// Assertions around attached window resize dragging from the right with 2
// windows.
TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) {
@@ -541,36 +559,39 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) {
// Assertions around dragging to the left/right edge of the screen.
TEST_F(WorkspaceWindowResizerTest, Edge) {
- int bottom =
- ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
- window_->SetBounds(gfx::Rect(20, 30, 50, 60));
+ // TODO(varkha): Insets are reset after every drag because of
+ // http://crbug.com/292238.
+ // Window is wide enough not to get docked right away.
+ window_->SetBounds(gfx::Rect(20, 30, 400, 60));
wm::WindowState* window_state = wm::GetWindowState(window_.get());
{
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0);
+ int bottom =
+ ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
resizer->CompleteDrag(0);
EXPECT_EQ("0,0 720x" + base::IntToString(bottom),
window_->bounds().ToString());
ASSERT_TRUE(window_state->HasRestoreBounds());
- EXPECT_EQ("20,30 50x60",
+ EXPECT_EQ("20,30 400x60",
window_state->GetRestoreBoundsInScreen().ToString());
}
// Try the same with the right side.
{
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
+ int bottom =
+ ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
resizer->CompleteDrag(0);
EXPECT_EQ("80,0 720x" + base::IntToString(bottom),
window_->bounds().ToString());
ASSERT_TRUE(window_state->HasRestoreBounds());
- EXPECT_EQ("20,30 50x60",
+ EXPECT_EQ("20,30 400x60",
window_state->GetRestoreBoundsInScreen().ToString());
}
@@ -580,29 +601,29 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
if (!SupportsMultipleDisplays())
return;
- UpdateDisplay("800x600,200x600");
+ UpdateDisplay("800x600,500x600");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
EXPECT_EQ(root_windows[0], window_->GetRootWindow());
- window_->SetBoundsInScreen(gfx::Rect(800, 10, 50, 60),
+ // Window is wide enough not to get docked right away.
+ window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60),
ScreenAsh::GetSecondaryDisplay());
EXPECT_EQ(root_windows[1], window_->GetRootWindow());
{
- bottom =
- ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
- EXPECT_EQ("800,10 50x60", window_->GetBoundsInScreen().ToString());
+ EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
-
- resizer->Drag(CalculateDragPoint(*resizer, 199, 00), 0);
+ resizer->Drag(CalculateDragPoint(*resizer, 499, 00), 0);
+ int bottom =
+ ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
resizer->CompleteDrag(0);
- // With the resolution of 200x600 we will hit in this case the 50% screen
+ // With the resolution of 500x600 we will hit in this case the 50% screen
// size setting.
- EXPECT_EQ("100,0 100x" + base::IntToString(bottom),
+ // TODO(varkha): Insets are updated because of http://crbug.com/292238
+ EXPECT_EQ("250,0 250x" + base::IntToString(bottom),
window_->bounds().ToString());
- EXPECT_EQ("800,10 50x60",
+ EXPECT_EQ("800,10 400x60",
window_state->GetRestoreBoundsInScreen().ToString());
}
}
@@ -612,9 +633,8 @@ TEST_F(WorkspaceWindowResizerTest, NonResizableWindows) {
window_->SetBounds(gfx::Rect(20, 30, 50, 60));
window_->SetProperty(aura::client::kCanResizeKey, false);
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0);
resizer->CompleteDrag(0);
@@ -634,21 +654,20 @@ TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) {
EXPECT_EQ(root_windows[0], window_->GetRootWindow());
EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
{
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
- EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_FALSE(snap_phantom_window_controller());
// The pointer is on the edge but not shared. The snap phantom window
// controller should be non-NULL.
resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0);
- EXPECT_TRUE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_TRUE(snap_phantom_window_controller());
// Move the cursor across the edge. Now the snap phantom window controller
// should be canceled.
resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0);
- EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_FALSE(snap_phantom_window_controller());
}
}
@@ -695,9 +714,8 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) {
ASSERT_EQ(1, Shell::GetScreen()->GetNumDisplays());
window_->SetBounds(gfx::Rect(100, 200, 300, 400));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0);
int expected_y =
@@ -725,9 +743,8 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) {
window_->SetBounds(gfx::Rect(100, 200, 300, 20));
DCHECK_LT(window_->bounds().height(),
WorkspaceWindowResizer::kMinOnscreenHeight);
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0);
int expected_y = kRootHeight - window_->bounds().height() - 10;
@@ -736,13 +753,16 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) {
// restricted only by the window height.
EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20",
window_->bounds().ToString());
+ // Revert the drag in order to not remember the restore bounds.
+ resizer->RevertDrag();
}
+ Shell::GetInstance()->SetDisplayWorkAreaInsets(
+ Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0));
{
window_->SetBounds(gfx::Rect(100, 200, 300, 400));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0);
int expected_y =
@@ -751,18 +771,20 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) {
// on non-work area with kMinOnscreenHeight margin.
EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400",
window_->bounds().ToString());
+ resizer->CompleteDrag(0);
}
{
window_->SetBounds(gfx::Rect(100, 200, 300, 400));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), window_->bounds().origin(), HTCAPTION));
ASSERT_TRUE(resizer.get());
- resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0);
+ // Drag down avoiding getting stuck against the shelf on the bottom screen.
+ resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0);
// The window can move to the secondary display beyond non-work area of
// the primary display.
- EXPECT_EQ("100,800 300x400", window_->bounds().ToString());
+ EXPECT_EQ("100,700 300x400", window_->bounds().ToString());
+ resizer->CompleteDrag(0);
}
}
@@ -772,9 +794,8 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) {
Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0));
window_->SetBounds(gfx::Rect(100, 200, 300, 400));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0);
EXPECT_EQ("100,10 300x400", window_->bounds().ToString());
@@ -785,9 +806,8 @@ TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) {
Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
window_->SetBounds(gfx::Rect(100, 200, 300, 380));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOP,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOP));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0);
EXPECT_EQ("100,200 300x380", window_->bounds().ToString());
@@ -801,9 +821,8 @@ TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) {
int window_width = 300;
int window_x = left - window_width + pixels_to_left_border;
window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0);
EXPECT_EQ(base::IntToString(window_x) + ",100 " +
@@ -820,9 +839,8 @@ TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) {
int window_width = 300;
int window_x = right - pixels_to_right_border;
window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(window_x, 0), HTLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(window_x, 0), HTLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) +
@@ -840,9 +858,8 @@ TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) {
int delta_to_bottom = 50;
int height = 380;
window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0);
EXPECT_EQ("100," +
@@ -866,9 +883,8 @@ TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) {
int window_width = 300;
int window_x = right - pixels_to_right_border;
window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(window_x, 0), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(window_x, 0), HTCAPTION));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) +
@@ -899,11 +915,10 @@ TEST_F(WorkspaceWindowResizerTest, SnapToEdge) {
window_->SetBounds(gfx::Rect(96, 112, 320, 160));
// Click 50px to the right so that the mouse pointer does not leave the
// workspace ensuring sticky behavior.
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
window_.get(),
window_->bounds().origin() + gfx::Vector2d(50, 0),
- HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ HTCAPTION));
ASSERT_TRUE(resizer.get());
// Move to an x-coordinate of 15, which should not snap.
resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0);
@@ -968,9 +983,8 @@ TEST_F(WorkspaceWindowResizerTest, SnapToEdge) {
// Verifies a resize snap when dragging TOPLEFT.
TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0);
EXPECT_EQ("0,0 120x230", window_->bounds().ToString());
@@ -981,9 +995,8 @@ TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
window_.get()));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(
CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0);
@@ -998,9 +1011,8 @@ TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
window_.get()));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(
CalculateDragPoint(*resizer, work_area.right() - 120 - 1,
@@ -1016,9 +1028,8 @@ TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
window_.get()));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(
CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0);
@@ -1035,11 +1046,10 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToEdge) {
window_->SetBounds(gfx::Rect(96, 112, 320, 160));
// Click 50px to the right so that the mouse pointer does not leave the
// workspace ensuring sticky behavior.
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
window_.get(),
window_->bounds().origin() + gfx::Vector2d(50, 0),
- HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ HTCAPTION));
ASSERT_TRUE(resizer.get());
// Move to an x-coordinate of 15, which should not stick.
resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0);
@@ -1078,9 +1088,8 @@ TEST_F(WorkspaceWindowResizerTestSticky, NoStickToEdgeWhenOutside) {
Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
window_->SetBounds(gfx::Rect(96, 112, 320, 160));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
// Move to an x-coordinate of 15, which should not stick.
resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0);
@@ -1092,9 +1101,8 @@ TEST_F(WorkspaceWindowResizerTestSticky, NoStickToEdgeWhenOutside) {
// Verifies a resize sticks when dragging TOPLEFT.
TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPLEFT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, -15 -200), 0);
EXPECT_EQ("0,0 120x230", window_->bounds().ToString());
@@ -1105,9 +1113,8 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPRIGHT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
window_.get()));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 + 20,
-200 - 15), 0);
@@ -1122,9 +1129,8 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMRIGHT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
window_.get()));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 - 20 + 15,
work_area.bottom() - 200 - 30 + 15), 0);
@@ -1139,9 +1145,8 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMLEFT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
window_.get()));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, -15 - 100,
work_area.bottom() - 200 - 30 + 15), 0);
@@ -1153,9 +1158,8 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMLEFT) {
TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) {
window_->SetBounds(gfx::Rect(96, 112, 320, 160));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
ASSERT_TRUE(resizer.get());
// Resize the right bottom to add 10 in width, 12 in height.
resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN);
@@ -1165,9 +1169,8 @@ TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) {
TEST_F(WorkspaceWindowResizerTest, CtrlCompleteDragMoveToExactPosition) {
window_->SetBounds(gfx::Rect(96, 112, 320, 160));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
// Ctrl + drag the window to new poistion by adding (10, 12) to its origin,
// the window should move to the exact position.
@@ -1181,9 +1184,8 @@ TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
window_->SetBounds(gfx::Rect(0, 0, 1000, 1000));
wm::WindowState* window_state = wm::GetWindowState(window_.get());
window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
// Drag the window to new position by adding (10, 10) to original point,
// the window should get restored.
@@ -1201,9 +1203,8 @@ TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) {
wm::WindowState* window_state = wm::GetWindowState(window_.get());
window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
// Drag the window to new poistion by adding (180, 16) to original point,
// the window should get restored.
@@ -1220,9 +1221,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyAttach) {
window2_->SetBounds(gfx::Rect(150, 160, 25, 20));
window2_->Show();
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
// Move |window| one pixel to the left of |window2|. Should snap to right and
// top.
@@ -1251,9 +1251,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOP) {
window2_->SetBounds(gfx::Rect(99, 179, 10, 20));
window2_->Show();
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOP,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOP));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("100,199 20x31", window_->bounds().ToString());
@@ -1265,9 +1264,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) {
window2_->Show();
{
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("99,199 21x31", window_->bounds().ToString());
@@ -1276,9 +1274,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) {
{
window2_->SetBounds(gfx::Rect(88, 201, 10, 20));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("98,201 22x29", window_->bounds().ToString());
@@ -1292,9 +1289,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) {
{
window2_->SetBounds(gfx::Rect(111, 179, 10, 20));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("100,199 21x31", window_->bounds().ToString());
@@ -1303,9 +1299,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) {
{
window2_->SetBounds(gfx::Rect(121, 199, 10, 20));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTTOPRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("100,199 21x31", window_->bounds().ToString());
@@ -1318,9 +1313,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_RIGHT) {
window2_->SetBounds(gfx::Rect(121, 199, 10, 20));
window2_->Show();
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("100,200 21x30", window_->bounds().ToString());
@@ -1332,9 +1326,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) {
{
window2_->SetBounds(gfx::Rect(122, 212, 10, 20));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("100,200 22x32", window_->bounds().ToString());
@@ -1343,9 +1336,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) {
{
window2_->SetBounds(gfx::Rect(111, 233, 10, 20));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("100,200 21x33", window_->bounds().ToString());
@@ -1358,9 +1350,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOM) {
window2_->SetBounds(gfx::Rect(111, 233, 10, 20));
window2_->Show();
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOM,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOM));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("100,200 20x33", window_->bounds().ToString());
@@ -1372,9 +1363,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) {
{
window2_->SetBounds(gfx::Rect(99, 231, 10, 20));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("99,200 21x31", window_->bounds().ToString());
@@ -1383,9 +1373,8 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) {
{
window2_->SetBounds(gfx::Rect(89, 209, 10, 20));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("99,200 21x29", window_->bounds().ToString());
@@ -1398,24 +1387,22 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) {
window_->SetBounds(gfx::Rect(100, 200, 20, 30));
window2_->Show();
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTLEFT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTLEFT));
ASSERT_TRUE(resizer.get());
resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
EXPECT_EQ("99,200 21x30", window_->bounds().ToString());
}
// Test that the user user moved window flag is getting properly set.
-TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) {
+TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) {
window_->SetBounds(gfx::Rect( 0, 50, 400, 200));
std::vector<aura::Window*> no_attached_windows;
// Check that an abort doesn't change anything.
{
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, no_attached_windows));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
// Move it 100 to the bottom.
resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0);
@@ -1427,9 +1414,8 @@ TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) {
// Check that a completed move / size does change the user coordinates.
{
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, no_attached_windows));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
// Move it 100 to the bottom.
resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0);
@@ -1444,9 +1430,8 @@ TEST_F(WorkspaceWindowResizerTest, TestMaxSizeEnforced) {
window_->SetBounds(gfx::Rect(0, 0, 400, 300));
delegate_.set_max_size(gfx::Size(401, 301));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
EXPECT_EQ(401, window_->bounds().width());
EXPECT_EQ(301, window_->bounds().height());
@@ -1457,9 +1442,8 @@ TEST_F(WorkspaceWindowResizerTest, TestPartialMaxSizeEnforced) {
window_->SetBounds(gfx::Rect(0, 0, 400, 300));
delegate_.set_max_size(gfx::Size(401, 0));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTBOTTOMRIGHT,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
EXPECT_EQ(401, window_->bounds().width());
EXPECT_EQ(302, window_->bounds().height());
@@ -1470,25 +1454,43 @@ TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) {
{
// With max size not set we get a phantom window controller for dragging off
// the right hand side.
- window_->SetBounds(gfx::Rect(0, 0, 300, 200));
+ // Make the window wider than maximum docked width.
+ window_->SetBounds(gfx::Rect(0, 0, 400, 200));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
- EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
+ EXPECT_FALSE(snap_phantom_window_controller());
resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
- EXPECT_TRUE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_TRUE(snap_phantom_window_controller());
+ resizer->RevertDrag();
}
{
- // With max size defined, we get no phantom window.
- window_->SetBounds(gfx::Rect(0, 0, 300, 200));
- delegate_.set_max_size(gfx::Size(300, 200));
+ // With max size defined, we get no phantom window for snapping but we still
+ // get a phantom window (docking guide).
+ window_->SetBounds(gfx::Rect(0, 0, 400, 200));
+ delegate_.set_max_size(gfx::Size(400, 200));
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
- EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ if (switches::UseDockedWindows())
+ EXPECT_TRUE(snap_phantom_window_controller());
+ else
+ EXPECT_FALSE(snap_phantom_window_controller());
+ resizer->RevertDrag();
+ }
+ {
+ // With max size defined, we get no phantom window for snapping.
+ window_->SetBounds(gfx::Rect(0, 0, 400, 200));
+ delegate_.set_max_size(gfx::Size(400, 200));
+ // With min size defined, we get no phantom window for docking.
+ delegate_.set_min_size(gfx::Size(400, 200));
+
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
+ resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
+ EXPECT_FALSE(snap_phantom_window_controller());
+ resizer->RevertDrag();
}
}
@@ -1877,18 +1879,16 @@ TEST_F(WorkspaceWindowResizerTest, PhantomWindowShow) {
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
EXPECT_EQ(root_windows[0], window_->GetRootWindow());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
- window_.get(), gfx::Point(0,0), HTCAPTION,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTCAPTION));
ASSERT_TRUE(resizer.get());
- EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_FALSE(snap_phantom_window_controller());
// The pointer is on the edge but not shared. The snap phantom window
// controller should be non-NULL.
resizer->Drag(CalculateDragPoint(*resizer, -1, 0), 0);
- EXPECT_TRUE(resizer->snap_phantom_window_controller_.get());
- PhantomWindowController* phantom_controller(
- resizer->snap_phantom_window_controller_.get());
+ EXPECT_TRUE(snap_phantom_window_controller());
+ PhantomWindowController* phantom_controller(snap_phantom_window_controller());
// phantom widget only in the left screen.
phantom_controller->Show(gfx::Rect(100, 100, 50, 60));
diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc
index 14ecd84..48e08fc 100644
--- a/ash/wm/workspace_controller_unittest.cc
+++ b/ash/wm/workspace_controller_unittest.cc
@@ -1232,11 +1232,13 @@ TEST_F(WorkspaceControllerTest, VerifyLayerOrdering) {
namespace {
// Used by DragMaximizedNonTrackedWindow to track how many times the window
-// hierarchy changes.
+// hierarchy changes affecting the specified window.
class DragMaximizedNonTrackedWindowObserver
: public aura::WindowObserver {
public:
- DragMaximizedNonTrackedWindowObserver() : change_count_(0) {
+ DragMaximizedNonTrackedWindowObserver(aura::Window* window)
+ : change_count_(0),
+ window_(window) {
}
// Number of times OnWindowHierarchyChanged() has been received.
@@ -1250,7 +1252,8 @@ class DragMaximizedNonTrackedWindowObserver
// from a docked container which is expected when a tab is dragged.
virtual void OnWindowHierarchyChanged(
const HierarchyChangeParams& params) OVERRIDE {
- if ((params.old_parent->id() == kShellWindowId_DefaultContainer &&
+ if (params.target != window_ ||
+ (params.old_parent->id() == kShellWindowId_DefaultContainer &&
params.new_parent->id() == kShellWindowId_DockedContainer) ||
(params.old_parent->id() == kShellWindowId_DockedContainer &&
params.new_parent->id() == kShellWindowId_DefaultContainer)) {
@@ -1261,6 +1264,7 @@ class DragMaximizedNonTrackedWindowObserver
private:
int change_count_;
+ aura::Window* window_;
DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver);
};
@@ -1286,7 +1290,7 @@ TEST_F(WorkspaceControllerTest, DragFullscreenNonTrackedWindow) {
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
w1->Show();
wm::ActivateWindow(w1.get());
- DragMaximizedNonTrackedWindowObserver observer;
+ DragMaximizedNonTrackedWindowObserver observer(w1.get());
w1->parent()->parent()->AddObserver(&observer);
const gfx::Rect max_bounds(w1->bounds());
@@ -1335,7 +1339,7 @@ TEST_F(WorkspaceControllerTest, DragMaximizedNonTrackedWindow) {
w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
w1->Show();
wm::ActivateWindow(w1.get());
- DragMaximizedNonTrackedWindowObserver observer;
+ DragMaximizedNonTrackedWindowObserver observer(w1.get());
w1->parent()->parent()->AddObserver(&observer);
const gfx::Rect max_bounds(w1->bounds());
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index c7a1dc3..9f3f820 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6535,11 +6535,11 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_SPELLCHECK_AUTOCORRECT_DESCRIPTION" desc="Description for the flag to force synchronous spellchecking.">
Turn on autocorrection of text while typing. Synchronous spellchecking is not compatible with this feature.
</message>
- <message name="IDS_FLAGS_DOCKED_WINDOWS_NAME" desc="Name for the flag to enable docked windows feature.">
- Enable docking of windows near screen edges.
+ <message name="IDS_FLAGS_DOCKED_WINDOWS_NAME" desc="Name for the flag to disable docked windows feature.">
+ Disable docking of windows near screen edges.
</message>
- <message name="IDS_FLAGS_DOCKED_WINDOWS_DESCRIPTION" desc="Description for the flag to enable docked windows feature.">
- Turns on docking of windows near screen edges, a feature that provides an easier way to interact with panel and other small windows.
+ <message name="IDS_FLAGS_DOCKED_WINDOWS_DESCRIPTION" desc="Description for the flag to disable docked windows feature.">
+ Turns off docking of windows near screen edges, a feature that provides an easier way to interact with panel and other small windows.
</message>
<message name="IDS_FLAGS_SHOW_SHELF_ALIGNMENT_MENU_NAME" desc="Name for the flag to show a menu that lets you change the alignment of the shelf.">
Show shelf alignment menu.
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 3a8c6cd..4df6488 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1003,11 +1003,11 @@ const Experiment kExperiments[] = {
SINGLE_VALUE_TYPE(chromeos::switches::kEnableBackgroundLoader)
},
{
- "ash-enable-docked-windows",
+ "ash-disable-docked-windows",
IDS_FLAGS_DOCKED_WINDOWS_NAME,
IDS_FLAGS_DOCKED_WINDOWS_DESCRIPTION,
kOsCrOS,
- SINGLE_VALUE_TYPE(ash::switches::kAshEnableDockedWindows)
+ SINGLE_VALUE_TYPE(ash::switches::kAshDisableDockedWindows)
},
#endif
{
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
index 1e1ea17..8a07bb4 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
@@ -341,9 +341,9 @@ class DetachToBrowserTabDragControllerTest
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(switches::kTabBrowserDragging);
#if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash)
- if (docked_windows_enabled()) {
+ if (!docked_windows_enabled()) {
CommandLine::ForCurrentProcess()->AppendSwitch(
- ash::switches::kAshEnableDockedWindows);
+ ash::switches::kAshDisableDockedWindows);
}
#endif
}