| 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/root_window_controller.h" |
| 9 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
| 12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/wm/property_util.h" | 14 #include "ash/wm/property_util.h" |
| 14 #include "ash/wm/shelf_layout_manager.h" | 15 #include "ash/wm/shelf_layout_manager.h" |
| 15 #include "ash/wm/workspace_controller.h" | 16 #include "ash/wm/workspace_controller.h" |
| 16 #include "ash/wm/workspace/snap_sizer.h" | 17 #include "ash/wm/workspace/snap_sizer.h" |
| 17 #include "ash/wm/workspace/phantom_window_controller.h" | 18 #include "ash/wm/workspace/phantom_window_controller.h" |
| 18 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 window_->bounds().ToString()); | 474 window_->bounds().ToString()); |
| 474 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 475 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
| 475 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); | 476 EXPECT_EQ("20,30 50x60", GetRestoreBoundsInScreen(window_.get())->ToString()); |
| 476 } | 477 } |
| 477 | 478 |
| 478 // Verifies a window can be moved from the primary display to another. | 479 // Verifies a window can be moved from the primary display to another. |
| 479 TEST_F(WorkspaceWindowResizerTest, MAYBE_WindowDragWithMultiDisplays) { | 480 TEST_F(WorkspaceWindowResizerTest, MAYBE_WindowDragWithMultiDisplays) { |
| 480 // The secondary display is logically on the right, but on the system (e.g. X) | 481 // The secondary display is logically on the right, but on the system (e.g. X) |
| 481 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. | 482 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. |
| 482 UpdateDisplay("800x600,800x600"); | 483 UpdateDisplay("800x600,800x600"); |
| 483 Shell::GetInstance()->shelf()->LayoutShelf(); | 484 Shell::GetPrimaryRootWindowController()->shelf()->LayoutShelf(); |
| 484 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 485 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 485 ASSERT_EQ(2U, root_windows.size()); | 486 ASSERT_EQ(2U, root_windows.size()); |
| 486 | 487 |
| 487 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 488 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
| 488 Shell::GetScreen()->GetPrimaryDisplay()); | 489 Shell::GetScreen()->GetPrimaryDisplay()); |
| 489 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 490 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
| 490 { | 491 { |
| 491 // Grab (0, 0) of the window. | 492 // Grab (0, 0) of the window. |
| 492 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 493 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| 493 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 494 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 // root window's bounds. | 535 // root window's bounds. |
| 535 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 536 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
| 536 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); | 537 EXPECT_EQ("-49,10 50x60", window_->bounds().ToString()); |
| 537 } | 538 } |
| 538 } | 539 } |
| 539 | 540 |
| 540 // Verifies a window can be moved from the secondary display to primary. | 541 // Verifies a window can be moved from the secondary display to primary. |
| 541 TEST_F(WorkspaceWindowResizerTest, | 542 TEST_F(WorkspaceWindowResizerTest, |
| 542 MAYBE_WindowDragWithMultiDisplaysRightToLeft) { | 543 MAYBE_WindowDragWithMultiDisplaysRightToLeft) { |
| 543 UpdateDisplay("800x600,800x600"); | 544 UpdateDisplay("800x600,800x600"); |
| 544 Shell::GetInstance()->shelf()->LayoutShelf(); | 545 Shell::GetPrimaryRootWindowController()->shelf()->LayoutShelf(); |
| 545 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 546 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 546 ASSERT_EQ(2U, root_windows.size()); | 547 ASSERT_EQ(2U, root_windows.size()); |
| 547 | 548 |
| 548 window_->SetBoundsInScreen( | 549 window_->SetBoundsInScreen( |
| 549 gfx::Rect(800, 00, 50, 60), | 550 gfx::Rect(800, 00, 50, 60), |
| 550 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); | 551 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1])); |
| 551 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 552 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
| 552 { | 553 { |
| 553 // Grab (0, 0) of the window. | 554 // Grab (0, 0) of the window. |
| 554 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 555 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); | 1003 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); |
| 1003 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); | 1004 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); |
| 1004 | 1005 |
| 1005 // Move |window| one pixel above the bottom of |window2|. | 1006 // Move |window| one pixel above the bottom of |window2|. |
| 1006 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); | 1007 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); |
| 1007 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); | 1008 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); |
| 1008 } | 1009 } |
| 1009 | 1010 |
| 1010 } // namespace internal | 1011 } // namespace internal |
| 1011 } // namespace ash | 1012 } // namespace ash |
| OLD | NEW |