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

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
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager2.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"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "ash/wm/property_util.h" 13 #include "ash/wm/property_util.h"
14 #include "ash/wm/shelf_layout_manager.h" 14 #include "ash/wm/shelf_layout_manager.h"
15 #include "ash/wm/workspace_controller.h" 15 #include "ash/wm/workspace_controller.h"
16 #include "ash/wm/workspace/snap_sizer.h" 16 #include "ash/wm/workspace/snap_sizer.h"
17 #include "ash/wm/workspace/phantom_window_controller.h" 17 #include "ash/wm/workspace/phantom_window_controller.h"
18 #include "ash/wm/workspace/workspace_layout_manager2.h"
18 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
19 #include "base/stringprintf.h" 20 #include "base/stringprintf.h"
20 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
21 #include "ui/aura/test/test_window_delegate.h" 22 #include "ui/aura/test/test_window_delegate.h"
22 #include "ui/base/hit_test.h" 23 #include "ui/base/hit_test.h"
23 #include "ui/gfx/insets.h" 24 #include "ui/gfx/insets.h"
24 #include "ui/gfx/screen.h" 25 #include "ui/gfx/screen.h"
25 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
26 27
27 namespace ash { 28 namespace ash {
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 839 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
839 840
840 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); 841 window_->SetBounds(gfx::Rect(100, 200, 300, 380));
841 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 842 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
842 window_.get(), gfx::Point(), HTTOP, empty_windows())); 843 window_.get(), gfx::Point(), HTTOP, empty_windows()));
843 ASSERT_TRUE(resizer.get()); 844 ASSERT_TRUE(resizer.get());
844 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); 845 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0);
845 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); 846 EXPECT_EQ("100,200 300x380", window_->bounds().ToString());
846 } 847 }
847 848
849 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) {
850 Shell::GetInstance()->SetDisplayWorkAreaInsets(
851 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
852 int left = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).x();
853 int pixels_to_left_border = 50;
854 int window_width = 300;
855 int window_x = left - window_width + pixels_to_left_border;
856 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
857 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
858 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT,
859 empty_windows()));
860 ASSERT_TRUE(resizer.get());
861 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0);
862 EXPECT_EQ(base::IntToString(window_x) + ",100 " +
863 base::IntToString(kMinimumOnScreenArea - window_x) +
864 "x380", window_->bounds().ToString());
865 }
866
867 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) {
868 Shell::GetInstance()->SetDisplayWorkAreaInsets(
869 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
870 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent(
871 window_.get()).right();
872 int pixels_to_right_border = 50;
873 int window_width = 300;
874 int window_x = right - pixels_to_right_border;
875 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
876 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
877 window_.get(), gfx::Point(window_x, 0), HTLEFT,
878 empty_windows()));
879 ASSERT_TRUE(resizer.get());
880 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
881 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) +
882 ",100 " +
883 base::IntToString(window_width - pixels_to_right_border +
884 kMinimumOnScreenArea) +
885 "x380", window_->bounds().ToString());
886 }
887
888 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) {
889 Shell::GetInstance()->SetDisplayWorkAreaInsets(
890 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
891 int bottom = ScreenAsh::GetDisplayWorkAreaBoundsInParent(
892 window_.get()).bottom();
893 int delta_to_bottom = 50;
894 int height = 380;
895 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height));
896 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
897 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP,
898 empty_windows()));
899 ASSERT_TRUE(resizer.get());
900 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0);
901 EXPECT_EQ("100," +
902 base::IntToString(bottom - kMinimumOnScreenArea) +
903 " 300x" +
904 base::IntToString(height - (delta_to_bottom -
905 kMinimumOnScreenArea)),
906 window_->bounds().ToString());
907 }
908
848 // Verifies snapping to edges works. 909 // Verifies snapping to edges works.
849 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { 910 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) {
850 Shell::GetInstance()->SetShelfAutoHideBehavior( 911 Shell::GetInstance()->SetShelfAutoHideBehavior(
851 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 912 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
852 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); 913 window_->SetBounds(gfx::Rect(96, 112, 320, 160));
853 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 914 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
854 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 915 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
855 ASSERT_TRUE(resizer.get()); 916 ASSERT_TRUE(resizer.get());
856 // Move to an x-coordinate of 15, which should not snap. 917 // Move to an x-coordinate of 15, which should not snap.
857 resizer->Drag(CalculateDragPoint(*resizer, -81, 0), 0); 918 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); 1063 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0);
1003 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); 1064 EXPECT_EQ("152,130 20x30", window_->bounds().ToString());
1004 1065
1005 // Move |window| one pixel above the bottom of |window2|. 1066 // Move |window| one pixel above the bottom of |window2|.
1006 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); 1067 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0);
1007 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); 1068 EXPECT_EQ("152,180 20x30", window_->bounds().ToString());
1008 } 1069 }
1009 1070
1010 } // namespace internal 1071 } // namespace internal
1011 } // namespace ash 1072 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698