| 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/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 #include "ash/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 636 |
| 637 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { | 637 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { |
| 638 if (!SupportsMultipleDisplays()) | 638 if (!SupportsMultipleDisplays()) |
| 639 return; | 639 return; |
| 640 | 640 |
| 641 UpdateDisplay("1000x600,600x400"); | 641 UpdateDisplay("1000x600,600x400"); |
| 642 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 642 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 643 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 643 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 644 views::Widget* w1_t1 = CreateTestWidgetWithParent( | 644 views::Widget* w1_t1 = CreateTestWidgetWithParent( |
| 645 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); | 645 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); |
| 646 // Transient child of the transient child. | 646 // Transient child of the child of the parent. |
| 647 views::Widget* w1_t11 = CreateTestWidgetWithParent( | 647 views::Widget* w1_t11 = CreateTestWidgetWithParent( |
| 648 w1_t1, gfx::Rect(1200, 70, 35, 35), false /* transient */); | 648 w1_t1, gfx::Rect(1200, 70, 35, 35), false /* transient */); |
| 649 | 649 |
| 650 views::Widget* w11 = CreateTestWidgetWithParent( | 650 views::Widget* w11 = CreateTestWidgetWithParent( |
| 651 w1, gfx::Rect(10, 10, 40, 40), true /* child */); | 651 w1, gfx::Rect(10, 10, 40, 40), true /* child */); |
| 652 views::Widget* w11_t1 = CreateTestWidgetWithParent( | 652 views::Widget* w11_t1 = CreateTestWidgetWithParent( |
| 653 w1, gfx::Rect(1300, 100, 80, 80), false /* transient */); | 653 w1, gfx::Rect(1300, 100, 80, 80), false /* transient */); |
| 654 | 654 |
| 655 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); | 655 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); |
| 656 EXPECT_EQ(root_windows[0], w11->GetNativeView()->GetRootWindow()); | 656 EXPECT_EQ(root_windows[0], w11->GetNativeView()->GetRootWindow()); |
| 657 EXPECT_EQ(root_windows[0], w1_t1->GetNativeView()->GetRootWindow()); | 657 EXPECT_EQ(root_windows[0], w1_t1->GetNativeView()->GetRootWindow()); |
| 658 EXPECT_EQ(root_windows[0], w1_t11->GetNativeView()->GetRootWindow()); | 658 EXPECT_EQ(root_windows[0], w1_t11->GetNativeView()->GetRootWindow()); |
| 659 EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow()); | 659 EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow()); |
| 660 EXPECT_EQ("50,50 50x50", | 660 EXPECT_EQ("50,50 50x50", |
| 661 w1_t1->GetWindowBoundsInScreen().ToString()); | 661 w1_t1->GetWindowBoundsInScreen().ToString()); |
| 662 EXPECT_EQ("1200,70 35x35", | 662 // The window must fit inside the workarea. |
| 663 w1_t11->GetWindowBoundsInScreen().ToString()); | 663 EXPECT_EQ("975,70 35x35", w1_t11->GetWindowBoundsInScreen().ToString()); |
| 664 EXPECT_EQ("20,20 40x40", | 664 EXPECT_EQ("20,20 40x40", |
| 665 w11->GetWindowBoundsInScreen().ToString()); | 665 w11->GetWindowBoundsInScreen().ToString()); |
| 666 EXPECT_EQ("1300,100 80x80", | 666 // The window must fit inside the workarea. |
| 667 w11_t1->GetWindowBoundsInScreen().ToString()); | 667 EXPECT_EQ("975,100 80x80", w11_t1->GetWindowBoundsInScreen().ToString()); |
| 668 | |
| 669 w1->SetBounds(gfx::Rect(1100, 10, 100, 100)); | 668 w1->SetBounds(gfx::Rect(1100, 10, 100, 100)); |
| 670 | 669 |
| 671 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); | 670 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 672 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); | 671 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 673 EXPECT_EQ(root_windows[1], w1_t11->GetNativeView()->GetRootWindow()); | 672 EXPECT_EQ(root_windows[1], w1_t11->GetNativeView()->GetRootWindow()); |
| 674 EXPECT_EQ(root_windows[1], w11->GetNativeView()->GetRootWindow()); | 673 EXPECT_EQ(root_windows[1], w11->GetNativeView()->GetRootWindow()); |
| 675 EXPECT_EQ(root_windows[1], w11_t1->GetNativeView()->GetRootWindow()); | 674 EXPECT_EQ(root_windows[1], w11_t1->GetNativeView()->GetRootWindow()); |
| 676 | 675 |
| 677 EXPECT_EQ("1110,20 40x40", | 676 EXPECT_EQ("1110,20 40x40", |
| 678 w11->GetWindowBoundsInScreen().ToString()); | 677 w11->GetWindowBoundsInScreen().ToString()); |
| 679 // Transient window's screen bounds stays the same. | 678 // Transient window's screen bounds stays the same. |
| 680 EXPECT_EQ("50,50 50x50", | 679 EXPECT_EQ("50,50 50x50", |
| 681 w1_t1->GetWindowBoundsInScreen().ToString()); | 680 w1_t1->GetWindowBoundsInScreen().ToString()); |
| 682 EXPECT_EQ("1200,70 35x35", | 681 // TODO(oshima): window should probably be fit into the desktop in this case. |
| 683 w1_t11->GetWindowBoundsInScreen().ToString()); | 682 EXPECT_EQ("975,70 35x35", w1_t11->GetWindowBoundsInScreen().ToString()); |
| 684 EXPECT_EQ("1300,100 80x80", | 683 EXPECT_EQ("975,100 80x80", w11_t1->GetWindowBoundsInScreen().ToString()); |
| 685 w11_t1->GetWindowBoundsInScreen().ToString()); | |
| 686 | 684 |
| 687 // Transient window doesn't move between root window unless | 685 // Transient window doesn't move between root window unless |
| 688 // its transient parent moves. | 686 // its transient parent moves. |
| 689 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50)); | 687 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50)); |
| 690 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); | 688 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 691 EXPECT_EQ("10,50 50x50", | 689 EXPECT_EQ("10,50 50x50", |
| 692 w1_t1->GetWindowBoundsInScreen().ToString()); | 690 w1_t1->GetWindowBoundsInScreen().ToString()); |
| 693 } | 691 } |
| 694 | 692 |
| 695 // Test if the Window::ConvertPointToTarget works across root windows. | 693 // Test if the Window::ConvertPointToTarget works across root windows. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 generator.ReleaseLeftButton(); | 923 generator.ReleaseLeftButton(); |
| 926 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 924 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 927 | 925 |
| 928 generator.MoveMouseTo(400, 150); | 926 generator.MoveMouseTo(400, 150); |
| 929 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 927 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 930 | 928 |
| 931 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 929 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 932 } | 930 } |
| 933 | 931 |
| 934 } // namespace ash | 932 } // namespace ash |
| OLD | NEW |