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/ash_constants.h" | 7 #include "ash/ash_constants.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/screen_ash.h" | 11 #include "ash/screen_util.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
16 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
18 #include "ash/wm/workspace/phantom_window_controller.h" | 18 #include "ash/wm/workspace/phantom_window_controller.h" |
19 #include "ash/wm/workspace/snap_sizer.h" | 19 #include "ash/wm/workspace/snap_sizer.h" |
20 #include "ash/wm/workspace_controller.h" | 20 #include "ash/wm/workspace_controller.h" |
21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 return; | 619 return; |
620 | 620 |
621 // Restore the window to clear snapped state. | 621 // Restore the window to clear snapped state. |
622 window_state->Restore(); | 622 window_state->Restore(); |
623 | 623 |
624 UpdateDisplay("800x600,500x600"); | 624 UpdateDisplay("800x600,500x600"); |
625 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 625 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
626 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 626 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
627 // Window is wide enough not to get docked right away. | 627 // Window is wide enough not to get docked right away. |
628 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), | 628 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), |
629 ScreenAsh::GetSecondaryDisplay()); | 629 ScreenUtil::GetSecondaryDisplay()); |
630 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 630 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
631 { | 631 { |
632 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); | 632 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); |
633 | 633 |
634 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 634 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
635 window_.get(), gfx::Point(), HTCAPTION)); | 635 window_.get(), gfx::Point(), HTCAPTION)); |
636 ASSERT_TRUE(resizer.get()); | 636 ASSERT_TRUE(resizer.get()); |
637 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0); | 637 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0); |
638 int bottom = | 638 int bottom = |
639 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 639 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
640 resizer->CompleteDrag(); | 640 resizer->CompleteDrag(); |
641 // With the resolution of 500x600 we will hit in this case the 50% screen | 641 // With the resolution of 500x600 we will hit in this case the 50% screen |
642 // size setting. | 642 // size setting. |
643 // TODO(varkha): Insets are updated because of http://crbug.com/292238 | 643 // TODO(varkha): Insets are updated because of http://crbug.com/292238 |
644 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), | 644 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), |
645 window_->bounds().ToString()); | 645 window_->bounds().ToString()); |
646 EXPECT_EQ("800,10 400x60", | 646 EXPECT_EQ("800,10 400x60", |
647 window_state->GetRestoreBoundsInScreen().ToString()); | 647 window_state->GetRestoreBoundsInScreen().ToString()); |
648 } | 648 } |
649 } | 649 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 831 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
832 window_.get(), gfx::Point(), HTTOP)); | 832 window_.get(), gfx::Point(), HTTOP)); |
833 ASSERT_TRUE(resizer.get()); | 833 ASSERT_TRUE(resizer.get()); |
834 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); | 834 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); |
835 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); | 835 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); |
836 } | 836 } |
837 | 837 |
838 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { | 838 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { |
839 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 839 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
840 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 840 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
841 int left = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); | 841 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); |
842 int pixels_to_left_border = 50; | 842 int pixels_to_left_border = 50; |
843 int window_width = 300; | 843 int window_width = 300; |
844 int window_x = left - window_width + pixels_to_left_border; | 844 int window_x = left - window_width + pixels_to_left_border; |
845 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 845 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
846 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 846 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
847 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); | 847 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); |
848 ASSERT_TRUE(resizer.get()); | 848 ASSERT_TRUE(resizer.get()); |
849 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); | 849 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); |
850 EXPECT_EQ(base::IntToString(window_x) + ",100 " + | 850 EXPECT_EQ(base::IntToString(window_x) + ",100 " + |
851 base::IntToString(kMinimumOnScreenArea - window_x) + | 851 base::IntToString(kMinimumOnScreenArea - window_x) + |
852 "x380", window_->bounds().ToString()); | 852 "x380", window_->bounds().ToString()); |
853 } | 853 } |
854 | 854 |
855 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { | 855 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { |
856 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 856 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
857 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 857 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
858 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 858 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
859 window_.get()).right(); | 859 window_.get()).right(); |
860 int pixels_to_right_border = 50; | 860 int pixels_to_right_border = 50; |
861 int window_width = 300; | 861 int window_width = 300; |
862 int window_x = right - pixels_to_right_border; | 862 int window_x = right - pixels_to_right_border; |
863 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 863 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
864 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 864 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
865 window_.get(), gfx::Point(window_x, 0), HTLEFT)); | 865 window_.get(), gfx::Point(window_x, 0), HTLEFT)); |
866 ASSERT_TRUE(resizer.get()); | 866 ASSERT_TRUE(resizer.get()); |
867 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 867 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
868 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + | 868 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + |
869 ",100 " + | 869 ",100 " + |
870 base::IntToString(window_width - pixels_to_right_border + | 870 base::IntToString(window_width - pixels_to_right_border + |
871 kMinimumOnScreenArea) + | 871 kMinimumOnScreenArea) + |
872 "x380", window_->bounds().ToString()); | 872 "x380", window_->bounds().ToString()); |
873 } | 873 } |
874 | 874 |
875 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { | 875 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { |
876 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 876 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
877 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 877 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
878 int bottom = ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 878 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
879 window_.get()).bottom(); | 879 window_.get()).bottom(); |
880 int delta_to_bottom = 50; | 880 int delta_to_bottom = 50; |
881 int height = 380; | 881 int height = 380; |
882 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); | 882 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); |
883 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 883 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
884 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); | 884 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); |
885 ASSERT_TRUE(resizer.get()); | 885 ASSERT_TRUE(resizer.get()); |
886 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); | 886 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); |
887 EXPECT_EQ("100," + | 887 EXPECT_EQ("100," + |
888 base::IntToString(bottom - kMinimumOnScreenArea) + | 888 base::IntToString(bottom - kMinimumOnScreenArea) + |
889 " 300x" + | 889 " 300x" + |
890 base::IntToString(height - (delta_to_bottom - | 890 base::IntToString(height - (delta_to_bottom - |
891 kMinimumOnScreenArea)), | 891 kMinimumOnScreenArea)), |
892 window_->bounds().ToString()); | 892 window_->bounds().ToString()); |
893 } | 893 } |
894 | 894 |
895 // Verifies that 'outside' check of the resizer take into account the extended | 895 // Verifies that 'outside' check of the resizer take into account the extended |
896 // desktop in case of repositions. | 896 // desktop in case of repositions. |
897 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { | 897 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { |
898 // Only primary display. Changes the window position to fit within the | 898 // Only primary display. Changes the window position to fit within the |
899 // display. | 899 // display. |
900 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 900 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
901 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 901 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
902 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 902 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
903 window_.get()).right(); | 903 window_.get()).right(); |
904 int pixels_to_right_border = 50; | 904 int pixels_to_right_border = 50; |
905 int window_width = 300; | 905 int window_width = 300; |
906 int window_x = right - pixels_to_right_border; | 906 int window_x = right - pixels_to_right_border; |
907 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 907 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
908 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 908 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
909 window_.get(), gfx::Point(window_x, 0), HTCAPTION)); | 909 window_.get(), gfx::Point(window_x, 0), HTCAPTION)); |
910 ASSERT_TRUE(resizer.get()); | 910 ASSERT_TRUE(resizer.get()); |
911 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 911 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
912 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + | 912 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1008 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1009 window_.get(), gfx::Point(), HTTOPLEFT)); | 1009 window_.get(), gfx::Point(), HTTOPLEFT)); |
1010 ASSERT_TRUE(resizer.get()); | 1010 ASSERT_TRUE(resizer.get()); |
1011 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); | 1011 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); |
1012 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); | 1012 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); |
1013 } | 1013 } |
1014 | 1014 |
1015 // Verifies a resize snap when dragging TOPRIGHT. | 1015 // Verifies a resize snap when dragging TOPRIGHT. |
1016 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { | 1016 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { |
1017 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1017 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1018 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1018 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1019 window_.get())); | 1019 window_.get())); |
1020 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1020 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1021 window_.get(), gfx::Point(), HTTOPRIGHT)); | 1021 window_.get(), gfx::Point(), HTTOPRIGHT)); |
1022 ASSERT_TRUE(resizer.get()); | 1022 ASSERT_TRUE(resizer.get()); |
1023 resizer->Drag( | 1023 resizer->Drag( |
1024 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0); | 1024 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0); |
1025 EXPECT_EQ(100, window_->bounds().x()); | 1025 EXPECT_EQ(100, window_->bounds().x()); |
1026 EXPECT_EQ(work_area.y(), window_->bounds().y()); | 1026 EXPECT_EQ(work_area.y(), window_->bounds().y()); |
1027 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1027 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
1028 EXPECT_EQ(230, window_->bounds().height()); | 1028 EXPECT_EQ(230, window_->bounds().height()); |
1029 } | 1029 } |
1030 | 1030 |
1031 // Verifies a resize snap when dragging BOTTOMRIGHT. | 1031 // Verifies a resize snap when dragging BOTTOMRIGHT. |
1032 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { | 1032 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { |
1033 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1033 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1034 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1034 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1035 window_.get())); | 1035 window_.get())); |
1036 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1036 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1037 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1037 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1038 ASSERT_TRUE(resizer.get()); | 1038 ASSERT_TRUE(resizer.get()); |
1039 resizer->Drag( | 1039 resizer->Drag( |
1040 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, | 1040 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, |
1041 work_area.bottom() - 220 - 2), 0); | 1041 work_area.bottom() - 220 - 2), 0); |
1042 EXPECT_EQ(100, window_->bounds().x()); | 1042 EXPECT_EQ(100, window_->bounds().x()); |
1043 EXPECT_EQ(200, window_->bounds().y()); | 1043 EXPECT_EQ(200, window_->bounds().y()); |
1044 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1044 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
1045 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1045 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
1046 } | 1046 } |
1047 | 1047 |
1048 // Verifies a resize snap when dragging BOTTOMLEFT. | 1048 // Verifies a resize snap when dragging BOTTOMLEFT. |
1049 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { | 1049 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { |
1050 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1050 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1051 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1051 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1052 window_.get())); | 1052 window_.get())); |
1053 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1053 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1054 window_.get(), gfx::Point(), HTBOTTOMLEFT)); | 1054 window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
1055 ASSERT_TRUE(resizer.get()); | 1055 ASSERT_TRUE(resizer.get()); |
1056 resizer->Drag( | 1056 resizer->Drag( |
1057 CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0); | 1057 CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0); |
1058 EXPECT_EQ(0, window_->bounds().x()); | 1058 EXPECT_EQ(0, window_->bounds().x()); |
1059 EXPECT_EQ(200, window_->bounds().y()); | 1059 EXPECT_EQ(200, window_->bounds().y()); |
1060 EXPECT_EQ(120, window_->bounds().width()); | 1060 EXPECT_EQ(120, window_->bounds().width()); |
1061 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1061 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1126 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1127 window_.get(), gfx::Point(), HTTOPLEFT)); | 1127 window_.get(), gfx::Point(), HTTOPLEFT)); |
1128 ASSERT_TRUE(resizer.get()); | 1128 ASSERT_TRUE(resizer.get()); |
1129 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, -15 -200), 0); | 1129 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, -15 -200), 0); |
1130 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); | 1130 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); |
1131 } | 1131 } |
1132 | 1132 |
1133 // Verifies a resize sticks when dragging TOPRIGHT. | 1133 // Verifies a resize sticks when dragging TOPRIGHT. |
1134 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPRIGHT) { | 1134 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPRIGHT) { |
1135 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1135 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1136 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1136 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1137 window_.get())); | 1137 window_.get())); |
1138 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1138 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1139 window_.get(), gfx::Point(), HTTOPRIGHT)); | 1139 window_.get(), gfx::Point(), HTTOPRIGHT)); |
1140 ASSERT_TRUE(resizer.get()); | 1140 ASSERT_TRUE(resizer.get()); |
1141 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 + 20, | 1141 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 + 20, |
1142 -200 - 15), 0); | 1142 -200 - 15), 0); |
1143 EXPECT_EQ(100, window_->bounds().x()); | 1143 EXPECT_EQ(100, window_->bounds().x()); |
1144 EXPECT_EQ(work_area.y(), window_->bounds().y()); | 1144 EXPECT_EQ(work_area.y(), window_->bounds().y()); |
1145 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1145 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
1146 EXPECT_EQ(230, window_->bounds().height()); | 1146 EXPECT_EQ(230, window_->bounds().height()); |
1147 } | 1147 } |
1148 | 1148 |
1149 // Verifies a resize snap when dragging BOTTOMRIGHT. | 1149 // Verifies a resize snap when dragging BOTTOMRIGHT. |
1150 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMRIGHT) { | 1150 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMRIGHT) { |
1151 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1151 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1152 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1152 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1153 window_.get())); | 1153 window_.get())); |
1154 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1154 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1155 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); | 1155 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); |
1156 ASSERT_TRUE(resizer.get()); | 1156 ASSERT_TRUE(resizer.get()); |
1157 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 - 20 + 15, | 1157 resizer->Drag(CalculateDragPoint(*resizer, work_area.right() - 100 - 20 + 15, |
1158 work_area.bottom() - 200 - 30 + 15), 0); | 1158 work_area.bottom() - 200 - 30 + 15), 0); |
1159 EXPECT_EQ(100, window_->bounds().x()); | 1159 EXPECT_EQ(100, window_->bounds().x()); |
1160 EXPECT_EQ(200, window_->bounds().y()); | 1160 EXPECT_EQ(200, window_->bounds().y()); |
1161 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); | 1161 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); |
1162 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1162 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
1163 } | 1163 } |
1164 | 1164 |
1165 // Verifies a resize snap when dragging BOTTOMLEFT. | 1165 // Verifies a resize snap when dragging BOTTOMLEFT. |
1166 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMLEFT) { | 1166 TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMLEFT) { |
1167 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); | 1167 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); |
1168 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 1168 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
1169 window_.get())); | 1169 window_.get())); |
1170 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( | 1170 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
1171 window_.get(), gfx::Point(), HTBOTTOMLEFT)); | 1171 window_.get(), gfx::Point(), HTBOTTOMLEFT)); |
1172 ASSERT_TRUE(resizer.get()); | 1172 ASSERT_TRUE(resizer.get()); |
1173 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, | 1173 resizer->Drag(CalculateDragPoint(*resizer, -15 - 100, |
1174 work_area.bottom() - 200 - 30 + 15), 0); | 1174 work_area.bottom() - 200 - 30 + 15), 0); |
1175 EXPECT_EQ(0, window_->bounds().x()); | 1175 EXPECT_EQ(0, window_->bounds().x()); |
1176 EXPECT_EQ(200, window_->bounds().y()); | 1176 EXPECT_EQ(200, window_->bounds().y()); |
1177 EXPECT_EQ(120, window_->bounds().width()); | 1177 EXPECT_EQ(120, window_->bounds().width()); |
1178 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); | 1178 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), | 1874 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), |
1875 gfx::Point(400, kRootHeight - 25), | 1875 gfx::Point(400, kRootHeight - 25), |
1876 base::TimeDelta::FromMilliseconds(10), | 1876 base::TimeDelta::FromMilliseconds(10), |
1877 5); | 1877 5); |
1878 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), | 1878 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), |
1879 touch_resize_window_->bounds().ToString()); | 1879 touch_resize_window_->bounds().ToString()); |
1880 } | 1880 } |
1881 | 1881 |
1882 } // namespace internal | 1882 } // namespace internal |
1883 } // namespace ash | 1883 } // namespace ash |
OLD | NEW |