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_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/mouse_cursor_event_filter.h" | 8 #include "ash/display/mouse_cursor_event_filter.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 // 100 up again. | 443 // 100 up again. |
444 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); | 444 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); |
445 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); | 445 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); |
446 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); | 446 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); |
447 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); | 447 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); |
448 } | 448 } |
449 | 449 |
450 // Assertions around dragging to the left/right edge of the screen. | 450 // Assertions around dragging to the left/right edge of the screen. |
451 TEST_F(WorkspaceWindowResizerTest, Edge) { | 451 TEST_F(WorkspaceWindowResizerTest, Edge) { |
452 int bottom = | 452 int bottom = |
453 ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(window_.get()).bottom(); | 453 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
454 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); | 454 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); |
455 { | 455 { |
456 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 456 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
457 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 457 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
458 ASSERT_TRUE(resizer.get()); | 458 ASSERT_TRUE(resizer.get()); |
459 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 459 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
460 resizer->CompleteDrag(0); | 460 resizer->CompleteDrag(0); |
461 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), | 461 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), |
462 window_->bounds().ToString()); | 462 window_->bounds().ToString()); |
463 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 463 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); | 993 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); |
994 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); | 994 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); |
995 } | 995 } |
996 | 996 |
997 // Check that only usable sizes get returned by the resizer. | 997 // Check that only usable sizes get returned by the resizer. |
998 TEST_F(WorkspaceWindowResizerTest, TestProperSizerResolutions) { | 998 TEST_F(WorkspaceWindowResizerTest, TestProperSizerResolutions) { |
999 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 999 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
1000 scoped_ptr<SnapSizer> resizer(new SnapSizer( | 1000 scoped_ptr<SnapSizer> resizer(new SnapSizer( |
1001 window_.get(), gfx::Point(), SnapSizer::LEFT_EDGE)); | 1001 window_.get(), gfx::Point(), SnapSizer::LEFT_EDGE)); |
1002 ASSERT_TRUE(resizer.get()); | 1002 ASSERT_TRUE(resizer.get()); |
| 1003 Shell::GetInstance()->shelf()->SetAutoHideBehavior( |
| 1004 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1003 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); | 1005 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); |
| 1006 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 1007 rect = resizer->GetTargetBoundsForSize(1); |
| 1008 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 1009 rect = resizer->GetTargetBoundsForSize(2); |
| 1010 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 1011 rect = resizer->GetTargetBoundsForSize(3); |
| 1012 EXPECT_EQ("0,0 640x597", rect.ToString()); |
| 1013 Shell::GetInstance()->shelf()->SetAutoHideBehavior( |
| 1014 SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1015 rect = resizer->GetTargetBoundsForSize(0); |
1004 EXPECT_EQ("0,0 720x552", rect.ToString()); | 1016 EXPECT_EQ("0,0 720x552", rect.ToString()); |
1005 rect = resizer->GetTargetBoundsForSize(1); | 1017 rect = resizer->GetTargetBoundsForSize(1); |
1006 EXPECT_EQ("0,0 720x552", rect.ToString()); | 1018 EXPECT_EQ("0,0 720x552", rect.ToString()); |
1007 rect = resizer->GetTargetBoundsForSize(2); | 1019 rect = resizer->GetTargetBoundsForSize(2); |
1008 EXPECT_EQ("0,0 720x552", rect.ToString()); | 1020 EXPECT_EQ("0,0 720x552", rect.ToString()); |
1009 rect = resizer->GetTargetBoundsForSize(3); | 1021 rect = resizer->GetTargetBoundsForSize(3); |
1010 EXPECT_EQ("0,0 640x552", rect.ToString()); | 1022 EXPECT_EQ("0,0 640x552", rect.ToString()); |
1011 } | 1023 } |
1012 | 1024 |
1013 // Verifies that a dragged window will restore to its pre-maximized size. | 1025 // Verifies that a dragged window will restore to its pre-maximized size. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); | 1075 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); |
1064 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); | 1076 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); |
1065 | 1077 |
1066 // Move |window| one pixel above the bottom of |window2|. | 1078 // Move |window| one pixel above the bottom of |window2|. |
1067 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); | 1079 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); |
1068 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); | 1080 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); |
1069 } | 1081 } |
1070 | 1082 |
1071 } // namespace internal | 1083 } // namespace internal |
1072 } // namespace ash | 1084 } // namespace ash |
OLD | NEW |