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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 1900443002: Removes aura dependencies from WindowPositioner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nuke GetWorkAreaForWindowInParent and fix windows Created 4 years, 8 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
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_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"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
13 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/display_manager_test_api.h" 14 #include "ash/test/display_manager_test_api.h"
15 #include "ash/wm/common/window_positioning_utils.h"
15 #include "ash/wm/common/wm_event.h" 16 #include "ash/wm/common/wm_event.h"
16 #include "ash/wm/window_state.h" 17 #include "ash/wm/window_state.h"
17 #include "ash/wm/window_state_aura.h" 18 #include "ash/wm/window_state_aura.h"
18 #include "ash/wm/window_util.h" 19 #include "ash/wm/window_util.h"
19 #include "ash/wm/workspace/phantom_window_controller.h" 20 #include "ash/wm/workspace/phantom_window_controller.h"
20 #include "ash/wm/workspace_controller.h" 21 #include "ash/wm/workspace_controller.h"
21 #include "base/command_line.h" 22 #include "base/command_line.h"
22 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
24 #include "ui/aura/client/aura_constants.h" 25 #include "ui/aura/client/aura_constants.h"
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); 910 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x();
910 int pixels_to_left_border = 50; 911 int pixels_to_left_border = 50;
911 int window_width = 300; 912 int window_width = 300;
912 int window_x = left - window_width + pixels_to_left_border; 913 int window_x = left - window_width + pixels_to_left_border;
913 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); 914 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
914 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( 915 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest(
915 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); 916 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT));
916 ASSERT_TRUE(resizer.get()); 917 ASSERT_TRUE(resizer.get());
917 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); 918 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0);
918 EXPECT_EQ(base::IntToString(window_x) + ",100 " + 919 EXPECT_EQ(base::IntToString(window_x) + ",100 " +
919 base::IntToString(kMinimumOnScreenArea - window_x) + 920 base::IntToString(wm::kMinimumOnScreenArea - window_x) + "x380",
920 "x380", window_->bounds().ToString()); 921 window_->bounds().ToString());
921 } 922 }
922 923
923 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { 924 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) {
924 Shell::GetInstance()->SetDisplayWorkAreaInsets( 925 Shell::GetInstance()->SetDisplayWorkAreaInsets(
925 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 926 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
926 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 927 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
927 window_.get()).right(); 928 window_.get()).right();
928 int pixels_to_right_border = 50; 929 int pixels_to_right_border = 50;
929 int window_width = 300; 930 int window_width = 300;
930 int window_x = right - pixels_to_right_border; 931 int window_x = right - pixels_to_right_border;
931 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); 932 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
932 std::unique_ptr<WindowResizer> resizer( 933 std::unique_ptr<WindowResizer> resizer(
933 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTLEFT)); 934 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTLEFT));
934 ASSERT_TRUE(resizer.get()); 935 ASSERT_TRUE(resizer.get());
935 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); 936 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
936 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + 937 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " +
937 ",100 " + 938 base::IntToString(window_width - pixels_to_right_border +
938 base::IntToString(window_width - pixels_to_right_border + 939 wm::kMinimumOnScreenArea) +
939 kMinimumOnScreenArea) + 940 "x380",
940 "x380", window_->bounds().ToString()); 941 window_->bounds().ToString());
941 } 942 }
942 943
943 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { 944 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) {
944 Shell::GetInstance()->SetDisplayWorkAreaInsets( 945 Shell::GetInstance()->SetDisplayWorkAreaInsets(
945 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 946 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
946 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 947 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
947 window_.get()).bottom(); 948 window_.get()).bottom();
948 int delta_to_bottom = 50; 949 int delta_to_bottom = 50;
949 int height = 380; 950 int height = 380;
950 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); 951 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height));
951 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest( 952 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest(
952 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); 953 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP));
953 ASSERT_TRUE(resizer.get()); 954 ASSERT_TRUE(resizer.get());
954 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); 955 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0);
955 EXPECT_EQ("100," + 956 EXPECT_EQ("100," + base::IntToString(bottom - wm::kMinimumOnScreenArea) +
956 base::IntToString(bottom - kMinimumOnScreenArea) + 957 " 300x" +
957 " 300x" + 958 base::IntToString(height -
958 base::IntToString(height - (delta_to_bottom - 959 (delta_to_bottom - wm::kMinimumOnScreenArea)),
959 kMinimumOnScreenArea)),
960 window_->bounds().ToString()); 960 window_->bounds().ToString());
961 } 961 }
962 962
963 // Verifies that 'outside' check of the resizer take into account the extended 963 // Verifies that 'outside' check of the resizer take into account the extended
964 // desktop in case of repositions. 964 // desktop in case of repositions.
965 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { 965 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) {
966 // Only primary display. Changes the window position to fit within the 966 // Only primary display. Changes the window position to fit within the
967 // display. 967 // display.
968 Shell::GetInstance()->SetDisplayWorkAreaInsets( 968 Shell::GetInstance()->SetDisplayWorkAreaInsets(
969 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 969 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
970 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 970 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
971 window_.get()).right(); 971 window_.get()).right();
972 int pixels_to_right_border = 50; 972 int pixels_to_right_border = 50;
973 int window_width = 300; 973 int window_width = 300;
974 int window_x = right - pixels_to_right_border; 974 int window_x = right - pixels_to_right_border;
975 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); 975 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
976 std::unique_ptr<WindowResizer> resizer( 976 std::unique_ptr<WindowResizer> resizer(
977 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTCAPTION)); 977 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTCAPTION));
978 ASSERT_TRUE(resizer.get()); 978 ASSERT_TRUE(resizer.get());
979 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); 979 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
980 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + 980 EXPECT_EQ(base::IntToString(right - wm::kMinimumOnScreenArea) + ",100 " +
981 ",100 " + 981 base::IntToString(window_width) + "x380",
982 base::IntToString(window_width) + 982 window_->bounds().ToString());
983 "x380", window_->bounds().ToString());
984 983
985 if (!SupportsMultipleDisplays()) 984 if (!SupportsMultipleDisplays())
986 return; 985 return;
987 986
988 // With secondary display. Operation itself is same but doesn't change 987 // With secondary display. Operation itself is same but doesn't change
989 // the position because the window is still within the secondary display. 988 // the position because the window is still within the secondary display.
990 UpdateDisplay("1000x600,600x400"); 989 UpdateDisplay("1000x600,600x400");
991 Shell::GetInstance()->SetDisplayWorkAreaInsets( 990 Shell::GetInstance()->SetDisplayWorkAreaInsets(
992 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 991 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
993 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); 992 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 // Drag even more to snap to the edge. 1884 // Drag even more to snap to the edge.
1886 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1885 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1887 gfx::Point(400, kRootHeight - 25), 1886 gfx::Point(400, kRootHeight - 25),
1888 base::TimeDelta::FromMilliseconds(10), 1887 base::TimeDelta::FromMilliseconds(10),
1889 5); 1888 5);
1890 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1889 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1891 touch_resize_window_->bounds().ToString()); 1890 touch_resize_window_->bounds().ToString());
1892 } 1891 }
1893 1892
1894 } // namespace ash 1893 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.cc ('k') | chrome/browser/ui/ash/window_positioner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698