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

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: Patch is now friendlier to pending docking changes 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"
11 #include "ash/screen_ash.h" 11 #include "ash/screen_ash.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/property_util.h" 16 #include "ash/wm/property_util.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"
20 #include "ash/wm/workspace_controller.h" 19 #include "ash/wm/workspace_controller.h"
21 #include "base/command_line.h" 20 #include "base/command_line.h"
22 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
24 #include "ui/aura/client/aura_constants.h" 23 #include "ui/aura/client/aura_constants.h"
25 #include "ui/aura/root_window.h" 24 #include "ui/aura/root_window.h"
26 #include "ui/aura/test/event_generator.h" 25 #include "ui/aura/test/event_generator.h"
27 #include "ui/aura/test/test_window_delegate.h" 26 #include "ui/aura/test/test_window_delegate.h"
28 #include "ui/base/hit_test.h" 27 #include "ui/base/hit_test.h"
29 #include "ui/gfx/insets.h" 28 #include "ui/gfx/insets.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); 544 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
546 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); 545 window_->SetBounds(gfx::Rect(20, 30, 50, 60));
547 { 546 {
548 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 547 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
549 window_.get(), gfx::Point(), HTCAPTION, 548 window_.get(), gfx::Point(), HTCAPTION,
550 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 549 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
551 ASSERT_TRUE(resizer.get()); 550 ASSERT_TRUE(resizer.get());
552 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); 551 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0);
553 resizer->CompleteDrag(0); 552 resizer->CompleteDrag(0);
554 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), 553 EXPECT_EQ("0,0 720x" + base::IntToString(bottom),
555 window_->bounds().ToString()); 554 window_->bounds().ToString());
varkha 2013/08/30 17:13:25 Does not this break if you restrict side-maximized
pkotwicz 2013/08/30 21:10:57 Modified unittest
556 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); 555 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get()));
557 EXPECT_EQ("20,30 50x60", 556 EXPECT_EQ("20,30 50x60",
558 GetRestoreBoundsInScreen(window_.get())->ToString()); 557 GetRestoreBoundsInScreen(window_.get())->ToString());
559 } 558 }
560 // Try the same with the right side. 559 // Try the same with the right side.
561 { 560 {
562 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 561 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
563 window_.get(), gfx::Point(), HTCAPTION, 562 window_.get(), gfx::Point(), HTCAPTION,
564 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 563 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
565 ASSERT_TRUE(resizer.get()); 564 ASSERT_TRUE(resizer.get());
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 window_.get(), gfx::Point(), HTCAPTION, 1133 window_.get(), gfx::Point(), HTCAPTION,
1135 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 1134 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
1136 ASSERT_TRUE(resizer.get()); 1135 ASSERT_TRUE(resizer.get());
1137 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, 1136 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin,
1138 // the window should move to the exact position. 1137 // the window should move to the exact position.
1139 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); 1138 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0);
1140 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); 1139 resizer->CompleteDrag(ui::EF_CONTROL_DOWN);
1141 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); 1140 EXPECT_EQ("106,124 320x160", window_->bounds().ToString());
1142 } 1141 }
1143 1142
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. 1143 // Verifies that a dragged window will restore to its pre-maximized size.
1182 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { 1144 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
1183 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); 1145 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000));
1184 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); 1146 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160));
1185 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 1147 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
1186 window_.get(), gfx::Point(), HTCAPTION, 1148 window_.get(), gfx::Point(), HTCAPTION,
1187 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows())); 1149 aura::client::WINDOW_MOVE_SOURCE_MOUSE, empty_windows()));
1188 ASSERT_TRUE(resizer.get()); 1150 ASSERT_TRUE(resizer.get());
1189 // Drag the window to new position by adding (10, 10) to original point, 1151 // Drag the window to new position by adding (10, 10) to original point,
1190 // the window should get restored. 1152 // the window should get restored.
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 RunAnimationTillComplete(phantom_controller->animation_.get()); 1931 RunAnimationTillComplete(phantom_controller->animation_.get());
1970 1932
1971 // Hide phantom controller. Both widgets should close. 1933 // Hide phantom controller. Both widgets should close.
1972 phantom_controller->Hide(); 1934 phantom_controller->Hide();
1973 EXPECT_FALSE(phantom_controller->phantom_widget_); 1935 EXPECT_FALSE(phantom_controller->phantom_widget_);
1974 EXPECT_FALSE(phantom_controller->phantom_widget_start_); 1936 EXPECT_FALSE(phantom_controller->phantom_widget_start_);
1975 } 1937 }
1976 1938
1977 } // namespace internal 1939 } // namespace internal
1978 } // namespace ash 1940 } // namespace ash
OLDNEW
« ash/wm/workspace/workspace_window_resizer.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