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

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

Issue 2165693002: Fix tests in when MD is set to EXPERIMENTAL by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/immersive_mode_controller_ash.h" 5 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/shelf/shelf_types.h" 9 #include "ash/common/shelf/shelf_types.h"
9 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "chrome/app/chrome_command_ids.h" 16 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/ui/browser_commands.h" 17 #include "chrome/browser/ui/browser_commands.h"
17 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 18 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ASSERT_FALSE(controller()->IsEnabled()); 119 ASSERT_FALSE(controller()->IsEnabled());
119 120
120 // By default, the tabstrip and toolbar should be visible. 121 // By default, the tabstrip and toolbar should be visible.
121 EXPECT_TRUE(tabstrip->visible()); 122 EXPECT_TRUE(tabstrip->visible());
122 EXPECT_TRUE(toolbar->visible()); 123 EXPECT_TRUE(toolbar->visible());
123 124
124 ToggleFullscreen(); 125 ToggleFullscreen();
125 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen()); 126 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen());
126 EXPECT_TRUE(controller()->IsEnabled()); 127 EXPECT_TRUE(controller()->IsEnabled());
127 EXPECT_FALSE(controller()->IsRevealed()); 128 EXPECT_FALSE(controller()->IsRevealed());
128
129 // Entering immersive fullscreen should make the tab strip use the immersive
130 // style and hide the toolbar.
131 EXPECT_TRUE(tabstrip->visible());
132 EXPECT_TRUE(tabstrip->IsImmersiveStyle());
133 EXPECT_FALSE(toolbar->visible()); 129 EXPECT_FALSE(toolbar->visible());
130 // For MD, the browser's top chrome is completely hidden in immersive
131 // fullscreen mode.
132 bool is_using_material_design =
133 ash::MaterialDesignController::IsShelfMaterial();
134 if (is_using_material_design) {
135 EXPECT_FALSE(tabstrip->visible());
136 } else {
137 EXPECT_TRUE(tabstrip->visible());
138 EXPECT_TRUE(tabstrip->IsImmersiveStyle());
139 }
134 140
135 // The tab indicators should be flush with the top of the widget. 141 // The tab indicators should be flush with the top of the widget.
136 EXPECT_EQ(0, GetBoundsInWidget(tabstrip).y()); 142 EXPECT_EQ(0, GetBoundsInWidget(tabstrip).y());
137 143
138 // The web contents should be immediately below the tab indicators. 144 // In MD, since the tab strip and tool bar are both hidden in immersive
139 EXPECT_EQ(Tab::GetImmersiveHeight(), 145 // fullscreen mode, the web contents should extend to the edge of screen. In
140 GetBoundsInWidget(contents_web_view).y()); 146 // non-MD, the web contents should be immediately below the tab indicators.
147 if (is_using_material_design) {
148 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
149 } else {
150 EXPECT_EQ(Tab::GetImmersiveHeight(),
151 GetBoundsInWidget(contents_web_view).y());
152 }
141 153
142 // Revealing the top-of-window views should set the tab strip back to the 154 // Revealing the top-of-window views should set the tab strip back to the
143 // normal style and show the toolbar. 155 // normal style and show the toolbar.
144 AttemptReveal(); 156 AttemptReveal();
145 EXPECT_TRUE(controller()->IsRevealed()); 157 EXPECT_TRUE(controller()->IsRevealed());
146 EXPECT_TRUE(tabstrip->visible()); 158 EXPECT_TRUE(tabstrip->visible());
147 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); 159 EXPECT_FALSE(tabstrip->IsImmersiveStyle());
148 EXPECT_TRUE(toolbar->visible()); 160 EXPECT_TRUE(toolbar->visible());
149 161
150 // The TopContainerView should be flush with the top edge of the widget. If 162 // The TopContainerView should be flush with the top edge of the widget. If
151 // it is not flush with the top edge the immersive reveal animation looks 163 // it is not flush with the top edge the immersive reveal animation looks
152 // wonky. 164 // wonky.
153 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); 165 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y());
154 166
155 // The web contents should be at the same y position as they were when the 167 // The web contents should be at the same y position as they were when the
156 // top-of-window views were hidden. 168 // top-of-window views were hidden.
157 EXPECT_EQ(Tab::GetImmersiveHeight(), 169 if (is_using_material_design) {
158 GetBoundsInWidget(contents_web_view).y()); 170 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
171 } else {
172 EXPECT_EQ(Tab::GetImmersiveHeight(),
173 GetBoundsInWidget(contents_web_view).y());
174 }
159 175
160 // Repeat the test for when in both immersive fullscreen and tab fullscreen. 176 // Repeat the test for when in both immersive fullscreen and tab fullscreen.
161 SetTabFullscreen(true); 177 SetTabFullscreen(true);
162 // Hide and reveal the top-of-window views so that they get relain out. 178 // Hide and reveal the top-of-window views so that they get relain out.
163 AttemptUnreveal(); 179 AttemptUnreveal();
164 AttemptReveal(); 180 AttemptReveal();
165 181
166 // The tab strip and toolbar should still be visible and the TopContainerView 182 // The tab strip and toolbar should still be visible and the TopContainerView
167 // should still be flush with the top edge of the widget. 183 // should still be flush with the top edge of the widget.
168 EXPECT_TRUE(controller()->IsRevealed()); 184 EXPECT_TRUE(controller()->IsRevealed());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 TEST_F(ImmersiveModeControllerAshTest, TabAndBrowserFullscreen) { 245 TEST_F(ImmersiveModeControllerAshTest, TabAndBrowserFullscreen) {
230 AddTab(browser(), GURL("about:blank")); 246 AddTab(browser(), GURL("about:blank"));
231 247
232 // The shelf should start out as visible. 248 // The shelf should start out as visible.
233 ash::ShelfLayoutManager* shelf = 249 ash::ShelfLayoutManager* shelf =
234 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 250 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
235 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); 251 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
236 252
237 // 1) Test that entering tab fullscreen from immersive fullscreen hides the 253 // 1) Test that entering tab fullscreen from immersive fullscreen hides the
238 // tab indicators and the shelf. 254 // tab indicators and the shelf.
255 // Note that tab indicators are removed from MD, so ShouldHideTabIndicators()
256 // always returns true.
239 ToggleFullscreen(); 257 ToggleFullscreen();
240 ASSERT_TRUE(controller()->IsEnabled()); 258 ASSERT_TRUE(controller()->IsEnabled());
241 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 259 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
242 EXPECT_FALSE(controller()->ShouldHideTabIndicators()); 260 if (!ash::MaterialDesignController::IsShelfMaterial())
261 EXPECT_FALSE(controller()->ShouldHideTabIndicators());
243 262
244 SetTabFullscreen(true); 263 SetTabFullscreen(true);
245 ASSERT_TRUE(controller()->IsEnabled()); 264 ASSERT_TRUE(controller()->IsEnabled());
246 EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state()); 265 EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state());
247 EXPECT_TRUE(controller()->ShouldHideTabIndicators()); 266 if (!ash::MaterialDesignController::IsShelfMaterial())
267 EXPECT_TRUE(controller()->ShouldHideTabIndicators());
248 268
249 // 2) Test that exiting tab fullscreen shows the tab indicators and autohides 269 // 2) Test that exiting tab fullscreen shows the tab indicators and autohides
250 // the shelf. 270 // the shelf.
251 SetTabFullscreen(false); 271 SetTabFullscreen(false);
252 ASSERT_TRUE(controller()->IsEnabled()); 272 ASSERT_TRUE(controller()->IsEnabled());
253 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 273 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
254 EXPECT_FALSE(controller()->ShouldHideTabIndicators()); 274 if (!ash::MaterialDesignController::IsShelfMaterial())
275 EXPECT_FALSE(controller()->ShouldHideTabIndicators());
255 276
256 // 3) Test that exiting tab fullscreen and immersive fullscreen 277 // 3) Test that exiting tab fullscreen and immersive fullscreen
257 // simultaneously correctly updates the shelf visibility and whether the tab 278 // simultaneously correctly updates the shelf visibility and whether the tab
258 // indicators should be hidden. 279 // indicators should be hidden.
259 SetTabFullscreen(true); 280 SetTabFullscreen(true);
260 ToggleFullscreen(); 281 ToggleFullscreen();
261 ASSERT_FALSE(controller()->IsEnabled()); 282 ASSERT_FALSE(controller()->IsEnabled());
262 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); 283 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
263 EXPECT_TRUE(controller()->ShouldHideTabIndicators()); 284 if (!ash::MaterialDesignController::IsShelfMaterial())
285 EXPECT_TRUE(controller()->ShouldHideTabIndicators());
264 } 286 }
265 287
266 // Ensure the circular tab-loading throbbers are not painted as layers in 288 // Ensure the circular tab-loading throbbers are not painted as layers in
267 // immersive fullscreen, since the tab strip may animate in or out without 289 // immersive fullscreen, since the tab strip may animate in or out without
268 // moving the layers. 290 // moving the layers.
269 TEST_F(ImmersiveModeControllerAshTest, LayeredSpinners) { 291 TEST_F(ImmersiveModeControllerAshTest, LayeredSpinners) {
270 AddTab(browser(), GURL("about:blank")); 292 AddTab(browser(), GURL("about:blank"));
271 293
272 TabStrip* tabstrip = browser_view()->tabstrip(); 294 TabStrip* tabstrip = browser_view()->tabstrip();
273 295
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 371
350 // Exit immersive fullscreen. The web contents should be back below the window 372 // Exit immersive fullscreen. The web contents should be back below the window
351 // header. 373 // header.
352 ToggleFullscreen(); 374 ToggleFullscreen();
353 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); 375 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen());
354 EXPECT_FALSE(controller()->IsEnabled()); 376 EXPECT_FALSE(controller()->IsEnabled());
355 EXPECT_FALSE(tabstrip->visible()); 377 EXPECT_FALSE(tabstrip->visible());
356 EXPECT_FALSE(toolbar->visible()); 378 EXPECT_FALSE(toolbar->visible());
357 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y()); 379 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y());
358 } 380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698