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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« ash/wm/window_resizer.cc ('K') | « ash/wm/window_resizer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/mouse_cursor_event_filter.h" 8 #include "ash/display/mouse_cursor_event_filter.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 838 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
839 839
840 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); 840 window_->SetBounds(gfx::Rect(100, 200, 300, 380));
841 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 841 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
842 window_.get(), gfx::Point(), HTTOP, empty_windows())); 842 window_.get(), gfx::Point(), HTTOP, empty_windows()));
843 ASSERT_TRUE(resizer.get()); 843 ASSERT_TRUE(resizer.get());
844 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); 844 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0);
845 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); 845 EXPECT_EQ("100,200 300x380", window_->bounds().ToString());
846 } 846 }
847 847
848 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) {
849 Shell::GetInstance()->SetDisplayWorkAreaInsets(
850 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
851 int left = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).x();
852 int pixels_to_left_border = 50;
853 int window_width = 300;
854 int window_x = left - window_width + pixels_to_left_border;
855 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
856 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
857 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT,
858 empty_windows()));
859 ASSERT_TRUE(resizer.get());
860 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0);
861 EXPECT_EQ(base::IntToString(window_x) + ",100 " +
862 base::IntToString(WindowResizer::kMinimumOnScreenSize - window_x) +
863 "x380", window_->bounds().ToString());
864 }
865
866 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) {
867 Shell::GetInstance()->SetDisplayWorkAreaInsets(
868 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
869 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent(
870 window_.get()).right();
871 int pixels_to_right_border = 50;
872 int window_width = 300;
873 int window_x = right - pixels_to_right_border;
874 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
875 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
876 window_.get(), gfx::Point(window_x, 0), HTLEFT,
877 empty_windows()));
878 ASSERT_TRUE(resizer.get());
879 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
880 EXPECT_EQ(base::IntToString(right - WindowResizer::kMinimumOnScreenSize) +
881 ",100 " +
882 base::IntToString(window_width - pixels_to_right_border +
883 WindowResizer::kMinimumOnScreenSize) +
884 "x380", window_->bounds().ToString());
885 }
886
887 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) {
888 Shell::GetInstance()->SetDisplayWorkAreaInsets(
889 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
890 int bottom = ScreenAsh::GetDisplayWorkAreaBoundsInParent(
891 window_.get()).bottom();
892 int delta_to_bottom = 50;
893 int height = 380;
894 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height));
895 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
896 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP,
897 empty_windows()));
898 ASSERT_TRUE(resizer.get());
899 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0);
900 EXPECT_EQ("100," +
901 base::IntToString(bottom - WindowResizer::kMinimumOnScreenSize) +
902 " 300x" +
903 base::IntToString(height - (delta_to_bottom -
904 WindowResizer::kMinimumOnScreenSize)),
905 window_->bounds().ToString());
906 }
907
848 // Verifies snapping to edges works. 908 // Verifies snapping to edges works.
849 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { 909 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) {
850 Shell::GetInstance()->SetShelfAutoHideBehavior( 910 Shell::GetInstance()->SetShelfAutoHideBehavior(
851 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 911 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
852 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); 912 window_->SetBounds(gfx::Rect(96, 112, 320, 160));
853 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 913 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
854 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 914 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
855 ASSERT_TRUE(resizer.get()); 915 ASSERT_TRUE(resizer.get());
856 // Move to an x-coordinate of 15, which should not snap. 916 // Move to an x-coordinate of 15, which should not snap.
857 resizer->Drag(CalculateDragPoint(*resizer, -81, 0), 0); 917 resizer->Drag(CalculateDragPoint(*resizer, -81, 0), 0);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); 1062 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0);
1003 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); 1063 EXPECT_EQ("152,130 20x30", window_->bounds().ToString());
1004 1064
1005 // Move |window| one pixel above the bottom of |window2|. 1065 // Move |window| one pixel above the bottom of |window2|.
1006 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); 1066 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0);
1007 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); 1067 EXPECT_EQ("152,180 20x30", window_->bounds().ToString());
1008 } 1068 }
1009 1069
1010 } // namespace internal 1070 } // namespace internal
1011 } // namespace ash 1071 } // namespace ash
OLDNEW
« 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