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

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 comments 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..4ff4658168c883306f88227354800665664b505e 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,42 @@ 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 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

Powered by Google App Engine
This is Rietveld 408576698