Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 23 #include "ui/aura/test/test_windows.h" | 23 #include "ui/aura/test/test_windows.h" |
| 24 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
| 25 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
| 26 #include "ui/wm/public/activation_client.h" | 26 #include "ui/wm/public/activation_client.h" |
| 27 | 27 |
| 28 typedef ash::test::AshTestBase WindowSizerAshTest; | 28 typedef ash::test::AshTestBase WindowSizerAshTest; |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 // A browser window proxy which is able to associate an aura native window with | |
| 33 // it. | |
| 34 class TestBrowserWindowAura : public TestBrowserWindow { | |
| 35 public: | |
| 36 // |native_window| will still be owned by the caller after the constructor | |
| 37 // was called. | |
| 38 explicit TestBrowserWindowAura(aura::Window* native_window) | |
| 39 : native_window_(native_window) { | |
| 40 } | |
| 41 ~TestBrowserWindowAura() override {} | |
| 42 | |
| 43 // TestBrowserWindow overrides: | |
| 44 void Show() override { | |
| 45 native_window_->Show(); | |
| 46 Activate(); | |
| 47 } | |
| 48 void Hide() override { native_window_->Hide(); } | |
| 49 void Activate() override { | |
| 50 aura::client::GetActivationClient( | |
| 51 native_window_->GetRootWindow())->ActivateWindow(native_window_.get()); | |
| 52 } | |
| 53 gfx::NativeWindow GetNativeWindow() const override { | |
| 54 return native_window_.get(); | |
| 55 } | |
| 56 gfx::Rect GetBounds() const override { return native_window_->bounds(); } | |
| 57 | |
| 58 Browser* browser() { return browser_.get(); } | |
| 59 | |
| 60 void CreateBrowser(const Browser::CreateParams& params) { | |
| 61 Browser::CreateParams create_params = params; | |
| 62 create_params.window = this; | |
| 63 browser_.reset(new Browser(create_params)); | |
| 64 if (browser_->is_type_tabbed() || browser_->is_app()) { | |
| 65 ash::wm::GetWindowState(native_window_.get())-> | |
| 66 set_window_position_managed(true); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 private: | |
| 71 scoped_ptr<Browser> browser_; | |
| 72 scoped_ptr<aura::Window> native_window_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(TestBrowserWindowAura); | |
| 75 }; | |
| 76 | |
| 77 scoped_ptr<TestBrowserWindowAura> CreateTestBrowserWindow( | 32 scoped_ptr<TestBrowserWindowAura> CreateTestBrowserWindow( |
| 78 aura::Window* window, | 33 aura::Window* window, |
| 79 const gfx::Rect& bounds, | 34 const gfx::Rect& bounds, |
| 80 const Browser::CreateParams& params) { | 35 const Browser::CreateParams& params) { |
| 81 if (!bounds.IsEmpty()) | 36 if (!bounds.IsEmpty()) |
| 82 window->SetBounds(bounds); | 37 window->SetBounds(bounds); |
| 83 scoped_ptr<TestBrowserWindowAura> browser_window( | 38 scoped_ptr<TestBrowserWindowAura> browser_window( |
| 84 new TestBrowserWindowAura(window)); | 39 new TestBrowserWindowAura(window)); |
| 85 browser_window->CreateBrowser(params); | 40 browser_window->CreateBrowser(params); |
| 41 if (browser_window->browser()->is_type_tabbed() || | |
| 42 browser_window->browser()->is_app()) { | |
| 43 ash::wm::GetWindowState(browser_window->GetNativeWindow()) | |
| 44 ->set_window_position_managed(true); | |
| 45 } | |
| 86 return browser_window.Pass(); | 46 return browser_window.Pass(); |
| 87 } | 47 } |
| 88 | 48 |
| 89 } // namespace | 49 } // namespace |
| 90 | 50 |
| 91 // On desktop linux aura, we currently don't use the ash frame, breaking some | 51 // On desktop linux aura, we currently don't use the ash frame, breaking some |
| 92 // tests which expect ash sizes: http://crbug.com/303862 | 52 // tests which expect ash sizes: http://crbug.com/303862 |
| 93 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 53 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 94 #define MAYBE_DefaultSizeCase DISABLED_DefaultSizeCase | 54 #define MAYBE_DefaultSizeCase DISABLED_DefaultSizeCase |
| 95 #else | 55 #else |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 | 436 |
| 477 // Creating a popup handler here to make sure it does not interfere with the | 437 // Creating a popup handler here to make sure it does not interfere with the |
| 478 // existing windows. | 438 // existing windows. |
| 479 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( | 439 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( |
| 480 CreateTestWindowInShellWithId(0), | 440 CreateTestWindowInShellWithId(0), |
| 481 gfx::Rect(16, 32, 640, 320), | 441 gfx::Rect(16, 32, 640, 320), |
| 482 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 442 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
| 483 | 443 |
| 484 // Creating a popup to make sure it does not interfere with the positioning. | 444 // Creating a popup to make sure it does not interfere with the positioning. |
| 485 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( | 445 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( |
| 486 CreateTestWindowInShellWithId(1), | 446 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 128, 256), |
| 487 gfx::Rect(16, 32, 128, 256), | |
| 488 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 447 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 489 chrome::HOST_DESKTOP_TYPE_ASH))); | 448 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 490 | 449 |
| 491 // Creating a panel to make sure it does not interfere with the positioning. | 450 // Creating a panel to make sure it does not interfere with the positioning. |
| 492 scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( | 451 scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( |
| 493 CreateTestWindowInShellWithId(2), | 452 CreateTestWindowInShellWithId(2), |
| 494 gfx::Rect(32, 48, 256, 512), | 453 gfx::Rect(32, 48, 256, 512), |
| 495 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 454 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 496 chrome::HOST_DESKTOP_TYPE_ASH))); | 455 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 497 browser_window->Show(); | 456 browser_window->Show(); |
| 457 aura::client::GetActivationClient( | |
| 458 browser_window->GetNativeWindow()->GetRootWindow()) | |
| 459 ->ActivateWindow(browser_window->GetNativeWindow()); | |
|
msw
2015/07/07 18:11:55
nit: i wonder if these activations are actually ne
xdai1
2015/07/08 00:26:21
I tried to delete these activations and it makes n
msw
2015/07/08 01:14:00
yeah, remove them if they're not needed.
| |
| 498 { // Make sure that popups do not get changed. | 460 { // Make sure that popups do not get changed. |
| 499 gfx::Rect window_bounds; | 461 gfx::Rect window_bounds; |
| 500 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | 462 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), |
| 501 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, | 463 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, |
| 502 PERSISTED, browser_popup->browser(), | 464 PERSISTED, browser_popup->browser(), |
| 503 gfx::Rect(), &window_bounds); | 465 gfx::Rect(), &window_bounds); |
| 504 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); | 466 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
| 505 } | 467 } |
| 506 | 468 |
| 507 browser_window->Hide(); | 469 browser_window->Hide(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 ash::Shell::GetInstance()->set_target_root_window( | 593 ash::Shell::GetInstance()->set_target_root_window( |
| 632 ash::Shell::GetPrimaryRootWindow()); | 594 ash::Shell::GetPrimaryRootWindow()); |
| 633 | 595 |
| 634 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 596 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 635 | 597 |
| 636 // Create browser windows that are used as reference. | 598 // Create browser windows that are used as reference. |
| 637 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( | 599 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( |
| 638 CreateTestWindowInShellWithId(0), | 600 CreateTestWindowInShellWithId(0), |
| 639 gfx::Rect(10, 10, 200, 200), | 601 gfx::Rect(10, 10, 200, 200), |
| 640 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 602 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
| 603 gfx::NativeWindow native_window = browser_window->GetNativeWindow(); | |
| 641 browser_window->Show(); | 604 browser_window->Show(); |
| 642 EXPECT_EQ(browser_window->GetNativeWindow()->GetRootWindow(), | 605 aura::client::GetActivationClient(native_window->GetRootWindow()) |
| 643 ash::Shell::GetTargetRootWindow()); | 606 ->ActivateWindow(native_window); |
| 607 EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow()); | |
| 644 | 608 |
| 645 scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( | 609 scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( |
| 646 CreateTestWindowInShellWithId(1), | 610 CreateTestWindowInShellWithId(1), |
| 647 gfx::Rect(400, 10, 300, 300), | 611 gfx::Rect(400, 10, 300, 300), |
| 648 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 612 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
| 613 gfx::NativeWindow another_native_window = | |
| 614 another_browser_window->GetNativeWindow(); | |
| 649 another_browser_window->Show(); | 615 another_browser_window->Show(); |
| 616 aura::client::GetActivationClient(another_native_window->GetRootWindow()) | |
| 617 ->ActivateWindow(another_native_window); | |
| 650 | 618 |
| 651 // Creating a new window to verify the new placement. | 619 // Creating a new window to verify the new placement. |
| 652 scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( | 620 scoped_ptr<TestBrowserWindowAura> new_browser_window( |
| 653 CreateTestWindowInShellWithId(0), | 621 CreateTestBrowserWindow( |
| 654 gfx::Rect(), | 622 CreateTestWindowInShellWithId(0), gfx::Rect(), |
| 655 Browser::CreateParams(profile.get(), | 623 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
| 656 chrome::HOST_DESKTOP_TYPE_ASH))); | |
| 657 | 624 |
| 658 // Make sure the primary root is active. | 625 // Make sure the primary root is active. |
| 659 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), | 626 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), |
| 660 ash::Shell::GetTargetRootWindow()); | 627 ash::Shell::GetTargetRootWindow()); |
| 661 | 628 |
| 662 // First new window should be in the primary. | 629 // First new window should be in the primary. |
| 663 { | 630 { |
| 664 gfx::Rect window_bounds; | 631 gfx::Rect window_bounds; |
| 665 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 632 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 666 gfx::Rect(), secondary_bounds, | 633 gfx::Rect(), secondary_bounds, |
| 667 PERSISTED, new_browser_window->browser(), | 634 PERSISTED, new_browser_window->browser(), |
| 668 gfx::Rect(), &window_bounds); | 635 gfx::Rect(), &window_bounds); |
| 669 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 636 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 670 // moved to ash and changed to include the result from | 637 // moved to ash and changed to include the result from |
| 671 // RearrangeVisibleWindowOnShow. | 638 // RearrangeVisibleWindowOnShow. |
| 672 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); | 639 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); |
| 673 } | 640 } |
| 674 | 641 |
| 675 // Move the window to the right side of the secondary display and create a new | 642 // 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. | 643 // window. It should be opened then on the secondary display. |
| 677 { | 644 { |
| 678 gfx::Display second_display = ash::Shell::GetScreen()-> | 645 gfx::Display second_display = ash::Shell::GetScreen()-> |
| 679 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); | 646 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); |
| 680 browser_window->GetNativeWindow()->SetBoundsInScreen( | 647 browser_window->GetNativeWindow()->SetBoundsInScreen( |
| 681 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), | 648 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), |
| 682 second_display); | 649 second_display); |
| 683 browser_window->Activate(); | 650 aura::client::GetActivationClient(native_window->GetRootWindow()) |
| 651 ->ActivateWindow(native_window); | |
| 684 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), | 652 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), |
| 685 ash::Shell::GetTargetRootWindow()); | 653 ash::Shell::GetTargetRootWindow()); |
| 686 gfx::Rect window_bounds; | 654 gfx::Rect window_bounds; |
| 687 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 655 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 688 gfx::Rect(), secondary_bounds, | 656 gfx::Rect(), secondary_bounds, |
| 689 PERSISTED, new_browser_window->browser(), | 657 PERSISTED, new_browser_window->browser(), |
| 690 gfx::Rect(), &window_bounds); | 658 gfx::Rect(), &window_bounds); |
| 691 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 659 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 692 // moved to ash and changed to include the result from | 660 // moved to ash and changed to include the result from |
| 693 // RearrangeVisibleWindowOnShow. | 661 // RearrangeVisibleWindowOnShow. |
| 694 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); | 662 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); |
| 695 } | 663 } |
| 696 | 664 |
| 697 // Activate another window in the primary display and create a new window. | 665 // Activate another window in the primary display and create a new window. |
| 698 // It should be created in the primary display. | 666 // It should be created in the primary display. |
| 699 { | 667 { |
| 700 another_browser_window->Activate(); | 668 aura::client::GetActivationClient(another_native_window->GetRootWindow()) |
| 669 ->ActivateWindow(another_native_window); | |
| 701 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), | 670 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), |
| 702 ash::Shell::GetTargetRootWindow()); | 671 ash::Shell::GetTargetRootWindow()); |
| 703 | 672 |
| 704 gfx::Rect window_bounds; | 673 gfx::Rect window_bounds; |
| 705 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 674 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 706 gfx::Rect(), secondary_bounds, | 675 gfx::Rect(), secondary_bounds, |
| 707 PERSISTED, new_browser_window->browser(), | 676 PERSISTED, new_browser_window->browser(), |
| 708 gfx::Rect(), &window_bounds); | 677 gfx::Rect(), &window_bounds); |
| 709 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 678 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 710 // moved to ash and changed to include the result from | 679 // moved to ash and changed to include the result from |
| 711 // RearrangeVisibleWindowOnShow. | 680 // RearrangeVisibleWindowOnShow. |
| 712 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); | 681 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); |
| 713 } | 682 } |
| 714 } | 683 } |
| 715 | 684 |
| 716 // On desktop linux aura, we currently don't use the ash frame, breaking some | 685 // On desktop linux aura, we currently don't use the ash frame, breaking some |
| 717 // tests which expect ash sizes: http://crbug.com/303862 | 686 // tests which expect ash sizes: http://crbug.com/303862 |
| 718 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 687 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 719 #define MAYBE_TestShowState DISABLED_TestShowState | 688 #define MAYBE_TestShowState DISABLED_TestShowState |
| 720 #else | 689 #else |
| 721 #define MAYBE_TestShowState TestShowState | 690 #define MAYBE_TestShowState TestShowState |
| 722 #endif | 691 #endif |
| 723 | 692 |
| 724 // Test that the show state is properly returned for non default cases. | 693 // Test that the show state is properly returned for non default cases. |
| 725 TEST_F(WindowSizerAshTest, MAYBE_TestShowState) { | 694 TEST_F(WindowSizerAshTest, MAYBE_TestShowState) { |
| 726 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 695 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 727 | 696 |
| 728 // Creating a browser & window to play with. | 697 // Creating a browser & window to play with. |
| 729 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( | 698 scoped_ptr<TestBrowserWindowAura> browser_window( |
| 730 CreateTestWindowInShellWithId(0), | 699 CreateTestBrowserWindow( |
| 731 gfx::Rect(16, 32, 640, 320), | 700 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), |
| 732 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 701 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
| 733 chrome::HOST_DESKTOP_TYPE_ASH))); | 702 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 734 | 703 |
| 735 // Create also a popup browser since that behaves different. | 704 // Create also a popup browser since that behaves different. |
| 736 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( | 705 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( |
| 737 CreateTestWindowInShellWithId(1), | 706 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320), |
| 738 gfx::Rect(16, 32, 640, 320), | |
| 739 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 707 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 740 chrome::HOST_DESKTOP_TYPE_ASH))); | 708 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 741 | 709 |
| 742 // Tabbed windows should retrieve the saved window state - since there is a | 710 // Tabbed windows should retrieve the saved window state - since there is a |
| 743 // top window. | 711 // top window. |
| 744 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, | 712 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, |
| 745 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 713 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
| 746 ui::SHOW_STATE_NORMAL, | 714 ui::SHOW_STATE_NORMAL, |
| 747 BOTH, | 715 BOTH, |
| 748 browser_window->browser(), | 716 browser_window->browser(), |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 777 GetWindowShowState(ui::SHOW_STATE_DEFAULT, | 745 GetWindowShowState(ui::SHOW_STATE_DEFAULT, |
| 778 ui::SHOW_STATE_NORMAL, | 746 ui::SHOW_STATE_NORMAL, |
| 779 BOTH, | 747 BOTH, |
| 780 browser_popup->browser(), | 748 browser_popup->browser(), |
| 781 p1600x1200, | 749 p1600x1200, |
| 782 p1600x1200)); | 750 p1600x1200)); |
| 783 | 751 |
| 784 // Now create a top level window and check again for both. Only the tabbed | 752 // Now create a top level window and check again for both. Only the tabbed |
| 785 // window should follow the top level window's state. | 753 // window should follow the top level window's state. |
| 786 // Creating a browser & window to play with. | 754 // Creating a browser & window to play with. |
| 787 scoped_ptr<TestBrowserWindowAura> browser_window2(CreateTestBrowserWindow( | 755 scoped_ptr<TestBrowserWindowAura> browser_window2( |
| 788 CreateTestWindowInShellWithId(3), | 756 CreateTestBrowserWindow( |
| 789 gfx::Rect(16, 32, 640, 320), | 757 CreateTestWindowInShellWithId(3), gfx::Rect(16, 32, 640, 320), |
| 790 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 758 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
| 791 chrome::HOST_DESKTOP_TYPE_ASH))); | 759 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 792 | 760 |
| 793 // A tabbed window should now take the top level window state. | 761 // A tabbed window should now take the top level window state. |
| 794 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 762 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 795 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 763 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
| 796 ui::SHOW_STATE_DEFAULT, | 764 ui::SHOW_STATE_DEFAULT, |
| 797 BOTH, | 765 BOTH, |
| 798 browser_window->browser(), | 766 browser_window->browser(), |
| 799 p1600x1200, | 767 p1600x1200, |
| 800 p1600x1200)); | 768 p1600x1200)); |
| 801 // Non tabbed windows should always follow the window saved visibility state. | 769 // Non tabbed windows should always follow the window saved visibility state. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 829 tiny_screen)); | 797 tiny_screen)); |
| 830 | 798 |
| 831 } | 799 } |
| 832 } | 800 } |
| 833 | 801 |
| 834 // Test that the default show state override behavior is properly handled. | 802 // Test that the default show state override behavior is properly handled. |
| 835 TEST_F(WindowSizerAshTest, TestShowStateDefaults) { | 803 TEST_F(WindowSizerAshTest, TestShowStateDefaults) { |
| 836 // Creating a browser & window to play with. | 804 // Creating a browser & window to play with. |
| 837 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 805 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 838 | 806 |
| 839 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( | 807 scoped_ptr<TestBrowserWindowAura> browser_window( |
| 840 CreateTestWindowInShellWithId(0), | 808 CreateTestBrowserWindow( |
| 841 gfx::Rect(16, 32, 640, 320), | 809 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), |
| 842 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 810 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
| 843 chrome::HOST_DESKTOP_TYPE_ASH))); | 811 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 844 | 812 |
| 845 // Create also a popup browser since that behaves slightly different for | 813 // Create also a popup browser since that behaves slightly different for |
| 846 // defaults. | 814 // defaults. |
| 847 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( | 815 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( |
| 848 CreateTestWindowInShellWithId(1), | 816 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 128, 256), |
| 849 gfx::Rect(16, 32, 128, 256), | |
| 850 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 817 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 851 chrome::HOST_DESKTOP_TYPE_ASH))); | 818 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 852 | 819 |
| 853 // Check that a browser creation state always get used if not given as | 820 // Check that a browser creation state always get used if not given as |
| 854 // SHOW_STATE_DEFAULT. On Windows ASH it should be SHOW_STATE_MAXIMIZED. | 821 // SHOW_STATE_DEFAULT. On Windows ASH it should be SHOW_STATE_MAXIMIZED. |
| 855 ui::WindowShowState window_show_state = | 822 ui::WindowShowState window_show_state = |
| 856 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 823 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
| 857 ui::SHOW_STATE_MAXIMIZED, | 824 ui::SHOW_STATE_MAXIMIZED, |
| 858 DEFAULT, | 825 DEFAULT, |
| 859 browser_window->browser(), | 826 browser_window->browser(), |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 } | 947 } |
| 981 } | 948 } |
| 982 | 949 |
| 983 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { | 950 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { |
| 984 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 951 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 985 Browser::CreateParams trusted_popup_create_params( | 952 Browser::CreateParams trusted_popup_create_params( |
| 986 Browser::TYPE_POPUP, profile.get(), chrome::HOST_DESKTOP_TYPE_ASH); | 953 Browser::TYPE_POPUP, profile.get(), chrome::HOST_DESKTOP_TYPE_ASH); |
| 987 trusted_popup_create_params.trusted_source = true; | 954 trusted_popup_create_params.trusted_source = true; |
| 988 | 955 |
| 989 scoped_ptr<TestBrowserWindowAura> trusted_popup(CreateTestBrowserWindow( | 956 scoped_ptr<TestBrowserWindowAura> trusted_popup(CreateTestBrowserWindow( |
| 990 CreateTestWindowInShellWithId(1), | 957 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320), |
| 991 gfx::Rect(16, 32, 640, 320), | |
| 992 trusted_popup_create_params)); | 958 trusted_popup_create_params)); |
| 993 // Trusted popup windows should follow the saved show state and ignore the | 959 // Trusted popup windows should follow the saved show state and ignore the |
| 994 // last show state. | 960 // last show state. |
| 995 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 961 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 996 GetWindowShowState(ui::SHOW_STATE_DEFAULT, | 962 GetWindowShowState(ui::SHOW_STATE_DEFAULT, |
| 997 ui::SHOW_STATE_NORMAL, | 963 ui::SHOW_STATE_NORMAL, |
| 998 BOTH, | 964 BOTH, |
| 999 trusted_popup->browser(), | 965 trusted_popup->browser(), |
| 1000 p1280x1024, | 966 p1280x1024, |
| 1001 p1600x1200)); | 967 p1600x1200)); |
| 1002 // A popup that is sized to occupy the whole work area has default state. | 968 // A popup that is sized to occupy the whole work area has default state. |
| 1003 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 969 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 1004 GetWindowShowState(ui::SHOW_STATE_DEFAULT, | 970 GetWindowShowState(ui::SHOW_STATE_DEFAULT, |
| 1005 ui::SHOW_STATE_NORMAL, | 971 ui::SHOW_STATE_NORMAL, |
| 1006 BOTH, | 972 BOTH, |
| 1007 trusted_popup->browser(), | 973 trusted_popup->browser(), |
| 1008 p1600x1200, | 974 p1600x1200, |
| 1009 p1600x1200)); | 975 p1600x1200)); |
| 1010 } | 976 } |
| OLD | NEW |