Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/frame/browser_frame_ash.h" | |
| 6 | |
| 7 #include "chrome/browser/ui/browser.h" | |
| 8 #include "chrome/browser/ui/browser_window.h" | |
| 9 #include "chrome/test/base/in_process_browser_test.h" | |
| 10 #include "ui/aura/window.h" | |
| 11 #include "ui/display/display.h" | |
| 12 #include "ui/display/screen.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 class BrowserTestParam : public InProcessBrowserTest, | |
| 17 public testing::WithParamInterface<bool> { | |
| 18 public: | |
| 19 bool TestApp() { return GetParam(); } | |
|
oshima
2017/02/14 01:09:51
nit: CreateV1App() would be better
Qiang(Joe) Xu
2017/02/14 01:19:52
Done.
| |
| 20 }; | |
|
sky
2017/02/14 00:38:27
private: DISALLOW...
Qiang(Joe) Xu
2017/02/14 01:19:52
Done.
| |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 // Test that in Chrome OS, for app browser (v1app) windows, the auto management | |
| 25 // logic is disabled while for tabbed browser windows, it is enabled. | |
| 26 IN_PROC_BROWSER_TEST_P(BrowserTestParam, | |
| 27 TabbedOrAppBrowserWindowAutoManagementTest) { | |
| 28 // Default |browser()| is not used by this test. | |
| 29 browser()->window()->Close(); | |
| 30 | |
| 31 // Open a new browser window (app or tabbed depending on a parameter). | |
| 32 bool test_app = TestApp(); | |
| 33 Browser::CreateParams params = | |
| 34 test_app ? Browser::CreateParams::CreateForApp( | |
| 35 "test_browser_app", true /* trusted_source */, gfx::Rect(), | |
| 36 browser()->profile()) | |
| 37 : Browser::CreateParams(browser()->profile()); | |
| 38 params.initial_show_state = ui::SHOW_STATE_DEFAULT; | |
| 39 Browser* browser = new Browser(params); | |
| 40 gfx::NativeWindow window = browser->window()->GetNativeWindow(); | |
| 41 gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100)); | |
| 42 window->SetBounds(original_bounds); | |
| 43 window->Show(); | |
| 44 | |
| 45 // For tabbed browser window, it will be centered to work area by auto window | |
| 46 // mangement logic; for app browser window, it will remain the given bounds. | |
| 47 gfx::Rect work_area = display::Screen::GetScreen() | |
| 48 ->GetDisplayNearestPoint(window->bounds().origin()) | |
| 49 .work_area(); | |
| 50 gfx::Rect tabbed_expected_bounds = work_area; | |
| 51 tabbed_expected_bounds.ClampToCenteredSize(original_bounds.size()); | |
| 52 tabbed_expected_bounds.set_y(original_bounds.y()); | |
| 53 if (test_app) | |
| 54 EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString()); | |
|
oshima
2017/02/14 01:09:51
nit: no need to convert to string. (Old tests use
Qiang(Joe) Xu
2017/02/14 01:19:52
Done.
| |
| 55 else | |
| 56 EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString()); | |
| 57 | |
| 58 // Close the browser and re-create the browser window with the same app name. | |
| 59 browser->window()->Close(); | |
| 60 browser = new Browser(params); | |
| 61 browser->window()->Show(); | |
| 62 | |
| 63 // The newly created browser window should remain the same bounds for each. | |
| 64 window = browser->window()->GetNativeWindow(); | |
| 65 if (test_app) | |
| 66 EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString()); | |
| 67 else | |
| 68 EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString()); | |
| 69 } | |
| 70 | |
| 71 INSTANTIATE_TEST_CASE_P(BrowserTestTabbedOrApp, | |
| 72 BrowserTestParam, | |
| 73 testing::Bool()); | |
| OLD | NEW |