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

Unified Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 424463002: Makes a window that has been resized to maximized bounds, then maximized and then restored shrink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Maximizes a window that has been resized to maximized bounds (added a test) Created 6 years, 5 months 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
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 9fae0c950b5ec02b1feb6efb66f0ee286cc665fb..91264d200969a4075dac5067f2246995bb69d5a1 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -420,6 +420,72 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) {
EXPECT_EQ("0,250 200x100", window2_->bounds().ToString());
}
+// Tests that resizing a window to maximized bounds (or even close to them with
+// magnetism) maximizes the window.
+TEST_F(WorkspaceWindowResizerTest, WindowResizedToMaximizedBoundsIsMaximized) {
+ window_->SetBounds(gfx::Rect(100, 200, 20, 30));
+ window_->SetProperty(aura::client::kCanMaximizeKey, true);
+ {
+ // Resize |window_| to fit top left corner. Magnetism will adjust it to fit
+ // the corner exactly.
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTTOPLEFT));
+ ASSERT_TRUE(resizer.get());
+ resizer->Drag(CalculateDragPoint(*resizer, -100 + 2, -200 + 2), 0);
+ resizer->CompleteDrag();
+ }
+ gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent(
+ window_.get());
+ {
+ // Resize |window_| to fit bottom right corner. Magnetism will adjust it to
+ // fit the corner exactly.
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(), HTBOTTOMRIGHT));
+ ASSERT_TRUE(resizer.get());
+ gfx::Rect bounds = window_->bounds();
+ resizer->Drag(
+ CalculateDragPoint(*resizer,
+ maximized_bounds.right() - bounds.right() - 2,
+ maximized_bounds.bottom() - bounds.bottom() - 2), 0);
+ resizer->CompleteDrag();
+ }
+ // The window should be maximized and should have restore bounds set to its
+ // previous bounds.
+ EXPECT_EQ(maximized_bounds.ToString(), window_->bounds().ToString());
+ wm::WindowState* window_state = wm::GetWindowState(window_.get());
+ EXPECT_TRUE(window_state->IsMaximized());
+ ASSERT_TRUE(window_state->HasRestoreBounds());
+ EXPECT_EQ("0,0 120x230", window_state->GetRestoreBoundsInScreen().ToString());
+}
+
+// Tests that dragging a window that has maximized size to top left screen
+// corner maximizes the window.
+TEST_F(WorkspaceWindowResizerTest, WindowDraggedToMaximizedBoundsIsMaximized) {
+ // Force an initial layout.
+ Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
+ LayoutShelf();
+ gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent(
+ window_.get());
+ window_->SetBounds(gfx::Rect(gfx::Point(20, 30), maximized_bounds.size()));
+ window_->SetProperty(aura::client::kCanMaximizeKey, true);
+ // Grab a window and drag it to the top left corner. Do not grab too close to
+ // the window origin to avoid snapping.
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
+ window_.get(), gfx::Point(40, 5), HTCAPTION));
+ ASSERT_TRUE(resizer.get());
+ resizer->Drag(CalculateDragPoint(*resizer, -20, -30), 0);
+ resizer->CompleteDrag();
+
+ // The window should be maximized and should have restore bounds set to its
+ // previous bounds.
+ EXPECT_EQ(maximized_bounds.ToString(), window_->bounds().ToString());
+ wm::WindowState* window_state = wm::GetWindowState(window_.get());
+ EXPECT_TRUE(window_state->IsMaximized());
+ ASSERT_TRUE(window_state->HasRestoreBounds());
+ EXPECT_EQ("20,30 " + maximized_bounds.size().ToString(),
+ window_state->GetRestoreBoundsInScreen().ToString());
+}
+
#if defined(OS_WIN)
// RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
#define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3

Powered by Google App Engine
This is Rietveld 408576698