| 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" |
| 11 #include "ash/wm/window_resizer.h" | 11 #include "ash/wm/window_resizer.h" |
| 12 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ptr_util.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "chrome/browser/ui/ash/ash_util.h" | 16 #include "chrome/browser/ui/ash/ash_util.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" | 18 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/test_browser_window_aura.h" | 20 #include "chrome/test/base/test_browser_window_aura.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 21 #include "content/public/test/render_view_test.h" | 22 #include "content/public/test/render_view_test.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "ui/aura/client/aura_constants.h" | 24 #include "ui/aura/client/aura_constants.h" |
| 24 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
| 25 #include "ui/aura/test/test_windows.h" | 26 #include "ui/aura/test/test_windows.h" |
| 26 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
| 27 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
| 28 #include "ui/wm/public/activation_client.h" | 29 #include "ui/wm/public/activation_client.h" |
| 29 | 30 |
| 30 typedef ash::test::AshTestBase WindowSizerAshTest; | 31 typedef ash::test::AshTestBase WindowSizerAshTest; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 scoped_ptr<Browser> CreateTestBrowser(aura::Window* window, | 35 std::unique_ptr<Browser> CreateTestBrowser(aura::Window* window, |
| 35 const gfx::Rect& bounds, | 36 const gfx::Rect& bounds, |
| 36 Browser::CreateParams* params) { | 37 Browser::CreateParams* params) { |
| 37 if (!bounds.IsEmpty()) | 38 if (!bounds.IsEmpty()) |
| 38 window->SetBounds(bounds); | 39 window->SetBounds(bounds); |
| 39 scoped_ptr<Browser> browser = | 40 std::unique_ptr<Browser> browser = |
| 40 chrome::CreateBrowserWithAuraTestWindowForParams(make_scoped_ptr(window), | 41 chrome::CreateBrowserWithAuraTestWindowForParams(base::WrapUnique(window), |
| 41 params); | 42 params); |
| 42 if (browser->is_type_tabbed() || browser->is_app()) { | 43 if (browser->is_type_tabbed() || browser->is_app()) { |
| 43 ash::wm::GetWindowState(browser->window()->GetNativeWindow()) | 44 ash::wm::GetWindowState(browser->window()->GetNativeWindow()) |
| 44 ->set_window_position_managed(true); | 45 ->set_window_position_managed(true); |
| 45 } | 46 } |
| 46 return browser; | 47 return browser; |
| 47 } | 48 } |
| 48 | 49 |
| 49 } // namespace | 50 } // namespace |
| 50 | 51 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 // tests which expect ash sizes: http://crbug.com/303862 | 420 // tests which expect ash sizes: http://crbug.com/303862 |
| 420 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 421 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 421 #define MAYBE_PlaceNewWindows DISABLED_PlaceNewWindows | 422 #define MAYBE_PlaceNewWindows DISABLED_PlaceNewWindows |
| 422 #else | 423 #else |
| 423 #define MAYBE_PlaceNewWindows PlaceNewWindows | 424 #define MAYBE_PlaceNewWindows PlaceNewWindows |
| 424 #endif | 425 #endif |
| 425 | 426 |
| 426 // Test the placement of newly created windows. | 427 // Test the placement of newly created windows. |
| 427 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindows) { | 428 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindows) { |
| 428 // Create a browser to pass into the GetWindowBounds function. | 429 // Create a browser to pass into the GetWindowBounds function. |
| 429 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 430 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 430 // Creating a popup handler here to make sure it does not interfere with the | 431 // Creating a popup handler here to make sure it does not interfere with the |
| 431 // existing windows. | 432 // existing windows. |
| 432 Browser::CreateParams native_params(profile.get()); | 433 Browser::CreateParams native_params(profile.get()); |
| 433 scoped_ptr<Browser> browser( | 434 std::unique_ptr<Browser> browser( |
| 434 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 435 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
| 435 | 436 |
| 436 // 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 |
| 437 // existing windows. | 438 // existing windows. |
| 438 Browser::CreateParams params2(profile.get()); | 439 Browser::CreateParams params2(profile.get()); |
| 439 scoped_ptr<Browser> browser2(CreateTestBrowser( | 440 std::unique_ptr<Browser> browser2(CreateTestBrowser( |
| 440 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), ¶ms2)); | 441 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), ¶ms2)); |
| 441 BrowserWindow* browser_window = browser2->window(); | 442 BrowserWindow* browser_window = browser2->window(); |
| 442 | 443 |
| 443 // 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. |
| 444 Browser::CreateParams params_popup(Browser::TYPE_POPUP, profile.get()); | 445 Browser::CreateParams params_popup(Browser::TYPE_POPUP, profile.get()); |
| 445 scoped_ptr<Browser> browser_popup( | 446 std::unique_ptr<Browser> browser_popup( |
| 446 CreateTestBrowser(CreateTestWindowInShellWithId(1), | 447 CreateTestBrowser(CreateTestWindowInShellWithId(1), |
| 447 gfx::Rect(16, 32, 128, 256), ¶ms_popup)); | 448 gfx::Rect(16, 32, 128, 256), ¶ms_popup)); |
| 448 | 449 |
| 449 // 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. |
| 450 Browser::CreateParams params_panel(Browser::TYPE_POPUP, profile.get()); | 451 Browser::CreateParams params_panel(Browser::TYPE_POPUP, profile.get()); |
| 451 scoped_ptr<Browser> browser_panel( | 452 std::unique_ptr<Browser> browser_panel( |
| 452 CreateTestBrowser(CreateTestWindowInShellWithId(2), | 453 CreateTestBrowser(CreateTestWindowInShellWithId(2), |
| 453 gfx::Rect(32, 48, 256, 512), ¶ms_panel)); | 454 gfx::Rect(32, 48, 256, 512), ¶ms_panel)); |
| 454 | 455 |
| 455 browser_window->Show(); | 456 browser_window->Show(); |
| 456 { // Make sure that popups do not get changed. | 457 { // Make sure that popups do not get changed. |
| 457 gfx::Rect window_bounds; | 458 gfx::Rect window_bounds; |
| 458 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), | 459 GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), |
| 459 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, PERSISTED, | 460 gfx::Rect(50, 100, 300, 150), bottom_s1600x1200, PERSISTED, |
| 460 browser_popup.get(), gfx::Rect(), &window_bounds); | 461 browser_popup.get(), gfx::Rect(), &window_bounds); |
| 461 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); | 462 EXPECT_EQ("50,100 300x150", window_bounds.ToString()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop DISABLED_PlaceNewBrowserWindow
OnEmptyDesktop | 496 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop DISABLED_PlaceNewBrowserWindow
OnEmptyDesktop |
| 496 #else | 497 #else |
| 497 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop PlaceNewBrowserWindowOnEmptyDe
sktop | 498 #define MAYBE_PlaceNewBrowserWindowOnEmptyDesktop PlaceNewBrowserWindowOnEmptyDe
sktop |
| 498 #endif | 499 #endif |
| 499 | 500 |
| 500 // Test the placement of newly created windows on an empty desktop. | 501 // Test the placement of newly created windows on an empty desktop. |
| 501 // This test supplements "PlaceNewWindows" by testing the creation of a newly | 502 // This test supplements "PlaceNewWindows" by testing the creation of a newly |
| 502 // created browser window on an empty desktop. | 503 // created browser window on an empty desktop. |
| 503 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewBrowserWindowOnEmptyDesktop) { | 504 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewBrowserWindowOnEmptyDesktop) { |
| 504 // Create a browser to pass into the GetWindowBoundsAndShowState function. | 505 // Create a browser to pass into the GetWindowBoundsAndShowState function. |
| 505 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 506 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 506 Browser::CreateParams native_params(profile.get()); | 507 Browser::CreateParams native_params(profile.get()); |
| 507 scoped_ptr<Browser> browser( | 508 std::unique_ptr<Browser> browser( |
| 508 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 509 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
| 509 | 510 |
| 510 // A common screen size for Chrome OS devices where this behavior is | 511 // A common screen size for Chrome OS devices where this behavior is |
| 511 // desirable. | 512 // desirable. |
| 512 const gfx::Rect p1366x768(0, 0, 1366, 768); | 513 const gfx::Rect p1366x768(0, 0, 1366, 768); |
| 513 | 514 |
| 514 // If there is no previous state the window should get maximized if the | 515 // If there is no previous state the window should get maximized if the |
| 515 // screen is less than or equal to our limit (1366 pixels width). | 516 // screen is less than or equal to our limit (1366 pixels width). |
| 516 gfx::Rect window_bounds; | 517 gfx::Rect window_bounds; |
| 517 ui::WindowShowState out_show_state1 = ui::SHOW_STATE_DEFAULT; | 518 ui::WindowShowState out_show_state1 = ui::SHOW_STATE_DEFAULT; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // Test the placement of newly created windows on multiple dislays. | 581 // Test the placement of newly created windows on multiple dislays. |
| 581 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { | 582 TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { |
| 582 UpdateDisplay("1600x1200,1600x1200"); | 583 UpdateDisplay("1600x1200,1600x1200"); |
| 583 gfx::Rect primary_bounds = | 584 gfx::Rect primary_bounds = |
| 584 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 585 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 585 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); | 586 gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); |
| 586 | 587 |
| 587 ash::Shell::GetInstance()->set_target_root_window( | 588 ash::Shell::GetInstance()->set_target_root_window( |
| 588 ash::Shell::GetPrimaryRootWindow()); | 589 ash::Shell::GetPrimaryRootWindow()); |
| 589 | 590 |
| 590 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 591 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 591 | 592 |
| 592 // Create browser windows that are used as reference. | 593 // Create browser windows that are used as reference. |
| 593 Browser::CreateParams params(profile.get()); | 594 Browser::CreateParams params(profile.get()); |
| 594 scoped_ptr<Browser> browser(CreateTestBrowser( | 595 std::unique_ptr<Browser> browser(CreateTestBrowser( |
| 595 CreateTestWindowInShellWithId(0), gfx::Rect(10, 10, 200, 200), ¶ms)); | 596 CreateTestWindowInShellWithId(0), gfx::Rect(10, 10, 200, 200), ¶ms)); |
| 596 BrowserWindow* browser_window = browser->window(); | 597 BrowserWindow* browser_window = browser->window(); |
| 597 gfx::NativeWindow native_window = browser_window->GetNativeWindow(); | 598 gfx::NativeWindow native_window = browser_window->GetNativeWindow(); |
| 598 browser_window->Show(); | 599 browser_window->Show(); |
| 599 EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow()); | 600 EXPECT_EQ(native_window->GetRootWindow(), ash::Shell::GetTargetRootWindow()); |
| 600 | 601 |
| 601 Browser::CreateParams another_params(profile.get()); | 602 Browser::CreateParams another_params(profile.get()); |
| 602 scoped_ptr<Browser> another_browser( | 603 std::unique_ptr<Browser> another_browser( |
| 603 CreateTestBrowser(CreateTestWindowInShellWithId(1), | 604 CreateTestBrowser(CreateTestWindowInShellWithId(1), |
| 604 gfx::Rect(400, 10, 300, 300), &another_params)); | 605 gfx::Rect(400, 10, 300, 300), &another_params)); |
| 605 BrowserWindow* another_browser_window = another_browser->window(); | 606 BrowserWindow* another_browser_window = another_browser->window(); |
| 606 gfx::NativeWindow another_native_window = | 607 gfx::NativeWindow another_native_window = |
| 607 another_browser_window->GetNativeWindow(); | 608 another_browser_window->GetNativeWindow(); |
| 608 another_browser_window->Show(); | 609 another_browser_window->Show(); |
| 609 | 610 |
| 610 // Creating a new window to verify the new placement. | 611 // Creating a new window to verify the new placement. |
| 611 Browser::CreateParams new_params(profile.get()); | 612 Browser::CreateParams new_params(profile.get()); |
| 612 scoped_ptr<Browser> new_browser(CreateTestBrowser( | 613 std::unique_ptr<Browser> new_browser(CreateTestBrowser( |
| 613 CreateTestWindowInShellWithId(0), gfx::Rect(), &new_params)); | 614 CreateTestWindowInShellWithId(0), gfx::Rect(), &new_params)); |
| 614 | 615 |
| 615 // Make sure the primary root is active. | 616 // Make sure the primary root is active. |
| 616 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), | 617 ASSERT_EQ(ash::Shell::GetPrimaryRootWindow(), |
| 617 ash::Shell::GetTargetRootWindow()); | 618 ash::Shell::GetTargetRootWindow()); |
| 618 | 619 |
| 619 // First new window should be in the primary. | 620 // First new window should be in the primary. |
| 620 { | 621 { |
| 621 gfx::Rect window_bounds; | 622 gfx::Rect window_bounds; |
| 622 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), | 623 GetWindowBounds(p1600x1200, p1600x1200, secondary_bounds, gfx::Rect(), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // On desktop linux aura, we currently don't use the ash frame, breaking some | 674 // On desktop linux aura, we currently don't use the ash frame, breaking some |
| 674 // tests which expect ash sizes: http://crbug.com/303862 | 675 // tests which expect ash sizes: http://crbug.com/303862 |
| 675 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 676 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 676 #define MAYBE_TestShowState DISABLED_TestShowState | 677 #define MAYBE_TestShowState DISABLED_TestShowState |
| 677 #else | 678 #else |
| 678 #define MAYBE_TestShowState TestShowState | 679 #define MAYBE_TestShowState TestShowState |
| 679 #endif | 680 #endif |
| 680 | 681 |
| 681 // Test that the show state is properly returned for non default cases. | 682 // Test that the show state is properly returned for non default cases. |
| 682 TEST_F(WindowSizerAshTest, MAYBE_TestShowState) { | 683 TEST_F(WindowSizerAshTest, MAYBE_TestShowState) { |
| 683 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 684 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 684 | 685 |
| 685 // Creating a browser & window to play with. | 686 // Creating a browser & window to play with. |
| 686 Browser::CreateParams params(Browser::TYPE_TABBED, profile.get()); | 687 Browser::CreateParams params(Browser::TYPE_TABBED, profile.get()); |
| 687 scoped_ptr<Browser> browser(CreateTestBrowser( | 688 std::unique_ptr<Browser> browser(CreateTestBrowser( |
| 688 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), ¶ms)); | 689 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), ¶ms)); |
| 689 | 690 |
| 690 // Create also a popup browser since that behaves different. | 691 // Create also a popup browser since that behaves different. |
| 691 Browser::CreateParams params_popup(Browser::TYPE_POPUP, profile.get()); | 692 Browser::CreateParams params_popup(Browser::TYPE_POPUP, profile.get()); |
| 692 scoped_ptr<Browser> browser_popup( | 693 std::unique_ptr<Browser> browser_popup( |
| 693 CreateTestBrowser(CreateTestWindowInShellWithId(1), | 694 CreateTestBrowser(CreateTestWindowInShellWithId(1), |
| 694 gfx::Rect(16, 32, 640, 320), ¶ms_popup)); | 695 gfx::Rect(16, 32, 640, 320), ¶ms_popup)); |
| 695 | 696 |
| 696 // Tabbed windows should retrieve the saved window state - since there is a | 697 // Tabbed windows should retrieve the saved window state - since there is a |
| 697 // top window. | 698 // top window. |
| 698 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, | 699 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, |
| 699 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_NORMAL, | 700 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_NORMAL, |
| 700 BOTH, browser.get(), p1600x1200, p1600x1200)); | 701 BOTH, browser.get(), p1600x1200, p1600x1200)); |
| 701 // A window that is smaller than the whole work area is set to default state. | 702 // A window that is smaller than the whole work area is set to default state. |
| 702 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 703 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 714 // The non tabbed window will take the status of the last active of its kind. | 715 // The non tabbed window will take the status of the last active of its kind. |
| 715 EXPECT_EQ( | 716 EXPECT_EQ( |
| 716 ui::SHOW_STATE_NORMAL, | 717 ui::SHOW_STATE_NORMAL, |
| 717 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 718 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 718 browser_popup.get(), p1600x1200, p1600x1200)); | 719 browser_popup.get(), p1600x1200, p1600x1200)); |
| 719 | 720 |
| 720 // Now create a top level window and check again for both. Only the tabbed | 721 // Now create a top level window and check again for both. Only the tabbed |
| 721 // window should follow the top level window's state. | 722 // window should follow the top level window's state. |
| 722 // Creating a browser & window to play with. | 723 // Creating a browser & window to play with. |
| 723 Browser::CreateParams params2(Browser::TYPE_TABBED, profile.get()); | 724 Browser::CreateParams params2(Browser::TYPE_TABBED, profile.get()); |
| 724 scoped_ptr<Browser> browser2(CreateTestBrowser( | 725 std::unique_ptr<Browser> browser2(CreateTestBrowser( |
| 725 CreateTestWindowInShellWithId(3), gfx::Rect(16, 32, 640, 320), ¶ms2)); | 726 CreateTestWindowInShellWithId(3), gfx::Rect(16, 32, 640, 320), ¶ms2)); |
| 726 | 727 |
| 727 // A tabbed window should now take the top level window state. | 728 // A tabbed window should now take the top level window state. |
| 728 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, | 729 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, |
| 729 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_DEFAULT, | 730 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_DEFAULT, |
| 730 BOTH, browser.get(), p1600x1200, p1600x1200)); | 731 BOTH, browser.get(), p1600x1200, p1600x1200)); |
| 731 // Non tabbed windows should always follow the window saved visibility state. | 732 // Non tabbed windows should always follow the window saved visibility state. |
| 732 EXPECT_EQ( | 733 EXPECT_EQ( |
| 733 ui::SHOW_STATE_MAXIMIZED, | 734 ui::SHOW_STATE_MAXIMIZED, |
| 734 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_MINIMIZED, | 735 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_MINIMIZED, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 747 EXPECT_EQ( | 748 EXPECT_EQ( |
| 748 ui::SHOW_STATE_MAXIMIZED, | 749 ui::SHOW_STATE_MAXIMIZED, |
| 749 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_DEFAULT, | 750 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_DEFAULT, |
| 750 BOTH, browser2.get(), tiny_screen, tiny_screen)); | 751 BOTH, browser2.get(), tiny_screen, tiny_screen)); |
| 751 } | 752 } |
| 752 } | 753 } |
| 753 | 754 |
| 754 // Test that the default show state override behavior is properly handled. | 755 // Test that the default show state override behavior is properly handled. |
| 755 TEST_F(WindowSizerAshTest, TestShowStateDefaults) { | 756 TEST_F(WindowSizerAshTest, TestShowStateDefaults) { |
| 756 // Creating a browser & window to play with. | 757 // Creating a browser & window to play with. |
| 757 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 758 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 758 | 759 |
| 759 Browser::CreateParams params(Browser::TYPE_TABBED, profile.get()); | 760 Browser::CreateParams params(Browser::TYPE_TABBED, profile.get()); |
| 760 scoped_ptr<Browser> browser(CreateTestBrowser( | 761 std::unique_ptr<Browser> browser(CreateTestBrowser( |
| 761 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), ¶ms)); | 762 CreateTestWindowInShellWithId(0), gfx::Rect(16, 32, 640, 320), ¶ms)); |
| 762 | 763 |
| 763 // Create also a popup browser since that behaves slightly different for | 764 // Create also a popup browser since that behaves slightly different for |
| 764 // defaults. | 765 // defaults. |
| 765 Browser::CreateParams params_popup(Browser::TYPE_POPUP, profile.get()); | 766 Browser::CreateParams params_popup(Browser::TYPE_POPUP, profile.get()); |
| 766 scoped_ptr<Browser> browser_popup( | 767 std::unique_ptr<Browser> browser_popup( |
| 767 CreateTestBrowser(CreateTestWindowInShellWithId(1), | 768 CreateTestBrowser(CreateTestWindowInShellWithId(1), |
| 768 gfx::Rect(16, 32, 128, 256), ¶ms_popup)); | 769 gfx::Rect(16, 32, 128, 256), ¶ms_popup)); |
| 769 | 770 |
| 770 // Check that a browser creation state always get used if not given as | 771 // Check that a browser creation state always get used if not given as |
| 771 // SHOW_STATE_DEFAULT. On Windows ASH it should be SHOW_STATE_MAXIMIZED. | 772 // SHOW_STATE_DEFAULT. On Windows ASH it should be SHOW_STATE_MAXIMIZED. |
| 772 ui::WindowShowState window_show_state = | 773 ui::WindowShowState window_show_state = |
| 773 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_MAXIMIZED, | 774 GetWindowShowState(ui::SHOW_STATE_MAXIMIZED, ui::SHOW_STATE_MAXIMIZED, |
| 774 DEFAULT, browser.get(), p1600x1200, p1600x1200); | 775 DEFAULT, browser.get(), p1600x1200, p1600x1200); |
| 775 #if defined(OS_WIN) | 776 #if defined(OS_WIN) |
| 776 EXPECT_EQ(window_show_state, ui::SHOW_STATE_MAXIMIZED); | 777 EXPECT_EQ(window_show_state, ui::SHOW_STATE_MAXIMIZED); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 805 | 806 |
| 806 // The popup should favor the initial show state over the command line. | 807 // The popup should favor the initial show state over the command line. |
| 807 EXPECT_EQ( | 808 EXPECT_EQ( |
| 808 GetWindowShowState(ui::SHOW_STATE_NORMAL, ui::SHOW_STATE_NORMAL, BOTH, | 809 GetWindowShowState(ui::SHOW_STATE_NORMAL, ui::SHOW_STATE_NORMAL, BOTH, |
| 809 browser_popup.get(), p1600x1200, p1600x1200), | 810 browser_popup.get(), p1600x1200, p1600x1200), |
| 810 ui::SHOW_STATE_NORMAL); | 811 ui::SHOW_STATE_NORMAL); |
| 811 } | 812 } |
| 812 | 813 |
| 813 TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { | 814 TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { |
| 814 // Create a browser to pass into the GetWindowBounds function. | 815 // Create a browser to pass into the GetWindowBounds function. |
| 815 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 816 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 816 Browser::CreateParams native_params(profile.get()); | 817 Browser::CreateParams native_params(profile.get()); |
| 817 scoped_ptr<Browser> browser( | 818 std::unique_ptr<Browser> browser( |
| 818 chrome::CreateBrowserWithTestWindowForParams(&native_params)); | 819 chrome::CreateBrowserWithTestWindowForParams(&native_params)); |
| 819 | 820 |
| 820 gfx::Rect display_bounds = | 821 gfx::Rect display_bounds = |
| 821 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 822 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds(); |
| 822 gfx::Rect specified_bounds = display_bounds; | 823 gfx::Rect specified_bounds = display_bounds; |
| 823 | 824 |
| 824 // Make a window bigger than the display work area. | 825 // Make a window bigger than the display work area. |
| 825 specified_bounds.Inset(-20, -20); | 826 specified_bounds.Inset(-20, -20); |
| 826 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; | 827 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; |
| 827 gfx::Rect bounds; | 828 gfx::Rect bounds; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 std::string(), | 875 std::string(), |
| 875 gfx::Rect(), | 876 gfx::Rect(), |
| 876 NULL, | 877 NULL, |
| 877 &bounds, | 878 &bounds, |
| 878 &show_state); | 879 &show_state); |
| 879 EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); | 880 EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); |
| 880 } | 881 } |
| 881 } | 882 } |
| 882 | 883 |
| 883 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { | 884 TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { |
| 884 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 885 std::unique_ptr<TestingProfile> profile(new TestingProfile()); |
| 885 Browser::CreateParams trusted_popup_create_params(Browser::TYPE_POPUP, | 886 Browser::CreateParams trusted_popup_create_params(Browser::TYPE_POPUP, |
| 886 profile.get()); | 887 profile.get()); |
| 887 trusted_popup_create_params.trusted_source = true; | 888 trusted_popup_create_params.trusted_source = true; |
| 888 | 889 |
| 889 scoped_ptr<Browser> trusted_popup(CreateTestBrowser( | 890 std::unique_ptr<Browser> trusted_popup(CreateTestBrowser( |
| 890 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320), | 891 CreateTestWindowInShellWithId(1), gfx::Rect(16, 32, 640, 320), |
| 891 &trusted_popup_create_params)); | 892 &trusted_popup_create_params)); |
| 892 // Trusted popup windows should follow the saved show state and ignore the | 893 // Trusted popup windows should follow the saved show state and ignore the |
| 893 // last show state. | 894 // last show state. |
| 894 EXPECT_EQ( | 895 EXPECT_EQ( |
| 895 ui::SHOW_STATE_DEFAULT, | 896 ui::SHOW_STATE_DEFAULT, |
| 896 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 897 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 897 trusted_popup.get(), p1280x1024, p1600x1200)); | 898 trusted_popup.get(), p1280x1024, p1600x1200)); |
| 898 // A popup that is sized to occupy the whole work area has default state. | 899 // A popup that is sized to occupy the whole work area has default state. |
| 899 EXPECT_EQ( | 900 EXPECT_EQ( |
| 900 ui::SHOW_STATE_DEFAULT, | 901 ui::SHOW_STATE_DEFAULT, |
| 901 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, | 902 GetWindowShowState(ui::SHOW_STATE_DEFAULT, ui::SHOW_STATE_NORMAL, BOTH, |
| 902 trusted_popup.get(), p1600x1200, p1600x1200)); | 903 trusted_popup.get(), p1600x1200, p1600x1200)); |
| 903 } | 904 } |
| OLD | NEW |