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

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

Issue 11366215: Prevents windows in chromeos from resizing bigger than their maximum size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DesktopNativeWidgetAura 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
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 47b3c08f282a2bcf830b20a530e83102a4f5b014..d8570ee6d471c6410f03d63e49e64bf831fe32c0 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -46,13 +46,22 @@ class TestWindowDelegate : public aura::test::TestWindowDelegate {
min_size_ = size;
}
+ void set_max_size(const gfx::Size& size) {
+ max_size_ = size;
+ }
+
private:
// Overridden from aura::Test::TestWindowDelegate:
virtual gfx::Size GetMinimumSize() const OVERRIDE {
return min_size_;
}
+ virtual gfx::Size GetMaximumSize() const OVERRIDE {
+ return max_size_;
+ }
+
gfx::Size min_size_;
+ gfx::Size max_size_;
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
};
@@ -1465,5 +1474,54 @@ TEST_F(WorkspaceWindowResizerTest, CheckUserWindowMangedFlags) {
}
}
+// Test that a window with a specified max size doesn't exceed it when dragged.
+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, empty_windows()));
+ resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
+ EXPECT_EQ(401, window_->bounds().width());
+ EXPECT_EQ(301, window_->bounds().height());
+}
+
+// Test that a window with a specified max width doesn't restrict its height.
+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, empty_windows()));
+ resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
+ EXPECT_EQ(401, window_->bounds().width());
+ EXPECT_EQ(302, window_->bounds().height());
+}
+
+// Test that a window with a specified max size can't be snapped.
+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));
+
+ scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
+ EXPECT_TRUE(resizer->snap_phantom_window_controller_.get());
+ }
+ {
+ // 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));
+
+ scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
+ resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ }
+}
+
} // namespace internal
} // namespace ash
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.cc ('k') | chrome/browser/ui/views/extensions/shell_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698