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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 429 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 470 // Creating a popup handler here to make sure it does not interfere with the | 430 // Creating a popup handler here to make sure it does not interfere with the |
| 471 // existing windows. | 431 // existing windows. |
| 472 Browser::CreateParams native_params(profile.get(), | 432 Browser::CreateParams native_params(profile.get(), |
| 473 chrome::HOST_DESKTOP_TYPE_ASH); | 433 chrome::HOST_DESKTOP_TYPE_ASH); |
| 474 scoped_ptr<Browser> browser( | 434 scoped_ptr<Browser> browser( |
| 475 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 435 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
| 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<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( |
| 480 CreateTestWindowInShellWithId(0), | 440 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), |
| 481 gfx::Rect(16, 32, 640, 320), | |
| 482 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 441 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
| 483 | 442 |
| 484 // Creating a popup to make sure it does not interfere with the positioning. | 443 // Creating a popup to make sure it does not interfere with the positioning. |
| 485 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( | 444 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( |
| 486 CreateTestWindowInShellWithId(1), | 445 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 128, 256), |
| 487 gfx::Rect(16, 32, 128, 256), | |
| 488 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 446 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 489 chrome::HOST_DESKTOP_TYPE_ASH))); | 447 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 490 | 448 |
| 491 // Creating a panel to make sure it does not interfere with the positioning. | 449 // Creating a panel to make sure it does not interfere with the positioning. |
| 492 scoped_ptr<BrowserWindow> browser_panel(CreateTestBrowserWindow( | 450 scoped_ptr<TestBrowserWindowAura> browser_panel(CreateTestBrowserWindow( |
| 493 CreateTestWindowInShellWithId(2), | 451 CreateTestWindowInShellWithId(2), gfx::Rect(32, 48, 256, 512), |
| 494 gfx::Rect(32, 48, 256, 512), | |
| 495 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 452 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 496 chrome::HOST_DESKTOP_TYPE_ASH))); | 453 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 497 browser_window->Show(); | 454 browser_window->Show(); |
| 498 { // Make sure that popups do not get changed. | 455 { // Make sure that popups do not get changed. |
| 499 gfx::Rect window_bounds; | 456 gfx::Rect window_bounds; |
| 500 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | 457 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), |
| 501 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, | 458 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, |
| 502 PERSISTED, browser_popup->browser(), | 459 PERSISTED, browser_popup->browser(), |
| 503 gfx::Rect(), &window_bounds); | 460 gfx::Rect(), &window_bounds); |
| 504 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); | 461 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 523 EXPECT_EQ( | 480 EXPECT_EQ( |
| 524 gfx::Rect( | 481 gfx::Rect( |
| 525 std::max(ash::WindowPositioner::kDesktopBorderSize, | 482 std::max(ash::WindowPositioner::kDesktopBorderSize, |
| 526 (1600 - ash::WindowPositioner::kMaximumWindowWidth) / 2), | 483 (1600 - ash::WindowPositioner::kMaximumWindowWidth) / 2), |
| 527 ash::WindowPositioner::kDesktopBorderSize, | 484 ash::WindowPositioner::kDesktopBorderSize, |
| 528 std::min(ash::WindowPositioner::kMaximumWindowWidth, | 485 std::min(ash::WindowPositioner::kMaximumWindowWidth, |
| 529 1600 - 2 * ash::WindowPositioner::kDesktopBorderSize), | 486 1600 - 2 * ash::WindowPositioner::kDesktopBorderSize), |
| 530 1200 - ash::WindowPositioner::kDesktopBorderSize).ToString(), | 487 1200 - ash::WindowPositioner::kDesktopBorderSize).ToString(), |
| 531 window_bounds.ToString()); | 488 window_bounds.ToString()); |
| 532 } | 489 } |
| 490 | |
| 491 // Explicitly delete browsers since they're not owned by | |
|
msw
2015/07/08 01:14:00
Hmm, should TestBrowserWindowAura own its browsers
xdai1
2015/07/08 21:34:21
This is a little tricky here. Since we modified Cr
| |
| 492 // TestBrowserWindowAura. | |
| 493 delete browser_window->browser(); | |
| 494 delete browser_popup->browser(); | |
| 495 delete browser_panel->browser(); | |
| 533 } | 496 } |
| 534 | 497 |
| 535 // On desktop linux aura, we currently don't use the ash frame, breaking some | 498 // On desktop linux aura, we currently don't use the ash frame, breaking some |
| 536 // tests which expect ash sizes: http://crbug.com/303862 | 499 // tests which expect ash sizes: http://crbug.com/303862 |
| 537 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 500 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 538 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop DISABLED_PlaceNewBrowserWindow OnEmptyDesktop | 501 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop DISABLED_PlaceNewBrowserWindow OnEmptyDesktop |
| 539 #else | 502 #else |
| 540 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop PlaceNewBrowserWindowOnEmptyDe sktop | 503 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop PlaceNewBrowserWindowOnEmptyDe sktop |
| 541 #endif | 504 #endif |
| 542 | 505 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 gfx::Rect primary_bounds = ash::Shell::GetInstance()->GetScreen()-> | 590 gfx::Rect primary_bounds = ash::Shell::GetInstance()->GetScreen()-> |
| 628 GetPrimaryDisplay().bounds(); | 591 GetPrimaryDisplay().bounds(); |
| 629 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); | 592 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); |
| 630 | 593 |
| 631 ash::Shell::GetInstance()->set_target_root_window( | 594 ash::Shell::GetInstance()->set_target_root_window( |
| 632 ash::Shell::GetPrimaryRootWindow()); | 595 ash::Shell::GetPrimaryRootWindow()); |
| 633 | 596 |
| 634 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 597 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 635 | 598 |
| 636 // Create browser windows that are used as reference. | 599 // Create browser windows that are used as reference. |
| 637 scoped_ptr<BrowserWindow> browser_window(CreateTestBrowserWindow( | 600 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( |
| 638 CreateTestWindowInShellWithId(0), | 601 CreateTestWindowInShellWithId(0), gfx::Rect(10, 10, 200, 200), |
| 639 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 EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow()); |
| 643 ash::Shell::GetTargetRootWindow()); | |
| 644 | 606 |
| 645 scoped_ptr<BrowserWindow> another_browser_window(CreateTestBrowserWindow( | 607 scoped_ptr<TestBrowserWindowAura> another_browser_window( |
| 646 CreateTestWindowInShellWithId(1), | 608 CreateTestBrowserWindow( |
| 647 gfx::Rect(400, 10, 300, 300), | 609 CreateTestWindowInShellWithId(1), gfx::Rect(400, 10, 300, 300), |
| 648 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); | 610 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
| 611 gfx::NativeWindow another_native_window = | |
| 612 another_browser_window->GetNativeWindow(); | |
| 649 another_browser_window->Show(); | 613 another_browser_window->Show(); |
| 650 | 614 |
| 651 // Creating a new window to verify the new placement. | 615 // Creating a new window to verify the new placement. |
| 652 scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( | 616 scoped_ptr<TestBrowserWindowAura> new_browser_window(CreateTestBrowserWindow( |
| 653 CreateTestWindowInShellWithId(0), | 617 CreateTestWindowInShellWithId(0), gfx::Rect(), |
| 654 gfx::Rect(), | 618 Browser::CreateParams(profile.get(), chrome::HOST_DESKTOP_TYPE_ASH))); |
| 655 Browser::CreateParams(profile.get(), | |
| 656 chrome::HOST_DESKTOP_TYPE_ASH))); | |
| 657 | 619 |
| 658 // Make sure the primary root is active. | 620 // Make sure the primary root is active. |
| 659 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), | 621 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), |
| 660 ash::Shell::GetTargetRootWindow()); | 622 ash::Shell::GetTargetRootWindow()); |
| 661 | 623 |
| 662 // First new window should be in the primary. | 624 // First new window should be in the primary. |
| 663 { | 625 { |
| 664 gfx::Rect window_bounds; | 626 gfx::Rect window_bounds; |
| 665 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 627 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 666 gfx::Rect(), secondary_bounds, | 628 gfx::Rect(), secondary_bounds, |
| 667 PERSISTED, new_browser_window->browser(), | 629 PERSISTED, new_browser_window->browser(), |
| 668 gfx::Rect(), &window_bounds); | 630 gfx::Rect(), &window_bounds); |
| 669 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 631 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 670 // moved to ash and changed to include the result from | 632 // moved to ash and changed to include the result from |
| 671 // RearrangeVisibleWindowOnShow. | 633 // RearrangeVisibleWindowOnShow. |
| 672 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); | 634 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); |
| 673 } | 635 } |
| 674 | 636 |
| 675 // Move the window to the right side of the secondary display and create a new | 637 // 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. | 638 // window. It should be opened then on the secondary display. |
| 677 { | 639 { |
| 678 gfx::Display second_display = ash::Shell::GetScreen()-> | 640 gfx::Display second_display = ash::Shell::GetScreen()-> |
| 679 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); | 641 GetDisplayNearestPoint(gfx::Point(1600 + 100,10)); |
| 680 browser_window->GetNativeWindow()->SetBoundsInScreen( | 642 browser_window->GetNativeWindow()->SetBoundsInScreen( |
| 681 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), | 643 gfx::Rect(secondary_bounds.CenterPoint().x() - 100, 10, 200, 200), |
| 682 second_display); | 644 second_display); |
| 683 browser_window->Activate(); | 645 aura::client::GetActivationClient(native_window->GetRootWindow()) |
| 646 ->ActivateWindow(native_window); | |
| 684 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), | 647 EXPECT_NE(ash::Shell::GetPrimaryRootWindow(), |
| 685 ash::Shell::GetTargetRootWindow()); | 648 ash::Shell::GetTargetRootWindow()); |
| 686 gfx::Rect window_bounds; | 649 gfx::Rect window_bounds; |
| 687 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 650 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 688 gfx::Rect(), secondary_bounds, | 651 gfx::Rect(), secondary_bounds, |
| 689 PERSISTED, new_browser_window->browser(), | 652 PERSISTED, new_browser_window->browser(), |
| 690 gfx::Rect(), &window_bounds); | 653 gfx::Rect(), &window_bounds); |
| 691 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 654 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 692 // moved to ash and changed to include the result from | 655 // moved to ash and changed to include the result from |
| 693 // RearrangeVisibleWindowOnShow. | 656 // RearrangeVisibleWindowOnShow. |
| 694 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); | 657 EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); |
| 695 } | 658 } |
| 696 | 659 |
| 697 // Activate another window in the primary display and create a new window. | 660 // Activate another window in the primary display and create a new window. |
| 698 // It should be created in the primary display. | 661 // It should be created in the primary display. |
| 699 { | 662 { |
| 700 another_browser_window->Activate(); | 663 aura::client::GetActivationClient(another_native_window->GetRootWindow()) |
| 664 ->ActivateWindow(another_native_window); | |
| 701 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), | 665 EXPECT_EQ(ash::Shell::GetPrimaryRootWindow(), |
| 702 ash::Shell::GetTargetRootWindow()); | 666 ash::Shell::GetTargetRootWindow()); |
| 703 | 667 |
| 704 gfx::Rect window_bounds; | 668 gfx::Rect window_bounds; |
| 705 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, | 669 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, |
| 706 gfx::Rect(), secondary_bounds, | 670 gfx::Rect(), secondary_bounds, |
| 707 PERSISTED, new_browser_window->browser(), | 671 PERSISTED, new_browser_window->browser(), |
| 708 gfx::Rect(), &window_bounds); | 672 gfx::Rect(), &window_bounds); |
| 709 // TODO(oshima): Use exact bounds when the window_sizer_ash is | 673 // TODO(oshima): Use exact bounds when the window_sizer_ash is |
| 710 // moved to ash and changed to include the result from | 674 // moved to ash and changed to include the result from |
| 711 // RearrangeVisibleWindowOnShow. | 675 // RearrangeVisibleWindowOnShow. |
| 712 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); | 676 EXPECT_TRUE(primary_bounds.Contains(window_bounds)); |
| 713 } | 677 } |
| 678 | |
| 679 // Explicitly delete browsers. | |
| 680 delete browser_window->browser(); | |
| 681 delete another_browser_window->browser(); | |
| 682 delete new_browser_window->browser(); | |
| 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(CreateTestBrowserWindow( |
| 730 CreateTestWindowInShellWithId(0), | 699 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), |
| 731 gfx::Rect(16, 32, 640, 320), | |
| 732 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 700 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
| 733 chrome::HOST_DESKTOP_TYPE_ASH))); | 701 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 734 | 702 |
| 735 // Create also a popup browser since that behaves different. | 703 // Create also a popup browser since that behaves different. |
| 736 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( | 704 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( |
| 737 CreateTestWindowInShellWithId(1), | 705 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320), |
| 738 gfx::Rect(16, 32, 640, 320), | |
| 739 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 706 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 740 chrome::HOST_DESKTOP_TYPE_ASH))); | 707 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 741 | 708 |
| 742 // Tabbed windows should retrieve the saved window state - since there is a | 709 // Tabbed windows should retrieve the saved window state - since there is a |
| 743 // top window. | 710 // top window. |
| 744 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, | 711 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, |
| 745 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 712 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
| 746 ui::SHOW_STATE_NORMAL, | 713 ui::SHOW_STATE_NORMAL, |
| 747 BOTH, | 714 BOTH, |
| 748 browser_window->browser(), | 715 browser_window->browser(), |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 778 ui::SHOW_STATE_NORMAL, | 745 ui::SHOW_STATE_NORMAL, |
| 779 BOTH, | 746 BOTH, |
| 780 browser_popup->browser(), | 747 browser_popup->browser(), |
| 781 p1600x1200, | 748 p1600x1200, |
| 782 p1600x1200)); | 749 p1600x1200)); |
| 783 | 750 |
| 784 // Now create a top level window and check again for both. Only the tabbed | 751 // Now create a top level window and check again for both. Only the tabbed |
| 785 // window should follow the top level window's state. | 752 // window should follow the top level window's state. |
| 786 // Creating a browser & window to play with. | 753 // Creating a browser & window to play with. |
| 787 scoped_ptr<TestBrowserWindowAura> browser_window2(CreateTestBrowserWindow( | 754 scoped_ptr<TestBrowserWindowAura> browser_window2(CreateTestBrowserWindow( |
| 788 CreateTestWindowInShellWithId(3), | 755 CreateTestWindowInShellWithId(3), gfx::Rect(16, 32, 640, 320), |
| 789 gfx::Rect(16, 32, 640, 320), | |
| 790 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 756 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
| 791 chrome::HOST_DESKTOP_TYPE_ASH))); | 757 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 792 | 758 |
| 793 // A tabbed window should now take the top level window state. | 759 // A tabbed window should now take the top level window state. |
| 794 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 760 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 795 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 761 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
| 796 ui::SHOW_STATE_DEFAULT, | 762 ui::SHOW_STATE_DEFAULT, |
| 797 BOTH, | 763 BOTH, |
| 798 browser_window->browser(), | 764 browser_window->browser(), |
| 799 p1600x1200, | 765 p1600x1200, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 822 browser_window->Hide(); | 788 browser_window->Hide(); |
| 823 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, | 789 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, |
| 824 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 790 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
| 825 ui::SHOW_STATE_DEFAULT, | 791 ui::SHOW_STATE_DEFAULT, |
| 826 BOTH, | 792 BOTH, |
| 827 browser_window2->browser(), | 793 browser_window2->browser(), |
| 828 tiny_screen, | 794 tiny_screen, |
| 829 tiny_screen)); | 795 tiny_screen)); |
| 830 | 796 |
| 831 } | 797 } |
| 798 | |
| 799 // Explictly delete browsers. | |
| 800 delete browser_window->browser(); | |
| 801 delete browser_popup->browser(); | |
| 802 delete browser_window2->browser(); | |
| 832 } | 803 } |
| 833 | 804 |
| 834 // Test that the default show state override behavior is properly handled. | 805 // Test that the default show state override behavior is properly handled. |
| 835 TEST_F(WindowSizerAshTest, TestShowStateDefaults) { | 806 TEST_F(WindowSizerAshTest, TestShowStateDefaults) { |
| 836 // Creating a browser & window to play with. | 807 // Creating a browser & window to play with. |
| 837 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 808 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 838 | 809 |
| 839 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( | 810 scoped_ptr<TestBrowserWindowAura> browser_window(CreateTestBrowserWindow( |
| 840 CreateTestWindowInShellWithId(0), | 811 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), |
| 841 gfx::Rect(16, 32, 640, 320), | |
| 842 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), | 812 Browser::CreateParams(Browser::TYPE_TABBED, profile.get(), |
| 843 chrome::HOST_DESKTOP_TYPE_ASH))); | 813 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 844 | 814 |
| 845 // Create also a popup browser since that behaves slightly different for | 815 // Create also a popup browser since that behaves slightly different for |
| 846 // defaults. | 816 // defaults. |
| 847 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( | 817 scoped_ptr<TestBrowserWindowAura> browser_popup(CreateTestBrowserWindow( |
| 848 CreateTestWindowInShellWithId(1), | 818 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 128, 256), |
| 849 gfx::Rect(16, 32, 128, 256), | |
| 850 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), | 819 Browser::CreateParams(Browser::TYPE_POPUP, profile.get(), |
| 851 chrome::HOST_DESKTOP_TYPE_ASH))); | 820 chrome::HOST_DESKTOP_TYPE_ASH))); |
| 852 | 821 |
| 853 // Check that a browser creation state always get used if not given as | 822 // 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. | 823 // SHOW_STATE_DEFAULT. On Windows ASH it should be SHOW_STATE_MAXIMIZED. |
| 855 ui::WindowShowState window_show_state = | 824 ui::WindowShowState window_show_state = |
| 856 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, | 825 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, |
| 857 ui::SHOW_STATE_MAXIMIZED, | 826 ui::SHOW_STATE_MAXIMIZED, |
| 858 DEFAULT, | 827 DEFAULT, |
| 859 browser_window->browser(), | 828 browser_window->browser(), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 p1600x1200, | 869 p1600x1200, |
| 901 p1600x1200), ui::SHOW_STATE_MAXIMIZED); | 870 p1600x1200), ui::SHOW_STATE_MAXIMIZED); |
| 902 | 871 |
| 903 // The popup should favor the initial show state over the command line. | 872 // The popup should favor the initial show state over the command line. |
| 904 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, | 873 EXPECT_EQ(GetWindowShowState(ui::SHOW_STATE_NORMAL, |
| 905 ui::SHOW_STATE_NORMAL, | 874 ui::SHOW_STATE_NORMAL, |
| 906 BOTH, | 875 BOTH, |
| 907 browser_popup->browser(), | 876 browser_popup->browser(), |
| 908 p1600x1200, | 877 p1600x1200, |
| 909 p1600x1200), ui::SHOW_STATE_NORMAL); | 878 p1600x1200), ui::SHOW_STATE_NORMAL); |
| 879 | |
| 880 // Explicitly delete browsers. | |
| 881 delete browser_window->browser(); | |
| 882 delete browser_popup->browser(); | |
| 910 } | 883 } |
| 911 | 884 |
| 912 TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { | 885 TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { |
| 913 // Create a browser to pass into the GetWindowBounds function. | 886 // Create a browser to pass into the GetWindowBounds function. |
| 914 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 887 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 915 Browser::CreateParams native_params(profile.get(), | 888 Browser::CreateParams native_params(profile.get(), |
| 916 chrome::HOST_DESKTOP_TYPE_ASH); | 889 chrome::HOST_DESKTOP_TYPE_ASH); |
| 917 scoped_ptr<Browser> browser( | 890 scoped_ptr<Browser> browser( |
| 918 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 891 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
| 919 | 892 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 } | 953 } |
| 981 } | 954 } |
| 982 | 955 |
| 983 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { | 956 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { |
| 984 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 957 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 985 Browser::CreateParams trusted_popup_create_params( | 958 Browser::CreateParams trusted_popup_create_params( |
| 986 Browser::TYPE_POPUP, profile.get(), chrome::HOST_DESKTOP_TYPE_ASH); | 959 Browser::TYPE_POPUP, profile.get(), chrome::HOST_DESKTOP_TYPE_ASH); |
| 987 trusted_popup_create_params.trusted_source = true; | 960 trusted_popup_create_params.trusted_source = true; |
| 988 | 961 |
| 989 scoped_ptr<TestBrowserWindowAura> trusted_popup(CreateTestBrowserWindow( | 962 scoped_ptr<TestBrowserWindowAura> trusted_popup(CreateTestBrowserWindow( |
| 990 CreateTestWindowInShellWithId(1), | 963 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320), |
| 991 gfx::Rect(16, 32, 640, 320), | |
| 992 trusted_popup_create_params)); | 964 trusted_popup_create_params)); |
| 993 // Trusted popup windows should follow the saved show state and ignore the | 965 // Trusted popup windows should follow the saved show state and ignore the |
| 994 // last show state. | 966 // last show state. |
| 995 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 967 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 996 GetWindowShowState(ui::SHOW_STATE_DEFAULT, | 968 GetWindowShowState(ui::SHOW_STATE_DEFAULT, |
| 997 ui::SHOW_STATE_NORMAL, | 969 ui::SHOW_STATE_NORMAL, |
| 998 BOTH, | 970 BOTH, |
| 999 trusted_popup->browser(), | 971 trusted_popup->browser(), |
| 1000 p1280x1024, | 972 p1280x1024, |
| 1001 p1600x1200)); | 973 p1600x1200)); |
| 1002 // A popup that is sized to occupy the whole work area has default state. | 974 // A popup that is sized to occupy the whole work area has default state. |
| 1003 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 975 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 1004 GetWindowShowState(ui::SHOW_STATE_DEFAULT, | 976 GetWindowShowState(ui::SHOW_STATE_DEFAULT, |
| 1005 ui::SHOW_STATE_NORMAL, | 977 ui::SHOW_STATE_NORMAL, |
| 1006 BOTH, | 978 BOTH, |
| 1007 trusted_popup->browser(), | 979 trusted_popup->browser(), |
| 1008 p1600x1200, | 980 p1600x1200, |
| 1009 p1600x1200)); | 981 p1600x1200)); |
| 982 | |
| 983 // Explicitly delete browser. | |
| 984 delete trusted_popup->browser(); | |
| 1010 } | 985 } |
| OLD | NEW |