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

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

Issue 11087037: Dont allow the user to 'resize a window out of the workarea' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed the 10 pixel overhang. Created 8 years, 2 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
« ash/wm/window_resizer.cc ('K') | « ash/wm/window_resizer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 67f29fb2fb1c290940c0a9dc4c69c1270027e64d..4c96e57c736d9db061f821654d12941faddf16d1 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -845,6 +845,66 @@ TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) {
EXPECT_EQ("100,200 300x380", window_->bounds().ToString());
}
+TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) {
+ Shell::GetInstance()->SetDisplayWorkAreaInsets(
+ Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
+ int left = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).x();
+ int pixels_to_left_border = 50;
+ 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,
+ empty_windows()));
+ ASSERT_TRUE(resizer.get());
+ resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0);
+ EXPECT_EQ(base::IntToString(window_x) + ",100 " +
+ base::IntToString(WindowResizer::kMinimumOnScreenSize - window_x) +
+ "x380", window_->bounds().ToString());
+}
+
+TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) {
+ Shell::GetInstance()->SetDisplayWorkAreaInsets(
+ Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
+ int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent(
+ window_.get()).right();
+ int pixels_to_right_border = 50;
+ 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,
+ empty_windows()));
+ ASSERT_TRUE(resizer.get());
+ resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
+ EXPECT_EQ(base::IntToString(right - WindowResizer::kMinimumOnScreenSize) +
+ ",100 " +
+ base::IntToString(window_width - pixels_to_right_border +
+ WindowResizer::kMinimumOnScreenSize) +
+ "x380", window_->bounds().ToString());
+}
+
+TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) {
+ Shell::GetInstance()->SetDisplayWorkAreaInsets(
+ Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
+ int bottom = ScreenAsh::GetDisplayWorkAreaBoundsInParent(
+ window_.get()).bottom();
+ 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,
+ empty_windows()));
+ ASSERT_TRUE(resizer.get());
+ resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0);
+ EXPECT_EQ("100," +
+ base::IntToString(bottom - WindowResizer::kMinimumOnScreenSize) +
+ " 300x" +
+ base::IntToString(height - (delta_to_bottom -
+ WindowResizer::kMinimumOnScreenSize)),
+ window_->bounds().ToString());
+}
+
// Verifies snapping to edges works.
TEST_F(WorkspaceWindowResizerTest, SnapToEdge) {
Shell::GetInstance()->SetShelfAutoHideBehavior(
« ash/wm/window_resizer.cc ('K') | « ash/wm/window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698