| 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/scoped_target_root_window.h" | 5 #include "ash/scoped_target_root_window.h" |
| 6 #include "ash/screen_util.h" | 6 #include "ash/screen_util.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/test/test_shell_delegate.h" | 9 #include "ash/test/test_shell_delegate.h" |
| 10 #include "ash/wm/window_positioner.h" | 10 #include "ash/wm/window_positioner.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // |native_window| will still be owned by the caller after the constructor | 36 // |native_window| will still be owned by the caller after the constructor |
| 37 // was called. | 37 // was called. |
| 38 explicit TestBrowserWindowAura(aura::Window* native_window) | 38 explicit TestBrowserWindowAura(aura::Window* native_window) |
| 39 : native_window_(native_window) { | 39 : native_window_(native_window) { |
| 40 } | 40 } |
| 41 ~TestBrowserWindowAura() override {} | 41 ~TestBrowserWindowAura() override {} |
| 42 | 42 |
| 43 // TestBrowserWindow overrides: | 43 // TestBrowserWindow overrides: |
| 44 void Show() override { | 44 void Show() override { |
| 45 native_window_->Show(); | 45 native_window_->Show(); |
| 46 Activate(); | 46 Activate(user_gesture); |
| 47 } | 47 } |
| 48 void Hide() override { native_window_->Hide(); } | 48 void Hide() override { native_window_->Hide(); } |
| 49 void Activate() override { | 49 void Activate(bool user_gesture) override { |
| 50 aura::client::GetActivationClient( | 50 aura::client::GetActivationClient( |
| 51 native_window_->GetRootWindow())->ActivateWindow(native_window_.get()); | 51 native_window_->GetRootWindow())->ActivateWindow(native_window_.get()); |
| 52 } | 52 } |
| 53 gfx::NativeWindow GetNativeWindow() const override { | 53 gfx::NativeWindow GetNativeWindow() const override { |
| 54 return native_window_.get(); | 54 return native_window_.get(); |
| 55 } | 55 } |
| 56 gfx::Rect GetBounds() const override { return native_window_->bounds(); } | 56 gfx::Rect GetBounds() const override { return native_window_->bounds(); } |
| 57 | 57 |
| 58 Browser* browser() { return browser_.get(); } | 58 Browser* browser() { return browser_.get(); } |
| 59 | 59 |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 } | 673 } |
| 674 | 674 |
| 675 // Move the window to the right side of the secondary display and create a new | 675 // Move the window to the right side of the secondary display and create a new |
| 676 // window. It should be opened then on the secondary display. | 676 // window. It should be opened then on the secondary display. |
| 677 { | 677 { |
| 678 gfx::Display second_display = ash::Shell::GetScreen()-> | 678 gfx::Display second_display = ash::Shell::GetScreen()-> |
| 679 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); | 679 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); |
| 680 browser_window->GetNativeWindow()->SetBoundsInScreen( | 680 browser_window->GetNativeWindow()->SetBoundsInScreen( |
| 681 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), | 681 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), |
| 682 second_display); | 682 second_display); |
| 683 browser_window->Activate(); | 683 browser_window->Activate(false /* user_gesture */); |
| 684 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), | 684 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), |
| 685 ash::Shell::GetTargetRootWindow()); | 685 ash::Shell::GetTargetRootWindow()); |
| 686 gfx::Rect window_bounds; | 686 gfx::Rect window_bounds; |
| 687 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 687 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 688 gfx::Rect(), secondary_bounds, | 688 gfx::Rect(), secondary_bounds, |
| 689 PERSISTED, new_browser_window->browser(), | 689 PERSISTED, new_browser_window->browser(), |
| 690 gfx::Rect(), &window_bounds); | 690 gfx::Rect(), &window_bounds); |
| 691 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 691 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 692 // moved to ash and changed to include the result from | 692 // moved to ash and changed to include the result from |
| 693 // RearrangeVisibleWindowOnShow. | 693 // RearrangeVisibleWindowOnShow. |
| 694 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); | 694 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); |
| 695 } | 695 } |
| 696 | 696 |
| 697 // Activate another window in the primary display and create a new window. | 697 // Activate another window in the primary display and create a new window. |
| 698 // It should be created in the primary display. | 698 // It should be created in the primary display. |
| 699 { | 699 { |
| 700 another_browser_window->Activate(); | 700 another_browser_window->Activate(false /* user_gesture */); |
| 701 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), | 701 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), |
| 702 ash::Shell::GetTargetRootWindow()); | 702 ash::Shell::GetTargetRootWindow()); |
| 703 | 703 |
| 704 gfx::Rect window_bounds; | 704 gfx::Rect window_bounds; |
| 705 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 705 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 706 gfx::Rect(), secondary_bounds, | 706 gfx::Rect(), secondary_bounds, |
| 707 PERSISTED, new_browser_window->browser(), | 707 PERSISTED, new_browser_window->browser(), |
| 708 gfx::Rect(), &window_bounds); | 708 gfx::Rect(), &window_bounds); |
| 709 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 709 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 710 // moved to ash and changed to include the result from | 710 // moved to ash and changed to include the result from |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 p1600x1200)); | 1001 p1600x1200)); |
| 1002 // A popup that is sized to occupy the whole work area has default state. | 1002 // A popup that is sized to occupy the whole work area has default state. |
| 1003 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 1003 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 1004 GetWindowShowState(ui::SHOW_STATE_DEFAULT, | 1004 GetWindowShowState(ui::SHOW_STATE_DEFAULT, |
| 1005 ui::SHOW_STATE_NORMAL, | 1005 ui::SHOW_STATE_NORMAL, |
| 1006 BOTH, | 1006 BOTH, |
| 1007 trusted_popup->browser(), | 1007 trusted_popup->browser(), |
| 1008 p1600x1200, | 1008 p1600x1200, |
| 1009 p1600x1200)); | 1009 p1600x1200)); |
| 1010 } | 1010 } |
| OLD | NEW |