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 23 matching lines...) Expand all Loading... |
34 class TestBrowserWindowAura : public TestBrowserWindow { | 34 class TestBrowserWindowAura : public TestBrowserWindow { |
35 public: | 35 public: |
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(bool user_gesture) override { |
45 native_window_->Show(); | 45 native_window_->Show(); |
46 Activate(user_gesture); | 46 Activate(user_gesture); |
47 } | 47 } |
48 void Hide() override { native_window_->Hide(); } | 48 void Hide() override { native_window_->Hide(); } |
49 void Activate(bool user_gesture) 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(); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 gfx::Rect(16, 32, 128, 256), | 487 gfx::Rect(16, 32, 128, 256), |
488 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 488 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
489 chrome::HOST_DESKTOP_TYPE_ASH))); | 489 chrome::HOST_DESKTOP_TYPE_ASH))); |
490 | 490 |
491 // Creating a panel to make sure it does not interfere with the positioning. | 491 // Creating a panel to make sure it does not interfere with the positioning. |
492 scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( | 492 scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( |
493 CreateTestWindowInShellWithId(2), | 493 CreateTestWindowInShellWithId(2), |
494 gfx::Rect(32, 48, 256, 512), | 494 gfx::Rect(32, 48, 256, 512), |
495 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 495 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
496 chrome::HOST_DESKTOP_TYPE_ASH))); | 496 chrome::HOST_DESKTOP_TYPE_ASH))); |
497 browser_window->Show(); | 497 browser_window->Show(false /* user_gesture */); |
498 { // Make sure that popups do not get changed. | 498 { // Make sure that popups do not get changed. |
499 gfx::Rect window_bounds; | 499 gfx::Rect window_bounds; |
500 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | 500 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), |
501 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, | 501 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, |
502 PERSISTED, browser_popup->browser(), | 502 PERSISTED, browser_popup->browser(), |
503 gfx::Rect(), &window_bounds); | 503 gfx::Rect(), &window_bounds); |
504 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); | 504 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
505 } | 505 } |
506 | 506 |
507 browser_window->Hide(); | 507 browser_window->Hide(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 ash::Shell::GetInstance()->set_target_root_window( | 631 ash::Shell::GetInstance()->set_target_root_window( |
632 ash::Shell::GetPrimaryRootWindow()); | 632 ash::Shell::GetPrimaryRootWindow()); |
633 | 633 |
634 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 634 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
635 | 635 |
636 // Create browser windows that are used as reference. | 636 // Create browser windows that are used as reference. |
637 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( | 637 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( |
638 CreateTestWindowInShellWithId(0), | 638 CreateTestWindowInShellWithId(0), |
639 gfx::Rect(10, 10, 200, 200), | 639 gfx::Rect(10, 10, 200, 200), |
640 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 640 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
641 browser_window->Show(); | 641 browser_window->Show(false /* user_gesture */); |
642 EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(), | 642 EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(), |
643 ash::Shell::GetTargetRootWindow()); | 643 ash::Shell::GetTargetRootWindow()); |
644 | 644 |
645 scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( | 645 scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( |
646 CreateTestWindowInShellWithId(1), | 646 CreateTestWindowInShellWithId(1), |
647 gfx::Rect(400, 10, 300, 300), | 647 gfx::Rect(400, 10, 300, 300), |
648 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 648 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
649 another_browser_window->Show(); | 649 another_browser_window->Show(false /* user_gesture */); |
650 | 650 |
651 // Creating a new window to verify the new placement. | 651 // Creating a new window to verify the new placement. |
652 scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( | 652 scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( |
653 CreateTestWindowInShellWithId(0), | 653 CreateTestWindowInShellWithId(0), |
654 gfx::Rect(), | 654 gfx::Rect(), |
655 Browser::CreateParams(profile.get(), | 655 Browser::CreateParams(profile.get(), |
656 chrome::HOST_DESKTOP_TYPE_ASH))); | 656 chrome::HOST_DESKTOP_TYPE_ASH))); |
657 | 657 |
658 // Make sure the primary root is active. | 658 // Make sure the primary root is active. |
659 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), | 659 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), |
(...skipping 341 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 |