Chromium Code Reviews| Index: chrome/browser/ui/browser_browsertest.cc |
| diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc |
| index d35e8938bb307b618adace55fe91a652723aab53..7fd46bf314733b5bc9ab966dd124b96b54ceb31a 100644 |
| --- a/chrome/browser/ui/browser_browsertest.cc |
| +++ b/chrome/browser/ui/browser_browsertest.cc |
| @@ -124,6 +124,12 @@ |
| #include "chrome/browser/browser_process.h" |
| #endif |
| +#if defined(OS_CHROMEOS) |
| +#include "ui/aura/window.h" |
| +#include "ui/display/display.h" |
| +#include "ui/display/screen.h" |
| +#endif |
| + |
| using app_modal::AppModalDialog; |
| using app_modal::AppModalDialogQueue; |
| using app_modal::JavaScriptAppModalDialog; |
| @@ -2942,3 +2948,67 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TestPopupBounds) { |
| browser->window()->Close(); |
| } |
| } |
| + |
| +#if defined(OS_CHROMEOS) |
| +namespace { |
| + |
| +class BrowserTestParam : public InProcessBrowserTest, |
| + public testing::WithParamInterface<bool> { |
| + public: |
| + bool TestApp() { return GetParam(); } |
| +}; |
| + |
| +} // namespace |
| + |
| +// Test that in Chrome OS, for app browser (v1app) windows, the auto management |
|
sky
2017/02/13 23:35:51
We try to avoid platform specific code in c/b/ui.
Qiang(Joe) Xu
2017/02/14 00:00:20
sure, updated.
|
| +// logic is disabled while for tabbed browser windows, it is enabled. |
| +IN_PROC_BROWSER_TEST_P(BrowserTestParam, |
| + TabbedOrAppBrowserWindowAutoManagementTest) { |
| + // Default |browser()| is not used by this test. |
| + browser()->window()->Close(); |
| + |
| + // Open a new browser window (app or tabbed depending on a parameter). |
| + bool test_app = TestApp(); |
| + Browser::CreateParams params = |
| + test_app ? Browser::CreateParams::CreateForApp( |
| + "test_browser_app", true /* trusted_source */, gfx::Rect(), |
| + browser()->profile()) |
| + : Browser::CreateParams(browser()->profile()); |
| + params.initial_show_state = ui::SHOW_STATE_DEFAULT; |
| + Browser* browser = new Browser(params); |
| + gfx::NativeWindow window = browser->window()->GetNativeWindow(); |
| + gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100)); |
| + window->SetBounds(original_bounds); |
| + window->Show(); |
| + |
| + // For tabbed browser window, it will be centered to work area by auto window |
| + // mangement logic; for app browser window, it will remain the given bounds. |
| + gfx::Rect work_area = display::Screen::GetScreen() |
| + ->GetDisplayNearestPoint(window->bounds().origin()) |
| + .work_area(); |
| + gfx::Rect tabbed_expected_bounds = work_area; |
| + tabbed_expected_bounds.ClampToCenteredSize(original_bounds.size()); |
| + tabbed_expected_bounds.set_y(original_bounds.y()); |
| + if (test_app) |
| + EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString()); |
| + else |
| + EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString()); |
| + |
| + // Close the browser and re-create the browser window with the same app name. |
| + browser->window()->Close(); |
| + browser = new Browser(params); |
| + browser->window()->Show(); |
| + |
| + // The newly created browser window should remain the same bounds for each. |
| + window = browser->window()->GetNativeWindow(); |
| + if (test_app) |
| + EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString()); |
| + else |
| + EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString()); |
| +} |
| + |
| +INSTANTIATE_TEST_CASE_P(BrowserTestTabbedOrApp, |
| + BrowserTestParam, |
| + testing::Bool()); |
| + |
| +#endif // defined(OS_CHROMEOS) |