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

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, 9 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"
8 #include "build/build_config.h"
9 #include "chrome/browser/ui/browser_commands.h" 7 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
11 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
12 #include "ui/views/focus/focus_manager.h"
13
14 #if defined(USE_ASH)
15 #include "ash/common/ash_switches.h"
16 #endif
17
18 #if defined(USE_AURA)
19 #include "chrome/browser/ui/browser_window_state.h"
20 #include "ui/aura/client/aura_constants.h"
21 #include "ui/aura/window_delegate.h"
22 #endif
23 10
24 using views::FocusManager; 11 using views::FocusManager;
25 12
26 typedef InProcessBrowserTest BrowserViewTest; 13 typedef InProcessBrowserTest BrowserViewTest;
27 14
28 // Active window and focus testing is not reliable on Windows crbug.com/79493 15 // Active window and focus testing is not reliable on Windows crbug.com/79493
29 #if defined(OS_WIN) 16 #if defined(OS_WIN)
30 #define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus 17 #define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus
31 #else 18 #else
32 #define MAYBE_FullscreenClearsFocus FullscreenClearsFocus 19 #define MAYBE_FullscreenClearsFocus FullscreenClearsFocus
33 #endif 20 #endif
34 IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_FullscreenClearsFocus) { 21 IN_PROC_BROWSER_TEST_F(BrowserViewTest, MAYBE_FullscreenClearsFocus) {
35 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); 22 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
36 LocationBarView* location_bar_view = browser_view->GetLocationBarView(); 23 LocationBarView* location_bar_view = browser_view->GetLocationBarView();
37 FocusManager* focus_manager = browser_view->GetFocusManager(); 24 FocusManager* focus_manager = browser_view->GetFocusManager();
38 25
39 // Focus starts in the location bar or one of its children. 26 // Focus starts in the location bar or one of its children.
40 EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView())); 27 EXPECT_TRUE(location_bar_view->Contains(focus_manager->GetFocusedView()));
41 28
42 chrome::ToggleFullscreenMode(browser()); 29 chrome::ToggleFullscreenMode(browser());
43 EXPECT_TRUE(browser_view->IsFullscreen()); 30 EXPECT_TRUE(browser_view->IsFullscreen());
44 31
45 // Focus is released from the location bar. 32 // Focus is released from the location bar.
46 EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView())); 33 EXPECT_FALSE(location_bar_view->Contains(focus_manager->GetFocusedView()));
47 } 34 }
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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_ash.cc ('k') | chrome/browser/ui/views/tabs/tab_drag_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698