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

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

Issue 23471004: Only support left/right maximizing at 50% width when the --ash-enable-alternate-caption-button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
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/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_controller.h" 9 #include "ash/display/display_controller.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); 538 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString());
539 } 539 }
540 540
541 541
542 // Assertions around dragging to the left/right edge of the screen. 542 // Assertions around dragging to the left/right edge of the screen.
543 TEST_F(WorkspaceWindowResizerTest, Edge) { 543 TEST_F(WorkspaceWindowResizerTest, Edge) {
544 int bottom = 544 int bottom =
545 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); 545 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
546 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); 546 window_->SetBounds(gfx::Rect(20, 30, 50, 60));
547 { 547 {
548 // Construct a SnapSizer to get the expected bounds when snapped left.
549 internal::SnapSizer sizer(window_.get(),
550 gfx::Point(),
551 internal::SnapSizer::LEFT_EDGE,
552 internal::SnapSizer::STEP_NO);
553
548 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 554 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
549 window_.get(), gfx::Point(), HTCAPTION, 555 window_.get(), gfx::Point(), HTCAPTION,
550 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 556 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
551 ASSERT_TRUE(resizer.get()); 557 ASSERT_TRUE(resizer.get());
552 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); 558 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0);
553 resizer->CompleteDrag(0); 559 resizer->CompleteDrag(0);
554 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), 560 EXPECT_EQ(sizer.target_bounds().ToString(),
555 window_->bounds().ToString()); 561 window_->bounds().ToString());
556 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); 562 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get()));
557 EXPECT_EQ("20,30 50x60", 563 EXPECT_EQ("20,30 50x60",
558 GetRestoreBoundsInScreen(window_.get())->ToString()); 564 GetRestoreBoundsInScreen(window_.get())->ToString());
559 } 565 }
560 // Try the same with the right side. 566 // Try the same with the right side.
561 { 567 {
568 // Construct a SnapSizer to get the expected bounds when snapped right.
569 internal::SnapSizer sizer(window_.get(),
570 gfx::Point(),
571 internal::SnapSizer::RIGHT_EDGE,
572 internal::SnapSizer::STEP_NO);
573
562 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 574 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
563 window_.get(), gfx::Point(), HTCAPTION, 575 window_.get(), gfx::Point(), HTCAPTION,
564 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 576 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
565 ASSERT_TRUE(resizer.get()); 577 ASSERT_TRUE(resizer.get());
566 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 578 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
567 resizer->CompleteDrag(0); 579 resizer->CompleteDrag(0);
568 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), 580 EXPECT_EQ(sizer.target_bounds().ToString(),
569 window_->bounds().ToString()); 581 window_->bounds().ToString());
570 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); 582 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get()));
571 EXPECT_EQ("20,30 50x60", 583 EXPECT_EQ("20,30 50x60",
572 GetRestoreBoundsInScreen(window_.get())->ToString()); 584 GetRestoreBoundsInScreen(window_.get())->ToString());
573 } 585 }
574 586
575 // Test if the restore bounds is correct in multiple displays. 587 // Test if the restore bounds is correct in multiple displays.
576 ClearRestoreBounds(window_.get()); 588 ClearRestoreBounds(window_.get());
577 589
578 if (!SupportsMultipleDisplays()) 590 if (!SupportsMultipleDisplays())
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 window_.get(), gfx::Point(), HTCAPTION, 1146 window_.get(), gfx::Point(), HTCAPTION,
1135 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 1147 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
1136 ASSERT_TRUE(resizer.get()); 1148 ASSERT_TRUE(resizer.get());
1137 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, 1149 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin,
1138 // the window should move to the exact position. 1150 // the window should move to the exact position.
1139 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); 1151 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0);
1140 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); 1152 resizer->CompleteDrag(ui::EF_CONTROL_DOWN);
1141 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); 1153 EXPECT_EQ("106,124 320x160", window_->bounds().ToString());
1142 } 1154 }
1143 1155
1144 // Check that only usable sizes get returned by the resizer.
1145 TEST_F(WorkspaceWindowResizerTest, TestProperSizerResolutions) {
1146 // Check that we have the correct work area resolution which fits our
1147 // expected test result.
1148 gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(
1149 window_.get()));
1150 EXPECT_EQ(800, work_area.width());
1151
1152 window_->SetBounds(gfx::Rect(96, 112, 320, 160));
1153 scoped_ptr<SnapSizer> resizer(new SnapSizer(
1154 window_.get(),
1155 gfx::Point(),
1156 SnapSizer::LEFT_EDGE,
1157 SnapSizer::OTHER_INPUT));
1158 ASSERT_TRUE(resizer.get());
1159 shelf_layout_manager()->SetAutoHideBehavior(
1160 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1161
1162 // Check that the list is declining and contains elements of the
1163 // ideal size list [1280, 1024, 768, 640] as well as 50% and 90% the work
1164 // area.
1165 gfx::Rect rect = resizer->GetTargetBoundsForSize(0);
1166 EXPECT_EQ("0,0 720x597", rect.ToString());
1167 rect = resizer->GetTargetBoundsForSize(1);
1168 EXPECT_EQ("0,0 640x597", rect.ToString());
1169 rect = resizer->GetTargetBoundsForSize(2);
1170 EXPECT_EQ("0,0 400x597", rect.ToString());
1171 shelf_layout_manager()->SetAutoHideBehavior(
1172 SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1173 rect = resizer->GetTargetBoundsForSize(0);
1174 EXPECT_EQ("0,0 720x552", rect.ToString());
1175 rect = resizer->GetTargetBoundsForSize(1);
1176 EXPECT_EQ("0,0 640x552", rect.ToString());
1177 rect = resizer->GetTargetBoundsForSize(2);
1178 EXPECT_EQ("0,0 400x552", rect.ToString());
1179 }
1180
1181 // Verifies that a dragged window will restore to its pre-maximized size. 1156 // Verifies that a dragged window will restore to its pre-maximized size.
1182 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { 1157 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
1183 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); 1158 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000));
1184 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); 1159 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160));
1185 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 1160 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
1186 window_.get(), gfx::Point(), HTCAPTION, 1161 window_.get(), gfx::Point(), HTCAPTION,
1187 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 1162 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
1188 ASSERT_TRUE(resizer.get()); 1163 ASSERT_TRUE(resizer.get());
1189 // Drag the window to new position by adding (10, 10) to original point, 1164 // Drag the window to new position by adding (10, 10) to original point,
1190 // the window should get restored. 1165 // the window should get restored.
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 RunAnimationTillComplete(phantom_controller->animation_.get()); 1944 RunAnimationTillComplete(phantom_controller->animation_.get());
1970 1945
1971 // Hide phantom controller. Both widgets should close. 1946 // Hide phantom controller. Both widgets should close.
1972 phantom_controller->Hide(); 1947 phantom_controller->Hide();
1973 EXPECT_FALSE(phantom_controller->phantom_widget_); 1948 EXPECT_FALSE(phantom_controller->phantom_widget_);
1974 EXPECT_FALSE(phantom_controller->phantom_widget_start_); 1949 EXPECT_FALSE(phantom_controller->phantom_widget_start_);
1975 } 1950 }
1976 1951
1977 } // namespace internal 1952 } // namespace internal
1978 } // namespace ash 1953 } // namespace ash
OLDNEW
« ash/wm/workspace/snap_sizer.cc ('K') | « ash/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698