| 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/shelf/shelf_layout_manager.h" | 7 #include "ash/common/shelf/shelf_layout_manager.h" |
| 8 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 EXPECT_TRUE(tabstrip->visible()); | 125 EXPECT_TRUE(tabstrip->visible()); |
| 126 EXPECT_TRUE(toolbar->visible()); | 126 EXPECT_TRUE(toolbar->visible()); |
| 127 | 127 |
| 128 ToggleFullscreen(); | 128 ToggleFullscreen(); |
| 129 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen()); | 129 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen()); |
| 130 EXPECT_TRUE(controller()->IsEnabled()); | 130 EXPECT_TRUE(controller()->IsEnabled()); |
| 131 EXPECT_FALSE(controller()->IsRevealed()); | 131 EXPECT_FALSE(controller()->IsRevealed()); |
| 132 EXPECT_FALSE(toolbar->visible()); | 132 EXPECT_FALSE(toolbar->visible()); |
| 133 // The browser's top chrome is completely offscreen with tapstrip visible. | 133 // The browser's top chrome is completely offscreen with tapstrip visible. |
| 134 EXPECT_TRUE(tabstrip->visible()); | 134 EXPECT_TRUE(tabstrip->visible()); |
| 135 | 135 // Tabstrip and top container view should be completely offscreen. |
| 136 // The tab indicators should be flush with the top of the widget. | 136 EXPECT_EQ(0, GetBoundsInWidget(tabstrip).bottom()); |
| 137 EXPECT_EQ(0, GetBoundsInWidget(tabstrip).y()); | 137 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).bottom()); |
| 138 | 138 |
| 139 // Since the tab strip and tool bar are both hidden in immersive fullscreen | 139 // Since the tab strip and tool bar are both hidden in immersive fullscreen |
| 140 // mode, the web contents should extend to the edge of screen. | 140 // mode, the web contents should extend to the edge of screen. |
| 141 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); | 141 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); |
| 142 | 142 |
| 143 // 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 |
| 144 // normal style and show the toolbar. | 144 // normal style and show the toolbar. |
| 145 AttemptReveal(); | 145 AttemptReveal(); |
| 146 EXPECT_TRUE(controller()->IsRevealed()); | 146 EXPECT_TRUE(controller()->IsRevealed()); |
| 147 EXPECT_TRUE(tabstrip->visible()); | 147 EXPECT_TRUE(tabstrip->visible()); |
| 148 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); | |
| 149 EXPECT_TRUE(toolbar->visible()); | 148 EXPECT_TRUE(toolbar->visible()); |
| 150 | 149 |
| 151 // The TopContainerView should be flush with the top edge of the widget. If | 150 // The TopContainerView should be flush with the top edge of the widget. If |
| 152 // it is not flush with the top edge the immersive reveal animation looks | 151 // it is not flush with the top edge the immersive reveal animation looks |
| 153 // wonky. | 152 // wonky. |
| 154 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); | 153 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); |
| 155 | 154 |
| 156 // The web contents should be at the same y position as they were when the | 155 // The web contents should be at the same y position as they were when the |
| 157 // top-of-window views were hidden. | 156 // top-of-window views were hidden. |
| 158 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); | 157 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); |
| 159 | 158 |
| 160 // Repeat the test for when in both immersive fullscreen and tab fullscreen. | 159 // Repeat the test for when in both immersive fullscreen and tab fullscreen. |
| 161 SetTabFullscreen(true); | 160 SetTabFullscreen(true); |
| 162 // Hide and reveal the top-of-window views so that they get relain out. | 161 // Hide and reveal the top-of-window views so that they get relain out. |
| 163 AttemptUnreveal(); | 162 AttemptUnreveal(); |
| 164 AttemptReveal(); | 163 AttemptReveal(); |
| 165 | 164 |
| 166 // The tab strip and toolbar should still be visible and the TopContainerView | 165 // The tab strip and toolbar should still be visible and the TopContainerView |
| 167 // should still be flush with the top edge of the widget. | 166 // should still be flush with the top edge of the widget. |
| 168 EXPECT_TRUE(controller()->IsRevealed()); | 167 EXPECT_TRUE(controller()->IsRevealed()); |
| 169 EXPECT_TRUE(tabstrip->visible()); | 168 EXPECT_TRUE(tabstrip->visible()); |
| 170 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); | |
| 171 EXPECT_TRUE(toolbar->visible()); | 169 EXPECT_TRUE(toolbar->visible()); |
| 172 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); | 170 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); |
| 173 | 171 |
| 174 // The web contents should be flush with the top edge of the widget when in | 172 // The web contents should be flush with the top edge of the widget when in |
| 175 // both immersive and tab fullscreen. | 173 // both immersive and tab fullscreen. |
| 176 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); | 174 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); |
| 177 | 175 |
| 178 // Hide the top-of-window views. Tabstrip is still considered as visible. | 176 // Hide the top-of-window views. Tabstrip is still considered as visible. |
| 179 AttemptUnreveal(); | 177 AttemptUnreveal(); |
| 180 EXPECT_FALSE(controller()->IsRevealed()); | 178 EXPECT_FALSE(controller()->IsRevealed()); |
| 181 EXPECT_FALSE(toolbar->visible()); | 179 EXPECT_FALSE(toolbar->visible()); |
| 182 EXPECT_TRUE(tabstrip->visible()); | 180 EXPECT_TRUE(tabstrip->visible()); |
| 183 | 181 |
| 184 // The web contents should still be flush with the edge of the widget. | 182 // The web contents should still be flush with the edge of the widget. |
| 185 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); | 183 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); |
| 186 | 184 |
| 187 // Exiting both immersive and tab fullscreen should show the tab strip and | 185 // Exiting both immersive and tab fullscreen should show the tab strip and |
| 188 // toolbar. | 186 // toolbar. |
| 189 ToggleFullscreen(); | 187 ToggleFullscreen(); |
| 190 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); | 188 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); |
| 191 EXPECT_FALSE(controller()->IsEnabled()); | 189 EXPECT_FALSE(controller()->IsEnabled()); |
| 192 EXPECT_FALSE(controller()->IsRevealed()); | 190 EXPECT_FALSE(controller()->IsRevealed()); |
| 193 EXPECT_TRUE(tabstrip->visible()); | 191 EXPECT_TRUE(tabstrip->visible()); |
| 194 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); | |
| 195 EXPECT_TRUE(toolbar->visible()); | 192 EXPECT_TRUE(toolbar->visible()); |
| 196 } | 193 } |
| 197 | 194 |
| 198 // Test that the browser commands which are usually disabled in fullscreen are | 195 // Test that the browser commands which are usually disabled in fullscreen are |
| 199 // are enabled in immersive fullscreen. | 196 // are enabled in immersive fullscreen. |
| 200 TEST_F(ImmersiveModeControllerAshTest, EnabledCommands) { | 197 TEST_F(ImmersiveModeControllerAshTest, EnabledCommands) { |
| 201 ASSERT_FALSE(controller()->IsEnabled()); | 198 ASSERT_FALSE(controller()->IsEnabled()); |
| 202 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | 199 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); |
| 203 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | 200 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); |
| 204 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | 201 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 216 ToggleFullscreen(); | 213 ToggleFullscreen(); |
| 217 AttemptReveal(); | 214 AttemptReveal(); |
| 218 ASSERT_TRUE(controller()->IsEnabled()); | 215 ASSERT_TRUE(controller()->IsEnabled()); |
| 219 ASSERT_TRUE(controller()->IsRevealed()); | 216 ASSERT_TRUE(controller()->IsRevealed()); |
| 220 ASSERT_TRUE(browser_view()->GetWidget()->IsFullscreen()); | 217 ASSERT_TRUE(browser_view()->GetWidget()->IsFullscreen()); |
| 221 | 218 |
| 222 browser_view()->GetWidget()->Restore(); | 219 browser_view()->GetWidget()->Restore(); |
| 223 EXPECT_FALSE(controller()->IsEnabled()); | 220 EXPECT_FALSE(controller()->IsEnabled()); |
| 224 } | 221 } |
| 225 | 222 |
| 226 // Test how being simultaneously in tab fullscreen and immersive fullscreen | 223 // Test the shelf visibility affected by entering and exiting tab fullscreen and |
| 227 // affects the shelf visibility and whether the tab indicators are hidden. | 224 // immersive fullscreen. |
| 228 TEST_F(ImmersiveModeControllerAshTest, TabAndBrowserFullscreen) { | 225 TEST_F(ImmersiveModeControllerAshTest, TabAndBrowserFullscreen) { |
| 229 AddTab(browser(), GURL("about:blank")); | 226 AddTab(browser(), GURL("about:blank")); |
| 230 | 227 |
| 231 // The shelf should start out as visible. | 228 // The shelf should start out as visible. |
| 232 ash::ShelfLayoutManager* shelf = | 229 ash::ShelfLayoutManager* shelf = |
| 233 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 230 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 234 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); | 231 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); |
| 235 | 232 |
| 236 // 1) Test that entering tab fullscreen from immersive fullscreen hides the | 233 // 1) Test that entering tab fullscreen from immersive fullscreen hides |
| 237 // tab indicators and the shelf. | 234 // the shelf. |
| 238 // Note that tab indicators are removed from MD, so ShouldHideTabIndicators() | |
| 239 // always returns true. | |
| 240 ToggleFullscreen(); | 235 ToggleFullscreen(); |
| 241 ASSERT_TRUE(controller()->IsEnabled()); | 236 ASSERT_TRUE(controller()->IsEnabled()); |
| 242 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 237 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 243 | 238 |
| 244 SetTabFullscreen(true); | 239 SetTabFullscreen(true); |
| 245 ASSERT_TRUE(controller()->IsEnabled()); | 240 ASSERT_TRUE(controller()->IsEnabled()); |
| 246 EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state()); | 241 EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state()); |
| 247 | 242 |
| 248 // 2) Test that exiting tab fullscreen shows the tab indicators and autohides | 243 // 2) Test that exiting tab fullscreen autohides the shelf. |
| 249 // the shelf. | |
| 250 SetTabFullscreen(false); | 244 SetTabFullscreen(false); |
| 251 ASSERT_TRUE(controller()->IsEnabled()); | 245 ASSERT_TRUE(controller()->IsEnabled()); |
| 252 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 246 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 253 | 247 |
| 254 // 3) Test that exiting tab fullscreen and immersive fullscreen simultaneously | 248 // 3) Test that exiting tab fullscreen and immersive fullscreen correctly |
| 255 // correctly updates the shelf visibility and whether the tab indicators | 249 // updates the shelf visibility. |
| 256 // should be hidden. | |
| 257 SetTabFullscreen(true); | 250 SetTabFullscreen(true); |
| 258 ToggleFullscreen(); | 251 ToggleFullscreen(); |
| 259 ASSERT_FALSE(controller()->IsEnabled()); | 252 ASSERT_FALSE(controller()->IsEnabled()); |
| 260 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); | 253 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); |
| 261 } | 254 } |
| 262 | 255 |
| 263 // Ensure the circular tab-loading throbbers are not painted as layers in | 256 // Ensure the circular tab-loading throbbers are not painted as layers in |
| 264 // immersive fullscreen, since the tab strip may animate in or out without | 257 // immersive fullscreen, since the tab strip may animate in or out without |
| 265 // moving the layers. | 258 // moving the layers. |
| 266 TEST_F(ImmersiveModeControllerAshTest, LayeredSpinners) { | 259 TEST_F(ImmersiveModeControllerAshTest, LayeredSpinners) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 340 |
| 348 // Exit immersive fullscreen. The web contents should be back below the window | 341 // Exit immersive fullscreen. The web contents should be back below the window |
| 349 // header. | 342 // header. |
| 350 ToggleFullscreen(); | 343 ToggleFullscreen(); |
| 351 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); | 344 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); |
| 352 EXPECT_FALSE(controller()->IsEnabled()); | 345 EXPECT_FALSE(controller()->IsEnabled()); |
| 353 EXPECT_FALSE(tabstrip->visible()); | 346 EXPECT_FALSE(tabstrip->visible()); |
| 354 EXPECT_FALSE(toolbar->visible()); | 347 EXPECT_FALSE(toolbar->visible()); |
| 355 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y()); | 348 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y()); |
| 356 } | 349 } |
| OLD | NEW |