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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 // 100 up again. | 442 // 100 up again. |
443 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); | 443 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); |
444 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); | 444 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); |
445 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); | 445 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); |
446 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); | 446 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); |
447 } | 447 } |
448 | 448 |
449 // Assertions around dragging to the left/right edge of the screen. | 449 // Assertions around dragging to the left/right edge of the screen. |
450 TEST_F(WorkspaceWindowResizerTest, Edge) { | 450 TEST_F(WorkspaceWindowResizerTest, Edge) { |
451 int bottom = | 451 int bottom = |
452 ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(window_.get()).bottom(); | 452 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
453 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); | 453 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); |
454 { | 454 { |
455 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 455 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
456 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 456 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
457 ASSERT_TRUE(resizer.get()); | 457 ASSERT_TRUE(resizer.get()); |
458 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 458 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
459 resizer->CompleteDrag(0); | 459 resizer->CompleteDrag(0); |
460 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), | 460 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), |
461 window_->bounds().ToString()); | 461 window_->bounds().ToString()); |
462 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 462 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); | 932 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); |
933 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); | 933 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); |
934 } | 934 } |
935 | 935 |
936 // Check that only usable sizes get returned by the resizer. | 936 // Check that only usable sizes get returned by the resizer. |
937 TEST_F(WorkspaceWindowResizerTest, TestProperSizerResolutions) { | 937 TEST_F(WorkspaceWindowResizerTest, TestProperSizerResolutions) { |
938 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); | 938 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); |
939 scoped_ptr<SnapSizer> resizer(new SnapSizer( | 939 scoped_ptr<SnapSizer> resizer(new SnapSizer( |
940 window_.get(), gfx::Point(), SnapSizer::LEFT_EDGE)); | 940 window_.get(), gfx::Point(), SnapSizer::LEFT_EDGE)); |
941 ASSERT_TRUE(resizer.get()); | 941 ASSERT_TRUE(resizer.get()); |
| 942 Shell::GetInstance()->shelf()->SetAutoHideBehavior( |
| 943 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
942 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); | 944 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); |
| 945 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 946 rect = resizer->GetTargetBoundsForSize(1); |
| 947 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 948 rect = resizer->GetTargetBoundsForSize(2); |
| 949 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 950 rect = resizer->GetTargetBoundsForSize(3); |
| 951 EXPECT_EQ("0,0 640x597", rect.ToString()); |
| 952 Shell::GetInstance()->shelf()->SetAutoHideBehavior( |
| 953 SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 954 rect = resizer->GetTargetBoundsForSize(0); |
943 EXPECT_EQ("0,0 720x552", rect.ToString()); | 955 EXPECT_EQ("0,0 720x552", rect.ToString()); |
944 rect = resizer->GetTargetBoundsForSize(1); | 956 rect = resizer->GetTargetBoundsForSize(1); |
945 EXPECT_EQ("0,0 720x552", rect.ToString()); | 957 EXPECT_EQ("0,0 720x552", rect.ToString()); |
946 rect = resizer->GetTargetBoundsForSize(2); | 958 rect = resizer->GetTargetBoundsForSize(2); |
947 EXPECT_EQ("0,0 720x552", rect.ToString()); | 959 EXPECT_EQ("0,0 720x552", rect.ToString()); |
948 rect = resizer->GetTargetBoundsForSize(3); | 960 rect = resizer->GetTargetBoundsForSize(3); |
949 EXPECT_EQ("0,0 640x552", rect.ToString()); | 961 EXPECT_EQ("0,0 640x552", rect.ToString()); |
950 } | 962 } |
951 | 963 |
952 // Verifies that a dragged window will restore to its pre-maximized size. | 964 // 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... |
1002 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); | 1014 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); |
1003 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); | 1015 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); |
1004 | 1016 |
1005 // Move |window| one pixel above the bottom of |window2|. | 1017 // Move |window| one pixel above the bottom of |window2|. |
1006 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); | 1018 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); |
1007 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); | 1019 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); |
1008 } | 1020 } |
1009 | 1021 |
1010 } // namespace internal | 1022 } // namespace internal |
1011 } // namespace ash | 1023 } // namespace ash |
OLD | NEW |