Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: chrome/browser/ui/views/frame/browser_frame_ash_browsertest.cc

Issue 2690563005: cros: Disable the auto management logic for v1app browser window (Closed)
Patch Set: nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 BrowserTestParam() {}
20 ~BrowserTestParam() {}
21
22 bool CreateV1App() { return GetParam(); }
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(BrowserTestParam);
26 };
27
28 } // namespace
29
30 // Test that in Chrome OS, for app browser (v1app) windows, the auto management
31 // logic is disabled while for tabbed browser windows, it is enabled.
32 IN_PROC_BROWSER_TEST_P(BrowserTestParam,
33 TabbedOrAppBrowserWindowAutoManagementTest) {
34 // Default |browser()| is not used by this test.
35 browser()->window()->Close();
36
37 // Open a new browser window (app or tabbed depending on a parameter).
38 bool test_app = CreateV1App();
39 Browser::CreateParams params =
40 test_app ? Browser::CreateParams::CreateForApp(
41 "test_browser_app", true /* trusted_source */, gfx::Rect(),
42 browser()->profile())
43 : Browser::CreateParams(browser()->profile());
44 params.initial_show_state = ui::SHOW_STATE_DEFAULT;
45 Browser* browser = new Browser(params);
46 gfx::NativeWindow window = browser->window()->GetNativeWindow();
47 gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100));
48 window->SetBounds(original_bounds);
49 window->Show();
50
51 // For tabbed browser window, it will be centered to work area by auto window
52 // mangement logic; for app browser window, it will remain the given bounds.
53 gfx::Rect work_area = display::Screen::GetScreen()
54 ->GetDisplayNearestPoint(window->bounds().origin())
55 .work_area();
56 gfx::Rect tabbed_expected_bounds = work_area;
57 tabbed_expected_bounds.ClampToCenteredSize(original_bounds.size());
58 tabbed_expected_bounds.set_y(original_bounds.y());
59 if (test_app)
60 EXPECT_EQ(original_bounds, window->bounds());
61 else
62 EXPECT_EQ(tabbed_expected_bounds, window->bounds());
63
64 // Close the browser and re-create the browser window with the same app name.
65 browser->window()->Close();
66 browser = new Browser(params);
67 browser->window()->Show();
68
69 // The newly created browser window should remain the same bounds for each.
70 window = browser->window()->GetNativeWindow();
71 if (test_app)
72 EXPECT_EQ(original_bounds, window->bounds());
73 else
74 EXPECT_EQ(tabbed_expected_bounds, window->bounds());
75 }
76
77 INSTANTIATE_TEST_CASE_P(BrowserTestTabbedOrApp,
78 BrowserTestParam,
79 testing::Bool());
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_ash.cc ('k') | chrome/browser/ui/views/frame/browser_view_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698