Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 129 // Entering immersive fullscreen should make the tab strip use the immersive | 130 // In MD, tab strip and tool bar are both hidden in immersive fullscreen mode; |
|
tdanderson
2016/07/19 21:10:24
Suggested rewording of entire comment: "For MD, th
yiyix
2016/07/20 06:03:08
Done.
| |
| 130 // style and hide the toolbar. | 131 // whereas the tab strip are are shown in non-MD. |
| 131 EXPECT_TRUE(tabstrip->visible()); | 132 if (ash::MaterialDesignController::IsShelfMaterial()) { |
| 132 EXPECT_TRUE(tabstrip->IsImmersiveStyle()); | 133 EXPECT_FALSE(tabstrip->visible()); |
| 133 EXPECT_FALSE(toolbar->visible()); | 134 EXPECT_FALSE(toolbar->visible()); |
| 135 } else { | |
| 136 EXPECT_TRUE(tabstrip->visible()); | |
| 137 EXPECT_TRUE(tabstrip->IsImmersiveStyle()); | |
|
tdanderson
2016/07/19 21:10:24
I'd move this to line 131 assuming it is true in b
yiyix
2016/07/20 06:03:08
Done.
| |
| 138 EXPECT_FALSE(toolbar->visible()); | |
| 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 tab strip and tool bar are both hidden in immersive fullscreen |
| 139 EXPECT_EQ(Tab::GetImmersiveHeight(), | 145 // mode, the web connents should extend to the edge of screen. In non-MD, the |
|
tdanderson
2016/07/19 21:10:24
connents->contents
yiyix
2016/07/20 06:03:08
I was careless. Thanks.
| |
| 140 GetBoundsInWidget(contents_web_view).y()); | 146 // web contents should be immediately below the tab indicators. |
| 147 if (ash::MaterialDesignController::IsShelfMaterial()) { | |
|
tdanderson
2016/07/19 21:10:23
nit: consider using a local variable const bool md
yiyix
2016/07/20 06:03:08
Done.
| |
| 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 (ash::MaterialDesignController::IsShelfMaterial()) { |
| 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 Loading... | |
| 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 hints are removed from MD, so function | |
| 256 // ShouldHideTabIndicators() always return true. | |
|
tdanderson
2016/07/19 21:10:24
Omit this comment, and instead replace with expect
| |
| 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 Loading... | |
| 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 } |
| OLD | NEW |