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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_interactive_uitest.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
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"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "ui/views/focus/focus_manager.h" 12 #include "ui/views/focus/focus_manager.h"
13 13
14 #if defined(USE_ASH) 14 #if defined(USE_ASH)
15 #include "ash/common/ash_switches.h" 15 #include "ash/common/ash_switches.h"
16 #endif 16 #endif
17 17
18 #if defined(USE_AURA) 18 #if defined(USE_AURA)
19 #include "chrome/browser/ui/browser_window_state.h" 19 #include "chrome/browser/ui/browser_window_state.h"
20 #include "ui/aura/client/aura_constants.h" 20 #include "ui/aura/client/aura_constants.h"
21 #include "ui/aura/window.h"
22 #include "ui/aura/window_delegate.h" 21 #include "ui/aura/window_delegate.h"
23 #include "ui/display/display.h"
24 #include "ui/display/screen.h"
25 #endif 22 #endif
26 23
27 using views::FocusManager; 24 using views::FocusManager;
28 25
29 typedef InProcessBrowserTest BrowserViewTest; 26 typedef InProcessBrowserTest BrowserViewTest;
30 27
31 // Active window and focus testing is not reliable on Windows crbug.com/79493 28 // Active window and focus testing is not reliable on Windows crbug.com/79493
32 #if defined(OS_WIN) 29 #if defined(OS_WIN)
33 #define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus 30 #define MAYBE_FullscreenClearsFocus DISABLED_FullscreenClearsFocus
34 #else 31 #else
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 "test_browser_app", true /* trusted_source */, gfx::Rect(), 76 "test_browser_app", true /* trusted_source */, gfx::Rect(),
80 browser()->profile()) 77 browser()->profile())
81 : Browser::CreateParams(browser()->profile()); 78 : Browser::CreateParams(browser()->profile());
82 params.initial_show_state = ui::SHOW_STATE_DEFAULT; 79 params.initial_show_state = ui::SHOW_STATE_DEFAULT;
83 80
84 // Default |browser()| is not used by this test. 81 // Default |browser()| is not used by this test.
85 browser()->window()->Close(); 82 browser()->window()->Close();
86 83
87 // Create a new app browser 84 // Create a new app browser
88 Browser* browser = new Browser(params); 85 Browser* browser = new Browser(params);
89 ASSERT_TRUE(browser);
90 gfx::NativeWindow window = browser->window()->GetNativeWindow(); 86 gfx::NativeWindow window = browser->window()->GetNativeWindow();
91 gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100)); 87 gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100));
92 window->SetBounds(original_bounds); 88 window->SetBounds(original_bounds);
93 window->Show(); 89 window->Show();
94 // Dock the browser window using |kShowStateKey| property. 90 // Dock the browser window using |kShowStateKey| property.
95 gfx::Rect work_area = display::Screen::GetScreen()
96 ->GetDisplayNearestPoint(window->bounds().origin())
97 .work_area();
98 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED); 91 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DOCKED);
99 92
100 // Saved placement should reflect docked state (for app windows only in Ash). 93 // Saved placement should reflect docked state (for app windows only in Ash).
101 gfx::Rect bounds; 94 gfx::Rect bounds;
102 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; 95 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT;
103 const views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); 96 const views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
104 widget->widget_delegate()->GetSavedWindowPlacement(widget, &bounds, 97 widget->widget_delegate()->GetSavedWindowPlacement(widget, &bounds,
105 &show_state); 98 &show_state);
106 EXPECT_EQ(kIsAsh && test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_DEFAULT, 99 EXPECT_EQ(kIsAsh && test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_DEFAULT,
107 show_state); 100 show_state);
108 // Docking is only relevant on Ash desktop. 101 // Docking is only relevant on Ash desktop.
109 if (!kIsAsh) 102 if (!kIsAsh)
110 return; 103 return;
111 104
112 // Saved placement should reflect restore bounds.
113 ASSERT_NE(nullptr, window->GetProperty(aura::client::kRestoreBoundsKey));
114 original_bounds = *window->GetProperty(aura::client::kRestoreBoundsKey);
115 gfx::Rect expected_bounds = work_area;
116 expected_bounds.ClampToCenteredSize(original_bounds.size());
117 expected_bounds.set_y(original_bounds.y());
118 EXPECT_EQ(expected_bounds.ToString(), bounds.ToString());
119 EXPECT_EQ(expected_bounds.ToString(), original_bounds.ToString());
120
121 // Browser window should be docked.
122 int width = 250; // same as DockedWindowLayoutManager::kIdealWidth.
123 if (window->delegate() && window->delegate()->GetMinimumSize().width() != 0)
124 width = std::max(width, window->delegate()->GetMinimumSize().width());
125 expected_bounds = work_area;
126 expected_bounds.set_width(width);
127 expected_bounds.set_x(work_area.right() - expected_bounds.width());
128 EXPECT_EQ(expected_bounds.ToString(), window->GetTargetBounds().ToString());
129 EXPECT_EQ(ui::SHOW_STATE_DOCKED,
130 window->GetProperty(aura::client::kShowStateKey));
131 browser->window()->Close();
132
133 // Newly created browser with the same app name should retain docked state 105 // Newly created browser with the same app name should retain docked state
134 // for app browser window but leave it as normal for a tabbed browser. 106 // for app browser window but leave it as normal for a tabbed browser.
135 browser = new Browser(params); 107 browser = new Browser(params);
136 ASSERT_TRUE(browser);
137 browser->window()->Show(); 108 browser->window()->Show();
138 window = browser->window()->GetNativeWindow(); 109 window = browser->window()->GetNativeWindow();
139 EXPECT_EQ(test_app ? expected_bounds.ToString() : original_bounds.ToString(),
140 window->GetTargetBounds().ToString());
141 EXPECT_EQ(test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_NORMAL, 110 EXPECT_EQ(test_app ? ui::SHOW_STATE_DOCKED : ui::SHOW_STATE_NORMAL,
142 window->GetProperty(aura::client::kShowStateKey)); 111 window->GetProperty(aura::client::kShowStateKey));
143 112
144 // Undocking the browser window should restore original size and vertical 113 // Undocking the browser window.
145 // offset while centering the window horizontally.
146 // Tabbed window is already not docked.
147 expected_bounds = work_area;
148 expected_bounds.ClampToCenteredSize(original_bounds.size());
149 expected_bounds.set_y(original_bounds.y());
150 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 114 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
151 EXPECT_EQ(expected_bounds.ToString(), window->GetTargetBounds().ToString());
152 EXPECT_EQ(ui::SHOW_STATE_NORMAL, 115 EXPECT_EQ(ui::SHOW_STATE_NORMAL,
153 window->GetProperty(aura::client::kShowStateKey)); 116 window->GetProperty(aura::client::kShowStateKey));
154 browser->window()->Close(); 117 browser->window()->Close();
155 118
156 // Re-create the browser window with the same app name. 119 // Re-create the browser window with the same app name.
157 browser = new Browser(params); 120 browser = new Browser(params);
158 ASSERT_TRUE(browser);
159 browser->window()->Show(); 121 browser->window()->Show();
160 122
161 // Newly created browser should retain undocked state and bounds. 123 // Newly created browser should retain undocked state.
162 window = browser->window()->GetNativeWindow(); 124 window = browser->window()->GetNativeWindow();
163 EXPECT_EQ(expected_bounds.ToString(), window->GetTargetBounds().ToString());
164 EXPECT_EQ(ui::SHOW_STATE_NORMAL, 125 EXPECT_EQ(ui::SHOW_STATE_NORMAL,
165 window->GetProperty(aura::client::kShowStateKey)); 126 window->GetProperty(aura::client::kShowStateKey));
166 } 127 }
167 128
168 INSTANTIATE_TEST_CASE_P(BrowserViewTestTabbedOrApp, 129 INSTANTIATE_TEST_CASE_P(BrowserViewTestTabbedOrApp,
169 BrowserViewTestParam, 130 BrowserViewTestParam,
170 testing::Bool()); 131 testing::Bool());
171 #endif 132 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698