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