Chromium Code Reviews| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 464 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 465 ASSERT_TRUE(resizer.get()); | 465 ASSERT_TRUE(resizer.get()); |
| 466 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 466 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
| 467 resizer->CompleteDrag(0); | 467 resizer->CompleteDrag(0); |
| 468 EXPECT_EQ("0,0 400x" + base::IntToString(bottom), | 468 EXPECT_EQ("0,0 400x" + base::IntToString(bottom), |
| 469 window_->bounds().ToString()); | 469 window_->bounds().ToString()); |
| 470 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 470 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
| 471 EXPECT_EQ("20,30 50x60", | 471 EXPECT_EQ("20,30 50x60", |
| 472 GetRestoreBoundsInScreen(window_.get())->ToString()); | 472 GetRestoreBoundsInScreen(window_.get())->ToString()); |
| 473 } | 473 } |
| 474 | 474 // Being left maximized tTry the same with the right side. |
| 475 // Try the same with the right side. | |
| 476 SetGridSize(0); | 475 SetGridSize(0); |
| 477 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 476 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 478 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 477 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 479 ASSERT_TRUE(resizer.get()); | 478 ASSERT_TRUE(resizer.get()); |
| 480 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); | 479 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); |
| 481 resizer->CompleteDrag(0); | 480 resizer->CompleteDrag(0); |
| 482 EXPECT_EQ("400,0 400x" + base::IntToString(bottom), | 481 EXPECT_EQ("400,0 400x" + base::IntToString(bottom), |
| 483 window_->bounds().ToString()); | 482 window_->bounds().ToString()); |
| 484 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 483 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
| 485 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); | 484 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 896 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 898 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 897 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| 899 ASSERT_TRUE(resizer.get()); | 898 ASSERT_TRUE(resizer.get()); |
| 900 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, | 899 // Ctrl + drag the window to new poistion by adding (10, 12) to its origin, |
| 901 // the window should move to the exact position. | 900 // the window should move to the exact position. |
| 902 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); | 901 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); |
| 903 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); | 902 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); |
| 904 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); | 903 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); |
| 905 } | 904 } |
| 906 | 905 |
| 906 // Verifies that a dragged window will restore to its pre-maximized size. | |
| 907 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { | |
| 908 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); | |
| 909 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); | |
| 910 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
| 911 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
| 912 SetGridSize(1); | |
|
sky
2012/09/10 17:10:48
I'm removing the grid @ http://codereview.chromium
| |
| 913 ASSERT_TRUE(resizer.get()); | |
| 914 // Drag the window to new poistion by adding (180, 16) to original point, | |
| 915 // the window should get restored. | |
| 916 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); | |
| 917 resizer->CompleteDrag(0); | |
| 918 EXPECT_EQ("180,16 320x160", window_->bounds().ToString()); | |
| 919 // The restore rectangle should get cleared as well. | |
| 920 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window_.get())); | |
| 921 } | |
| 922 | |
| 923 // Verifies that a dragged window will restore to its pre-maximized size. | |
| 924 TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) { | |
| 925 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); | |
| 926 SetRestoreBoundsInScreen(window_.get(), gfx::Rect(96, 112, 320, 160)); | |
| 927 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | |
| 928 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | |
| 929 SetGridSize(1); | |
| 930 ASSERT_TRUE(resizer.get()); | |
| 931 // Drag the window to new poistion by adding (180, 16) to original point, | |
| 932 // the window should get restored. | |
| 933 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); | |
| 934 resizer->RevertDrag(); | |
| 935 EXPECT_EQ("0,0 1000x1000", window_->bounds().ToString()); | |
| 936 EXPECT_EQ("96,112 320x160", | |
| 937 GetRestoreBoundsInScreen(window_.get())->ToString()); | |
| 938 } | |
| 939 | |
| 907 } // namespace internal | 940 } // namespace internal |
| 908 } // namespace ash | 941 } // namespace ash |
| OLD | NEW |