| 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 921 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_NEVER); |
| 942 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); | 944 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); |
| 943 EXPECT_EQ("0,0 720x552", rect.ToString()); | 945 EXPECT_EQ("0,0 720x552", rect.ToString()); |
| 944 rect = resizer->GetTargetBoundsForSize(1); | 946 rect = resizer->GetTargetBoundsForSize(1); |
| 945 EXPECT_EQ("0,0 720x552", rect.ToString()); | 947 EXPECT_EQ("0,0 720x552", rect.ToString()); |
| 946 rect = resizer->GetTargetBoundsForSize(2); | 948 rect = resizer->GetTargetBoundsForSize(2); |
| 947 EXPECT_EQ("0,0 720x552", rect.ToString()); | 949 EXPECT_EQ("0,0 720x552", rect.ToString()); |
| 948 rect = resizer->GetTargetBoundsForSize(3); | 950 rect = resizer->GetTargetBoundsForSize(3); |
| 949 EXPECT_EQ("0,0 640x552", rect.ToString()); | 951 EXPECT_EQ("0,0 640x552", rect.ToString()); |
| 952 Shell::GetInstance()->shelf()->SetAutoHideBehavior( |
| 953 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 954 rect = resizer->GetTargetBoundsForSize(0); |
| 955 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 956 rect = resizer->GetTargetBoundsForSize(1); |
| 957 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 958 rect = resizer->GetTargetBoundsForSize(2); |
| 959 EXPECT_EQ("0,0 720x597", rect.ToString()); |
| 960 rect = resizer->GetTargetBoundsForSize(3); |
| 961 EXPECT_EQ("0,0 640x597", 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. |
| 953 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { | 965 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { |
| 954 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); | 966 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); |
| 955 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); | 967 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); |
| 956 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 968 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 957 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 969 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 958 ASSERT_TRUE(resizer.get()); | 970 ASSERT_TRUE(resizer.get()); |
| 959 // Drag the window to new position by adding (10, 10) to original point, | 971 // Drag the window to new position by adding (10, 10) to original point, |
| (...skipping 42 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 |