OLD | NEW |
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_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ->set_max_touch_move_in_pixels_for_click(0); | 76 ->set_max_touch_move_in_pixels_for_click(0); |
77 | 77 |
78 aura::Window* root = Shell::GetPrimaryRootWindow(); | 78 aura::Window* root = Shell::GetPrimaryRootWindow(); |
79 gfx::Rect root_bounds(root->bounds()); | 79 gfx::Rect root_bounds(root->bounds()); |
80 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
81 // RootWindow and Display can't resize on Windows Ash. | 81 // RootWindow and Display can't resize on Windows Ash. |
82 // http://crbug.com/165962 | 82 // http://crbug.com/165962 |
83 EXPECT_EQ(kRootHeight, root_bounds.height()); | 83 EXPECT_EQ(kRootHeight, root_bounds.height()); |
84 #endif | 84 #endif |
85 EXPECT_EQ(800, root_bounds.width()); | 85 EXPECT_EQ(800, root_bounds.width()); |
86 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 86 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, |
| 87 gfx::Insets()); |
87 window_.reset(new aura::Window(&delegate_)); | 88 window_.reset(new aura::Window(&delegate_)); |
88 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 89 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
89 window_->Init(ui::LAYER_NOT_DRAWN); | 90 window_->Init(ui::LAYER_NOT_DRAWN); |
90 ParentWindowInPrimaryRootWindow(window_.get()); | 91 ParentWindowInPrimaryRootWindow(window_.get()); |
91 window_->set_id(1); | 92 window_->set_id(1); |
92 | 93 |
93 window2_.reset(new aura::Window(&delegate2_)); | 94 window2_.reset(new aura::Window(&delegate2_)); |
94 window2_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 95 window2_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
95 window2_->Init(ui::LAYER_NOT_DRAWN); | 96 window2_->Init(ui::LAYER_NOT_DRAWN); |
96 ParentWindowInPrimaryRootWindow(window2_.get()); | 97 ParentWindowInPrimaryRootWindow(window2_.get()); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 #define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3 | 428 #define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3 |
428 #else | 429 #else |
429 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 | 430 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 |
430 #endif | 431 #endif |
431 | 432 |
432 // Assertions around attached window resize dragging from the bottom with 3 | 433 // Assertions around attached window resize dragging from the bottom with 3 |
433 // windows. | 434 // windows. |
434 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { | 435 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { |
435 UpdateDisplay("600x800"); | 436 UpdateDisplay("600x800"); |
436 aura::Window* root = Shell::GetPrimaryRootWindow(); | 437 aura::Window* root = Shell::GetPrimaryRootWindow(); |
437 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 438 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
438 | 439 |
439 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); | 440 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); |
440 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); | 441 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); |
441 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); | 442 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); |
442 delegate2_.set_min_size(gfx::Size(50, 52)); | 443 delegate2_.set_min_size(gfx::Size(50, 52)); |
443 delegate3_.set_min_size(gfx::Size(50, 38)); | 444 delegate3_.set_min_size(gfx::Size(50, 38)); |
444 | 445 |
445 std::vector<aura::Window*> windows; | 446 std::vector<aura::Window*> windows; |
446 windows.push_back(window2_.get()); | 447 windows.push_back(window2_.get()); |
447 windows.push_back(window3_.get()); | 448 windows.push_back(window3_.get()); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // Move it 100 to the right, which should expand w1 and push w2 and w3. | 786 // Move it 100 to the right, which should expand w1 and push w2 and w3. |
786 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); | 787 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); |
787 | 788 |
788 // 2 should be topmost since it's initially the highest in the stack. | 789 // 2 should be topmost since it's initially the highest in the stack. |
789 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); | 790 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); |
790 } | 791 } |
791 } | 792 } |
792 | 793 |
793 // Makes sure we don't allow dragging below the work area. | 794 // Makes sure we don't allow dragging below the work area. |
794 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { | 795 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { |
795 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 796 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
796 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 797 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
797 | 798 |
798 ASSERT_EQ(1, Shell::GetScreen()->GetNumDisplays()); | 799 ASSERT_EQ(1, Shell::GetScreen()->GetNumDisplays()); |
799 | 800 |
800 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 801 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
801 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 802 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
802 window_.get(), gfx::Point(), HTCAPTION)); | 803 window_.get(), gfx::Point(), HTCAPTION)); |
803 ASSERT_TRUE(resizer.get()); | 804 ASSERT_TRUE(resizer.get()); |
804 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); | 805 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); |
805 int expected_y = | 806 int expected_y = |
806 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 807 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
807 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 808 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
808 window_->bounds().ToString()); | 809 window_->bounds().ToString()); |
809 } | 810 } |
810 | 811 |
811 // Makes sure we don't allow dragging on the work area with multidisplay. | 812 // Makes sure we don't allow dragging on the work area with multidisplay. |
812 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { | 813 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { |
813 if (!SupportsMultipleDisplays()) | 814 if (!SupportsMultipleDisplays()) |
814 return; | 815 return; |
815 | 816 |
816 UpdateDisplay("800x600,800x600"); | 817 UpdateDisplay("800x600,800x600"); |
817 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 818 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); |
818 | 819 |
819 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 820 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
820 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 821 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
821 | 822 |
822 // Positions the secondary display at the bottom the primary display. | 823 // Positions the secondary display at the bottom the primary display. |
823 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 824 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
824 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); | 825 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); |
825 | 826 |
826 { | 827 { |
827 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); | 828 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); |
828 DCHECK_LT(window_->bounds().height(), | 829 DCHECK_LT(window_->bounds().height(), |
829 WorkspaceWindowResizer::kMinOnscreenHeight); | 830 WorkspaceWindowResizer::kMinOnscreenHeight); |
830 // Drag down avoiding dragging along the edge as that would side-snap. | 831 // Drag down avoiding dragging along the edge as that would side-snap. |
831 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 832 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
832 window_.get(), gfx::Point(10, 0), HTCAPTION)); | 833 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
833 ASSERT_TRUE(resizer.get()); | 834 ASSERT_TRUE(resizer.get()); |
834 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 835 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
835 int expected_y = kRootHeight - window_->bounds().height() - 10; | 836 int expected_y = kRootHeight - window_->bounds().height() - 10; |
836 // When the mouse cursor is in the primary display, the window cannot move | 837 // When the mouse cursor is in the primary display, the window cannot move |
837 // on non-work area but can get all the way towards the bottom, | 838 // on non-work area but can get all the way towards the bottom, |
838 // restricted only by the window height. | 839 // restricted only by the window height. |
839 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", | 840 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", |
840 window_->bounds().ToString()); | 841 window_->bounds().ToString()); |
841 // Revert the drag in order to not remember the restore bounds. | 842 // Revert the drag in order to not remember the restore bounds. |
842 resizer->RevertDrag(); | 843 resizer->RevertDrag(); |
843 } | 844 } |
844 | 845 |
845 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 846 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
846 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 847 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
847 { | 848 { |
848 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 849 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
849 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 850 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
850 window_.get(), gfx::Point(10, 0), HTCAPTION)); | 851 window_.get(), gfx::Point(10, 0), HTCAPTION)); |
851 ASSERT_TRUE(resizer.get()); | 852 ASSERT_TRUE(resizer.get()); |
852 // Drag down avoiding dragging along the edge as that would side-snap. | 853 // Drag down avoiding dragging along the edge as that would side-snap. |
853 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); | 854 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); |
854 int expected_y = | 855 int expected_y = |
855 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 856 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
(...skipping 13 matching lines...) Expand all Loading... |
869 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); | 870 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); |
870 // The window can move to the secondary display beyond non-work area of | 871 // The window can move to the secondary display beyond non-work area of |
871 // the primary display. | 872 // the primary display. |
872 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); | 873 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); |
873 resizer->CompleteDrag(); | 874 resizer->CompleteDrag(); |
874 } | 875 } |
875 } | 876 } |
876 | 877 |
877 // Makes sure we don't allow dragging off the top of the work area. | 878 // Makes sure we don't allow dragging off the top of the work area. |
878 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { | 879 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { |
879 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 880 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
880 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); | 881 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); |
881 | 882 |
882 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); | 883 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); |
883 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 884 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
884 window_.get(), gfx::Point(), HTCAPTION)); | 885 window_.get(), gfx::Point(), HTCAPTION)); |
885 ASSERT_TRUE(resizer.get()); | 886 ASSERT_TRUE(resizer.get()); |
886 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); | 887 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); |
887 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); | 888 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); |
888 } | 889 } |
889 | 890 |
890 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { | 891 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { |
891 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 892 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
892 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 893 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
893 | 894 |
894 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); | 895 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); |
895 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 896 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
896 window_.get(), gfx::Point(), HTTOP)); | 897 window_.get(), gfx::Point(), HTTOP)); |
897 ASSERT_TRUE(resizer.get()); | 898 ASSERT_TRUE(resizer.get()); |
898 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); | 899 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); |
899 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); | 900 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); |
900 } | 901 } |
901 | 902 |
902 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { | 903 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { |
903 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 904 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
904 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 905 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
905 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); | 906 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); |
906 int pixels_to_left_border = 50; | 907 int pixels_to_left_border = 50; |
907 int window_width = 300; | 908 int window_width = 300; |
908 int window_x = left - window_width + pixels_to_left_border; | 909 int window_x = left - window_width + pixels_to_left_border; |
909 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 910 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
910 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 911 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
911 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); | 912 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); |
912 ASSERT_TRUE(resizer.get()); | 913 ASSERT_TRUE(resizer.get()); |
913 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); | 914 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); |
914 EXPECT_EQ(base::IntToString(window_x) + ",100 " + | 915 EXPECT_EQ(base::IntToString(window_x) + ",100 " + |
915 base::IntToString(kMinimumOnScreenArea - window_x) + | 916 base::IntToString(kMinimumOnScreenArea - window_x) + |
916 "x380", window_->bounds().ToString()); | 917 "x380", window_->bounds().ToString()); |
917 } | 918 } |
918 | 919 |
919 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { | 920 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { |
920 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 921 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
921 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 922 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
922 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 923 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
923 window_.get()).right(); | 924 window_.get()).right(); |
924 int pixels_to_right_border = 50; | 925 int pixels_to_right_border = 50; |
925 int window_width = 300; | 926 int window_width = 300; |
926 int window_x = right - pixels_to_right_border; | 927 int window_x = right - pixels_to_right_border; |
927 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 928 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
928 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 929 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
929 window_.get(), gfx::Point(window_x, 0), HTLEFT)); | 930 window_.get(), gfx::Point(window_x, 0), HTLEFT)); |
930 ASSERT_TRUE(resizer.get()); | 931 ASSERT_TRUE(resizer.get()); |
931 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 932 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
932 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + | 933 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + |
933 ",100 " + | 934 ",100 " + |
934 base::IntToString(window_width - pixels_to_right_border + | 935 base::IntToString(window_width - pixels_to_right_border + |
935 kMinimumOnScreenArea) + | 936 kMinimumOnScreenArea) + |
936 "x380", window_->bounds().ToString()); | 937 "x380", window_->bounds().ToString()); |
937 } | 938 } |
938 | 939 |
939 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { | 940 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { |
940 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 941 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
941 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 942 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
942 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 943 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
943 window_.get()).bottom(); | 944 window_.get()).bottom(); |
944 int delta_to_bottom = 50; | 945 int delta_to_bottom = 50; |
945 int height = 380; | 946 int height = 380; |
946 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); | 947 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); |
947 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 948 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
948 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); | 949 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); |
949 ASSERT_TRUE(resizer.get()); | 950 ASSERT_TRUE(resizer.get()); |
950 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); | 951 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); |
951 EXPECT_EQ("100," + | 952 EXPECT_EQ("100," + |
952 base::IntToString(bottom - kMinimumOnScreenArea) + | 953 base::IntToString(bottom - kMinimumOnScreenArea) + |
953 " 300x" + | 954 " 300x" + |
954 base::IntToString(height - (delta_to_bottom - | 955 base::IntToString(height - (delta_to_bottom - |
955 kMinimumOnScreenArea)), | 956 kMinimumOnScreenArea)), |
956 window_->bounds().ToString()); | 957 window_->bounds().ToString()); |
957 } | 958 } |
958 | 959 |
959 // Verifies that 'outside' check of the resizer take into account the extended | 960 // Verifies that 'outside' check of the resizer take into account the extended |
960 // desktop in case of repositions. | 961 // desktop in case of repositions. |
961 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { | 962 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { |
962 // Only primary display. Changes the window position to fit within the | 963 // Only primary display. Changes the window position to fit within the |
963 // display. | 964 // display. |
964 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 965 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
965 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 966 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
966 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( | 967 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
967 window_.get()).right(); | 968 window_.get()).right(); |
968 int pixels_to_right_border = 50; | 969 int pixels_to_right_border = 50; |
969 int window_width = 300; | 970 int window_width = 300; |
970 int window_x = right - pixels_to_right_border; | 971 int window_x = right - pixels_to_right_border; |
971 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 972 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
972 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 973 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
973 window_.get(), gfx::Point(window_x, 0), HTCAPTION)); | 974 window_.get(), gfx::Point(window_x, 0), HTCAPTION)); |
974 ASSERT_TRUE(resizer.get()); | 975 ASSERT_TRUE(resizer.get()); |
975 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 976 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
976 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + | 977 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + |
977 ",100 " + | 978 ",100 " + |
978 base::IntToString(window_width) + | 979 base::IntToString(window_width) + |
979 "x380", window_->bounds().ToString()); | 980 "x380", window_->bounds().ToString()); |
980 | 981 |
981 if (!SupportsMultipleDisplays()) | 982 if (!SupportsMultipleDisplays()) |
982 return; | 983 return; |
983 | 984 |
984 // With secondary display. Operation itself is same but doesn't change | 985 // With secondary display. Operation itself is same but doesn't change |
985 // the position because the window is still within the secondary display. | 986 // the position because the window is still within the secondary display. |
986 UpdateDisplay("1000x600,600x400"); | 987 UpdateDisplay("1000x600,600x400"); |
987 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 988 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting( |
988 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 989 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
989 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 990 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
990 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 991 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
991 EXPECT_EQ(base::IntToString(window_x + window_width) + | 992 EXPECT_EQ(base::IntToString(window_x + window_width) + |
992 ",100 " + | 993 ",100 " + |
993 base::IntToString(window_width) + | 994 base::IntToString(window_width) + |
994 "x380", window_->bounds().ToString()); | 995 "x380", window_->bounds().ToString()); |
995 } | 996 } |
996 | 997 |
997 // Verifies snapping to edges works. | 998 // Verifies snapping to edges works. |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 window_.get(), gfx::Point(), HTCAPTION)); | 1510 window_.get(), gfx::Point(), HTCAPTION)); |
1510 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); | 1511 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); |
1511 EXPECT_FALSE(snap_phantom_window_controller()); | 1512 EXPECT_FALSE(snap_phantom_window_controller()); |
1512 resizer->RevertDrag(); | 1513 resizer->RevertDrag(); |
1513 } | 1514 } |
1514 } | 1515 } |
1515 | 1516 |
1516 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { | 1517 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { |
1517 UpdateDisplay("600x800"); | 1518 UpdateDisplay("600x800"); |
1518 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1519 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1519 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1520 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1520 | 1521 |
1521 // Four 100x100 windows flush against eachother, starting at 100,100. | 1522 // Four 100x100 windows flush against eachother, starting at 100,100. |
1522 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1523 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1523 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1524 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1524 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1525 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1525 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1526 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1526 delegate2_.set_max_size(gfx::Size(101, 0)); | 1527 delegate2_.set_max_size(gfx::Size(101, 0)); |
1527 | 1528 |
1528 std::vector<aura::Window*> windows; | 1529 std::vector<aura::Window*> windows; |
1529 windows.push_back(window2_.get()); | 1530 windows.push_back(window2_.get()); |
(...skipping 10 matching lines...) Expand all Loading... |
1540 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1541 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1541 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1542 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1542 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); | 1543 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); |
1543 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); | 1544 EXPECT_EQ("250,100 125x100", window3_->bounds().ToString()); |
1544 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); | 1545 EXPECT_EQ("375,100 125x100", window4_->bounds().ToString()); |
1545 } | 1546 } |
1546 | 1547 |
1547 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) { | 1548 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) { |
1548 UpdateDisplay("600x800"); | 1549 UpdateDisplay("600x800"); |
1549 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1550 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1550 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1551 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1551 | 1552 |
1552 // Four 100x100 windows flush against eachother, starting at 100,100. | 1553 // Four 100x100 windows flush against eachother, starting at 100,100. |
1553 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1554 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1554 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1555 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1555 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1556 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1556 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); | 1557 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); |
1557 delegate2_.set_max_size(gfx::Size(101, 0)); | 1558 delegate2_.set_max_size(gfx::Size(101, 0)); |
1558 delegate3_.set_max_size(gfx::Size(101, 0)); | 1559 delegate3_.set_max_size(gfx::Size(101, 0)); |
1559 | 1560 |
1560 std::vector<aura::Window*> windows; | 1561 std::vector<aura::Window*> windows; |
1561 windows.push_back(window2_.get()); | 1562 windows.push_back(window2_.get()); |
1562 windows.push_back(window3_.get()); | 1563 windows.push_back(window3_.get()); |
1563 windows.push_back(window4_.get()); | 1564 windows.push_back(window4_.get()); |
1564 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1565 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1565 window_.get(), gfx::Point(), HTRIGHT, | 1566 window_.get(), gfx::Point(), HTRIGHT, |
1566 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1567 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1567 ASSERT_TRUE(resizer.get()); | 1568 ASSERT_TRUE(resizer.get()); |
1568 // Move it 52 to the left, which should contract w1 and expand w2-4. | 1569 // Move it 52 to the left, which should contract w1 and expand w2-4. |
1569 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); | 1570 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); |
1570 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); | 1571 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); |
1571 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); | 1572 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); |
1572 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); | 1573 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); |
1573 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); | 1574 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); |
1574 } | 1575 } |
1575 | 1576 |
1576 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { | 1577 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { |
1577 UpdateDisplay("600x800"); | 1578 UpdateDisplay("600x800"); |
1578 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1579 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1579 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1580 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1580 | 1581 |
1581 // Four 100x100 windows flush against eachother, starting at 100,100. | 1582 // Four 100x100 windows flush against eachother, starting at 100,100. |
1582 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1583 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1583 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1584 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1584 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1585 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1585 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1586 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1586 delegate2_.set_max_size(gfx::Size(0, 101)); | 1587 delegate2_.set_max_size(gfx::Size(0, 101)); |
1587 delegate3_.set_max_size(gfx::Size(0, 101)); | 1588 delegate3_.set_max_size(gfx::Size(0, 101)); |
1588 | 1589 |
1589 std::vector<aura::Window*> windows; | 1590 std::vector<aura::Window*> windows; |
(...skipping 15 matching lines...) Expand all Loading... |
1605 #if defined(OS_WIN) | 1606 #if defined(OS_WIN) |
1606 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 1607 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
1607 #define MAYBE_DontExceedMinHeight DISABLED_DontExceedMinHeight | 1608 #define MAYBE_DontExceedMinHeight DISABLED_DontExceedMinHeight |
1608 #else | 1609 #else |
1609 #define MAYBE_DontExceedMinHeight DontExceedMinHeight | 1610 #define MAYBE_DontExceedMinHeight DontExceedMinHeight |
1610 #endif | 1611 #endif |
1611 | 1612 |
1612 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) { | 1613 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) { |
1613 UpdateDisplay("600x500"); | 1614 UpdateDisplay("600x500"); |
1614 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1615 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1615 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1616 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1616 | 1617 |
1617 // Four 100x100 windows flush against eachother, starting at 100,100. | 1618 // Four 100x100 windows flush against eachother, starting at 100,100. |
1618 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1619 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1619 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); | 1620 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); |
1620 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); | 1621 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); |
1621 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); | 1622 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); |
1622 delegate2_.set_min_size(gfx::Size(0, 99)); | 1623 delegate2_.set_min_size(gfx::Size(0, 99)); |
1623 delegate3_.set_min_size(gfx::Size(0, 99)); | 1624 delegate3_.set_min_size(gfx::Size(0, 99)); |
1624 | 1625 |
1625 std::vector<aura::Window*> windows; | 1626 std::vector<aura::Window*> windows; |
1626 windows.push_back(window2_.get()); | 1627 windows.push_back(window2_.get()); |
1627 windows.push_back(window3_.get()); | 1628 windows.push_back(window3_.get()); |
1628 windows.push_back(window4_.get()); | 1629 windows.push_back(window4_.get()); |
1629 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1630 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1630 window_.get(), gfx::Point(), HTBOTTOM, | 1631 window_.get(), gfx::Point(), HTBOTTOM, |
1631 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1632 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1632 ASSERT_TRUE(resizer.get()); | 1633 ASSERT_TRUE(resizer.get()); |
1633 // Move it 52 down, which should expand w1 and contract w2-4. | 1634 // Move it 52 down, which should expand w1 and contract w2-4. |
1634 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); | 1635 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); |
1635 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); | 1636 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); |
1636 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); | 1637 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); |
1637 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); | 1638 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); |
1638 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); | 1639 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); |
1639 } | 1640 } |
1640 | 1641 |
1641 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { | 1642 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { |
1642 UpdateDisplay("600x800"); | 1643 UpdateDisplay("600x800"); |
1643 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1644 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1644 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1645 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1645 | 1646 |
1646 // Three 100x100 windows flush against eachother, starting at 100,100. | 1647 // Three 100x100 windows flush against eachother, starting at 100,100. |
1647 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1648 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1648 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1649 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1649 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1650 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1650 delegate3_.set_max_size(gfx::Size(101, 0)); | 1651 delegate3_.set_max_size(gfx::Size(101, 0)); |
1651 | 1652 |
1652 std::vector<aura::Window*> windows; | 1653 std::vector<aura::Window*> windows; |
1653 windows.push_back(window2_.get()); | 1654 windows.push_back(window2_.get()); |
1654 windows.push_back(window3_.get()); | 1655 windows.push_back(window3_.get()); |
1655 windows.push_back(window4_.get()); | 1656 windows.push_back(window4_.get()); |
1656 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1657 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1657 window_.get(), gfx::Point(), HTRIGHT, | 1658 window_.get(), gfx::Point(), HTRIGHT, |
1658 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1659 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1659 ASSERT_TRUE(resizer.get()); | 1660 ASSERT_TRUE(resizer.get()); |
1660 // Move it 51 to the left, which should contract w1 and expand w2-3. | 1661 // Move it 51 to the left, which should contract w1 and expand w2-3. |
1661 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); | 1662 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); |
1662 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); | 1663 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); |
1663 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); | 1664 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); |
1664 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1665 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1665 } | 1666 } |
1666 | 1667 |
1667 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { | 1668 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { |
1668 UpdateDisplay("600x800"); | 1669 UpdateDisplay("600x800"); |
1669 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1670 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1670 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1671 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1671 | 1672 |
1672 // Three 100x100 windows flush against eachother, starting at 100,100. | 1673 // Three 100x100 windows flush against eachother, starting at 100,100. |
1673 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1674 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1674 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1675 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1675 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1676 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1676 delegate2_.set_max_size(gfx::Size(101, 0)); | 1677 delegate2_.set_max_size(gfx::Size(101, 0)); |
1677 delegate3_.set_max_size(gfx::Size(101, 0)); | 1678 delegate3_.set_max_size(gfx::Size(101, 0)); |
1678 | 1679 |
1679 std::vector<aura::Window*> windows; | 1680 std::vector<aura::Window*> windows; |
1680 windows.push_back(window2_.get()); | 1681 windows.push_back(window2_.get()); |
(...skipping 13 matching lines...) Expand all Loading... |
1694 #if defined(OS_WIN) | 1695 #if defined(OS_WIN) |
1695 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 1696 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
1696 #define MAYBE_MainWindowHonoursMaxWidth DISABLED_MainWindowHonoursMaxWidth | 1697 #define MAYBE_MainWindowHonoursMaxWidth DISABLED_MainWindowHonoursMaxWidth |
1697 #else | 1698 #else |
1698 #define MAYBE_MainWindowHonoursMaxWidth MainWindowHonoursMaxWidth | 1699 #define MAYBE_MainWindowHonoursMaxWidth MainWindowHonoursMaxWidth |
1699 #endif | 1700 #endif |
1700 | 1701 |
1701 TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) { | 1702 TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) { |
1702 UpdateDisplay("400x800"); | 1703 UpdateDisplay("400x800"); |
1703 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1704 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1704 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1705 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1705 | 1706 |
1706 // Three 100x100 windows flush against eachother, starting at 100,100. | 1707 // Three 100x100 windows flush against eachother, starting at 100,100. |
1707 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1708 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1708 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1709 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1709 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1710 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1710 delegate_.set_max_size(gfx::Size(102, 0)); | 1711 delegate_.set_max_size(gfx::Size(102, 0)); |
1711 | 1712 |
1712 std::vector<aura::Window*> windows; | 1713 std::vector<aura::Window*> windows; |
1713 windows.push_back(window2_.get()); | 1714 windows.push_back(window2_.get()); |
1714 windows.push_back(window3_.get()); | 1715 windows.push_back(window3_.get()); |
1715 windows.push_back(window4_.get()); | 1716 windows.push_back(window4_.get()); |
1716 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( | 1717 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( |
1717 window_.get(), gfx::Point(), HTRIGHT, | 1718 window_.get(), gfx::Point(), HTRIGHT, |
1718 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); | 1719 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); |
1719 ASSERT_TRUE(resizer.get()); | 1720 ASSERT_TRUE(resizer.get()); |
1720 // Move it 50 to the right, which should expand w1 and contract w2-3, as they | 1721 // Move it 50 to the right, which should expand w1 and contract w2-3, as they |
1721 // won't fit in the root window in their original sizes. | 1722 // won't fit in the root window in their original sizes. |
1722 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); | 1723 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); |
1723 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); | 1724 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); |
1724 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); | 1725 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); |
1725 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); | 1726 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); |
1726 } | 1727 } |
1727 | 1728 |
1728 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { | 1729 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { |
1729 UpdateDisplay("400x800"); | 1730 UpdateDisplay("400x800"); |
1730 aura::Window* root = Shell::GetPrimaryRootWindow(); | 1731 aura::Window* root = Shell::GetPrimaryRootWindow(); |
1731 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); | 1732 Shell::GetInstance()->SetDisplayWorkAreaInsetsForTesting(root, gfx::Insets()); |
1732 | 1733 |
1733 // Three 100x100 windows flush against eachother, starting at 100,100. | 1734 // Three 100x100 windows flush against eachother, starting at 100,100. |
1734 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); | 1735 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); |
1735 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); | 1736 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); |
1736 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); | 1737 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); |
1737 delegate_.set_min_size(gfx::Size(98, 0)); | 1738 delegate_.set_min_size(gfx::Size(98, 0)); |
1738 | 1739 |
1739 std::vector<aura::Window*> windows; | 1740 std::vector<aura::Window*> windows; |
1740 windows.push_back(window2_.get()); | 1741 windows.push_back(window2_.get()); |
1741 windows.push_back(window3_.get()); | 1742 windows.push_back(window3_.get()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 // Drag even more to snap to the edge. | 1883 // Drag even more to snap to the edge. |
1883 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), | 1884 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), |
1884 gfx::Point(400, kRootHeight - 25), | 1885 gfx::Point(400, kRootHeight - 25), |
1885 base::TimeDelta::FromMilliseconds(10), | 1886 base::TimeDelta::FromMilliseconds(10), |
1886 5); | 1887 5); |
1887 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), | 1888 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), |
1888 touch_resize_window_->bounds().ToString()); | 1889 touch_resize_window_->bounds().ToString()); |
1889 } | 1890 } |
1890 | 1891 |
1891 } // namespace ash | 1892 } // namespace ash |
OLD | NEW |