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

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

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Rebase 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
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "chrome/browser/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
(...skipping 27 matching lines...) Expand all
38 38
39 // Focus starts in the location bar or one of its children. 39 // Focus starts in the location bar or one of its children.
40 EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView())); 40 EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView()));
41 41
42 chrome::ToggleFullscreenMode(browser()); 42 chrome::ToggleFullscreenMode(browser());
43 EXPECT_TRUE(browser_view->IsFullscreen()); 43 EXPECT_TRUE(browser_view->IsFullscreen());
44 44
45 // Focus is released from the location bar. 45 // Focus is released from the location bar.
46 EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView())); 46 EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView()));
47 } 47 }
48
49 #if defined(USE_AURA)
50 namespace {
51
52 class BrowserViewTestParam : public BrowserViewTest,
53 public testing::WithParamInterface<bool> {
54 public:
55 bool TestApp() { return GetParam(); }
56 };
57
58 } // namespace
59
60 // Test that docked state is remembered for app browser windows and not
61 // remembered for tabbed browser windows.
62 IN_PROC_BROWSER_TEST_P(BrowserViewTestParam, BrowserRemembersDockedState) {
63 #if defined(USE_ASH)
64 // Enable window docking for this test.
65 base::CommandLine::ForCurrentProcess()->AppendSwitch(
66 ash::switches::kAshEnableDockedWindows);
67 const bool kIsAsh = true;
68 #else
69 const bool kIsAsh = false;
70 #endif // defined(USE_ASH)
71
72 // Open a new browser window (app or tabbed depending on a parameter).
73 bool test_app = TestApp();
74 Browser::CreateParams params =
75 test_app ? Browser::CreateParams::CreateForApp(
76 "test_browser_app", true /* trusted_source */, gfx::Rect(),
77 browser()->profile(), true)
78 : Browser::CreateParams(browser()->profile(), true);
79 params.initial_show_state = ui::SHOW_STATE_DEFAULT;
80
81 // Default |browser()| is not used by this test.
82 browser()->window()->Close();
83
84 // Create a new app browser
85 Browser* browser = new Browser(params);
86 gfx::NativeWindow window = browser->window()->GetNativeWindow();
87 gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100));
88 window->SetBounds(original_bounds);
89 window->Show();
90 // Dock the browser window using |kShowStateKey| property.
91 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED);
92
93 // Saved placement should reflect docked state (for app windows only in Ash).
94 gfx::Rect bounds;
95 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT;
96 const views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
97 widget->widget_delegate()->GetSavedWindowPlacement(widget, &bounds,
98 &show_state);
99 EXPECT_EQ(kIsAsh && test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_DEFAULT,
100 show_state);
101 // Docking is only relevant on Ash desktop.
102 if (!kIsAsh)
103 return;
104
105 // Newly created browser with the same app name should retain docked state
106 // for app browser window but leave it as normal for a tabbed browser.
107 browser = new Browser(params);
108 browser->window()->Show();
109 window = browser->window()->GetNativeWindow();
110 EXPECT_EQ(test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_NORMAL,
111 window->GetProperty(aura::client::kShowStateKey));
112
113 // Undocking the browser window.
114 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
115 EXPECT_EQ(ui::SHOW_STATE_NORMAL,
116 window->GetProperty(aura::client::kShowStateKey));
117 browser->window()->Close();
118
119 // Re-create the browser window with the same app name.
120 browser = new Browser(params);
121 browser->window()->Show();
122
123 // Newly created browser should retain undocked state.
124 window = browser->window()->GetNativeWindow();
125 EXPECT_EQ(ui::SHOW_STATE_NORMAL,
126 window->GetProperty(aura::client::kShowStateKey));
127 }
128
129 INSTANTIATE_TEST_CASE_P(BrowserViewTestTabbedOrApp,
130 BrowserViewTestParam,
131 testing::Bool());
132 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698