| 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/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 451 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 452 ASSERT_TRUE(resizer.get()); | 452 ASSERT_TRUE(resizer.get()); |
| 453 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 453 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
| 454 resizer->CompleteDrag(0); | 454 resizer->CompleteDrag(0); |
| 455 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), | 455 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), |
| 456 window_->bounds().ToString()); | 456 window_->bounds().ToString()); |
| 457 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 457 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
| 458 EXPECT_EQ("20,30 50x60", | 458 EXPECT_EQ("20,30 50x60", |
| 459 GetRestoreBoundsInScreen(window_.get())->ToString()); | 459 GetRestoreBoundsInScreen(window_.get())->ToString()); |
| 460 } | 460 } |
| 461 | |
| 462 // Try the same with the right side. | 461 // Try the same with the right side. |
| 463 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 462 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 464 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 463 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 465 ASSERT_TRUE(resizer.get()); | 464 ASSERT_TRUE(resizer.get()); |
| 466 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 465 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
| 467 resizer->CompleteDrag(0); | 466 resizer->CompleteDrag(0); |
| 468 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), | 467 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), |
| 469 window_->bounds().ToString()); | 468 window_->bounds().ToString()); |
| 470 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 469 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
| 471 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); | 470 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); | 861 gfx::Rect rect = resizer->GetTargetBoundsForSize(0); |
| 863 EXPECT_EQ("0,0 720x552", rect.ToString()); | 862 EXPECT_EQ("0,0 720x552", rect.ToString()); |
| 864 rect = resizer->GetTargetBoundsForSize(1); | 863 rect = resizer->GetTargetBoundsForSize(1); |
| 865 EXPECT_EQ("0,0 720x552", rect.ToString()); | 864 EXPECT_EQ("0,0 720x552", rect.ToString()); |
| 866 rect = resizer->GetTargetBoundsForSize(2); | 865 rect = resizer->GetTargetBoundsForSize(2); |
| 867 EXPECT_EQ("0,0 720x552", rect.ToString()); | 866 EXPECT_EQ("0,0 720x552", rect.ToString()); |
| 868 rect = resizer->GetTargetBoundsForSize(3); | 867 rect = resizer->GetTargetBoundsForSize(3); |
| 869 EXPECT_EQ("0,0 640x552", rect.ToString()); | 868 EXPECT_EQ("0,0 640x552", rect.ToString()); |
| 870 } | 869 } |
| 871 | 870 |
| 871 // Verifies that a dragged window will restore to its pre-maximized size. |
| 872 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { |
| 873 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); |
| 874 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); |
| 875 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 876 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 877 ASSERT_TRUE(resizer.get()); |
| 878 // Drag the window to new position by adding (10, 10) to original point, |
| 879 // the window should get restored. |
| 880 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); |
| 881 resizer->CompleteDrag(0); |
| 882 EXPECT_EQ("10,10 320x160", window_->bounds().ToString()); |
| 883 // The restore rectangle should get cleared as well. |
| 884 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window_.get())); |
| 885 } |
| 886 |
| 887 // Verifies that a dragged window will restore to its pre-maximized size. |
| 888 TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) { |
| 889 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); |
| 890 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); |
| 891 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 892 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 893 ASSERT_TRUE(resizer.get()); |
| 894 // Drag the window to new poistion by adding (180, 16) to original point, |
| 895 // the window should get restored. |
| 896 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); |
| 897 resizer->RevertDrag(); |
| 898 EXPECT_EQ("0,0 1000x1000", window_->bounds().ToString()); |
| 899 EXPECT_EQ("96,112 320x160", |
| 900 GetRestoreBoundsInScreen(window_.get())->ToString()); |
| 901 } |
| 902 |
| 872 } // namespace internal | 903 } // namespace internal |
| 873 } // namespace ash | 904 } // namespace ash |
| OLD | NEW |