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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 EXPECT_EQ("20,500 100x100", window3_->bounds().ToString()); | 466 EXPECT_EQ("20,500 100x100", window3_->bounds().ToString()); |
467 | 467 |
468 // 100 up again. | 468 // 100 up again. |
469 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); | 469 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); |
470 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); | 470 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); |
471 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); | 471 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); |
472 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); | 472 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); |
473 } | 473 } |
474 | 474 |
475 | 475 |
476 #if defined(OS_WIN) | |
477 // Multiple displays are not supported on Windows Ash. http://crbug.com/165962 | |
478 #define MAYBE_Edge DISABLED_Edge | |
479 #else | |
480 #define MAYBE_Edge Edge | |
481 #endif | |
482 | |
483 // Assertions around dragging to the left/right edge of the screen. | 476 // Assertions around dragging to the left/right edge of the screen. |
484 TEST_F(WorkspaceWindowResizerTest, MAYBE_Edge) { | 477 TEST_F(WorkspaceWindowResizerTest, Edge) { |
485 int bottom = | 478 int bottom = |
486 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 479 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
487 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); | 480 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); |
488 { | 481 { |
489 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 482 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
490 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 483 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
491 ASSERT_TRUE(resizer.get()); | 484 ASSERT_TRUE(resizer.get()); |
492 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); | 485 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); |
493 resizer->CompleteDrag(0); | 486 resizer->CompleteDrag(0); |
494 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), | 487 EXPECT_EQ("0,0 720x" + base::IntToString(bottom), |
(...skipping 11 matching lines...) Expand all Loading... |
506 resizer->CompleteDrag(0); | 499 resizer->CompleteDrag(0); |
507 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), | 500 EXPECT_EQ("80,0 720x" + base::IntToString(bottom), |
508 window_->bounds().ToString()); | 501 window_->bounds().ToString()); |
509 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); | 502 ASSERT_TRUE(GetRestoreBoundsInScreen(window_.get())); |
510 EXPECT_EQ("20,30 50x60", | 503 EXPECT_EQ("20,30 50x60", |
511 GetRestoreBoundsInScreen(window_.get())->ToString()); | 504 GetRestoreBoundsInScreen(window_.get())->ToString()); |
512 } | 505 } |
513 | 506 |
514 // Test if the restore bounds is correct in multiple displays. | 507 // Test if the restore bounds is correct in multiple displays. |
515 ClearRestoreBounds(window_.get()); | 508 ClearRestoreBounds(window_.get()); |
| 509 |
| 510 if (!SupportsMultipleDisplays()) |
| 511 return; |
| 512 |
516 UpdateDisplay("800x600,200x600"); | 513 UpdateDisplay("800x600,200x600"); |
517 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 514 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
518 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 515 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
519 window_->SetBoundsInScreen(gfx::Rect(800, 10, 50, 60), | 516 window_->SetBoundsInScreen(gfx::Rect(800, 10, 50, 60), |
520 ScreenAsh::GetSecondaryDisplay()); | 517 ScreenAsh::GetSecondaryDisplay()); |
521 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); | 518 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); |
522 { | 519 { |
523 bottom = | 520 bottom = |
524 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); | 521 ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); |
525 EXPECT_EQ("800,10 50x60", window_->GetBoundsInScreen().ToString()); | 522 EXPECT_EQ("800,10 50x60", window_->GetBoundsInScreen().ToString()); |
(...skipping 19 matching lines...) Expand all Loading... |
545 window_->SetProperty(aura::client::kCanResizeKey, false); | 542 window_->SetProperty(aura::client::kCanResizeKey, false); |
546 | 543 |
547 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 544 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
548 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 545 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
549 ASSERT_TRUE(resizer.get()); | 546 ASSERT_TRUE(resizer.get()); |
550 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); | 547 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); |
551 resizer->CompleteDrag(0); | 548 resizer->CompleteDrag(0); |
552 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); | 549 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); |
553 } | 550 } |
554 | 551 |
555 #if defined(OS_WIN) | 552 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) { |
556 // Multiple displays are not supported on Windows Ash. http://crbug.com/165962 | 553 if (!SupportsMultipleDisplays()) |
557 #define MAYBE_CancelSnapPhantom DISABLED_CancelSnapPhantom | 554 return; |
558 #else | |
559 #define MAYBE_CancelSnapPhantom CancelSnapPhantom | |
560 #endif | |
561 | 555 |
562 TEST_F(WorkspaceWindowResizerTest, MAYBE_CancelSnapPhantom) { | |
563 UpdateDisplay("800x600,800x600"); | 556 UpdateDisplay("800x600,800x600"); |
564 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 557 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
565 ASSERT_EQ(2U, root_windows.size()); | 558 ASSERT_EQ(2U, root_windows.size()); |
566 | 559 |
567 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), | 560 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
568 Shell::GetScreen()->GetPrimaryDisplay()); | 561 Shell::GetScreen()->GetPrimaryDisplay()); |
569 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); | 562 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
570 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); | 563 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); |
571 { | 564 { |
572 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 565 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 623 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
631 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); | 624 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); |
632 ASSERT_TRUE(resizer.get()); | 625 ASSERT_TRUE(resizer.get()); |
633 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); | 626 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); |
634 int expected_y = | 627 int expected_y = |
635 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; | 628 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; |
636 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", | 629 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", |
637 window_->bounds().ToString()); | 630 window_->bounds().ToString()); |
638 } | 631 } |
639 | 632 |
640 #if defined(OS_WIN) | 633 // Makes sure we don't allow dragging on the work area with multidisplay. |
641 // Multiple displays are not supported on Windows Ash. http://crbug.com/165962 | 634 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { |
642 #define MAYBE_DontDragOffBottomWithMultiDisplay \ | 635 if (!SupportsMultipleDisplays()) |
643 DISABLED_DontDragOffBottomWithMultiDisplay | 636 return; |
644 #else | |
645 #define MAYBE_DontDragOffBottomWithMultiDisplay \ | |
646 DontDragOffBottomWithMultiDisplay | |
647 #endif | |
648 | 637 |
649 // Makes sure we don't allow dragging on the work area with multidisplay. | |
650 TEST_F(WorkspaceWindowResizerTest, MAYBE_DontDragOffBottomWithMultiDisplay) { | |
651 UpdateDisplay("800x600,800x600"); | 638 UpdateDisplay("800x600,800x600"); |
652 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 639 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); |
653 | 640 |
654 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 641 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
655 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); | 642 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); |
656 | 643 |
657 // Positions the secondary display at the bottom the primary display. | 644 // Positions the secondary display at the bottom the primary display. |
658 Shell::GetInstance()->display_controller()->SetLayoutForCurrentDisplays( | 645 Shell::GetInstance()->display_controller()->SetLayoutForCurrentDisplays( |
659 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); | 646 ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 0)); |
660 | 647 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 ASSERT_TRUE(resizer.get()); | 749 ASSERT_TRUE(resizer.get()); |
763 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); | 750 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); |
764 EXPECT_EQ("100," + | 751 EXPECT_EQ("100," + |
765 base::IntToString(bottom - kMinimumOnScreenArea) + | 752 base::IntToString(bottom - kMinimumOnScreenArea) + |
766 " 300x" + | 753 " 300x" + |
767 base::IntToString(height - (delta_to_bottom - | 754 base::IntToString(height - (delta_to_bottom - |
768 kMinimumOnScreenArea)), | 755 kMinimumOnScreenArea)), |
769 window_->bounds().ToString()); | 756 window_->bounds().ToString()); |
770 } | 757 } |
771 | 758 |
772 #if defined(OS_WIN) | |
773 // Multiple displays are not supported on Windows Ash. http://crbug.com/165962 | |
774 #define MAYBE_DragWindowOutsideRightToSecondaryDisplay \ | |
775 DISABLED_DragWindowOutsideRightToSecondaryDisplay | |
776 #else | |
777 #define MAYBE_DragWindowOutsideRightToSecondaryDisplay \ | |
778 DragWindowOutsideRightToSecondaryDisplay | |
779 #endif | |
780 | |
781 // Verifies that 'outside' check of the resizer take into account the extended | 759 // Verifies that 'outside' check of the resizer take into account the extended |
782 // desktop in case of repositions. | 760 // desktop in case of repositions. |
783 TEST_F(WorkspaceWindowResizerTest, | 761 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { |
784 MAYBE_DragWindowOutsideRightToSecondaryDisplay) { | |
785 // Only primary display. Changes the window position to fit within the | 762 // Only primary display. Changes the window position to fit within the |
786 // display. | 763 // display. |
787 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 764 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
788 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 765 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
789 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( | 766 int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( |
790 window_.get()).right(); | 767 window_.get()).right(); |
791 int pixels_to_right_border = 50; | 768 int pixels_to_right_border = 50; |
792 int window_width = 300; | 769 int window_width = 300; |
793 int window_x = right - pixels_to_right_border; | 770 int window_x = right - pixels_to_right_border; |
794 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 771 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
795 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( | 772 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( |
796 window_.get(), gfx::Point(window_x, 0), HTCAPTION, | 773 window_.get(), gfx::Point(window_x, 0), HTCAPTION, |
797 empty_windows())); | 774 empty_windows())); |
798 ASSERT_TRUE(resizer.get()); | 775 ASSERT_TRUE(resizer.get()); |
799 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 776 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
800 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + | 777 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + |
801 ",100 " + | 778 ",100 " + |
802 base::IntToString(window_width) + | 779 base::IntToString(window_width) + |
803 "x380", window_->bounds().ToString()); | 780 "x380", window_->bounds().ToString()); |
804 | 781 |
| 782 if (!SupportsMultipleDisplays()) |
| 783 return; |
| 784 |
805 // With secondary display. Operation itself is same but doesn't change | 785 // With secondary display. Operation itself is same but doesn't change |
806 // the position because the window is still within the secondary display. | 786 // the position because the window is still within the secondary display. |
807 UpdateDisplay("1000x600,600x400"); | 787 UpdateDisplay("1000x600,600x400"); |
808 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 788 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
809 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); | 789 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); |
810 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); | 790 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); |
811 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); | 791 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); |
812 EXPECT_EQ(base::IntToString(window_x + window_width) + | 792 EXPECT_EQ(base::IntToString(window_x + window_width) + |
813 ",100 " + | 793 ",100 " + |
814 base::IntToString(window_width) + | 794 base::IntToString(window_width) + |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 ASSERT_TRUE(resizer.get()); | 1580 ASSERT_TRUE(resizer.get()); |
1601 // Move it 50 to the left, which should contract w1 and expand w2-3. | 1581 // Move it 50 to the left, which should contract w1 and expand w2-3. |
1602 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); | 1582 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); |
1603 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); | 1583 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); |
1604 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); | 1584 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); |
1605 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); | 1585 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); |
1606 } | 1586 } |
1607 | 1587 |
1608 } // namespace internal | 1588 } // namespace internal |
1609 } // namespace ash | 1589 } // namespace ash |
OLD | NEW |