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

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

Issue 2640433004: ChromeOS MD: Fix cannot drag tab onto immersive fullscreen window (Closed)
Patch Set: nits for ps9 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 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" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/shelf/shelf_layout_manager.h" 8 #include "ash/common/shelf/shelf_layout_manager.h"
9 #include "ash/public/cpp/shelf_types.h" 9 #include "ash/public/cpp/shelf_types.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 private: 102 private:
103 // Not owned. 103 // Not owned.
104 ImmersiveModeController* controller_; 104 ImmersiveModeController* controller_;
105 105
106 std::unique_ptr<ImmersiveRevealedLock> revealed_lock_; 106 std::unique_ptr<ImmersiveRevealedLock> revealed_lock_;
107 107
108 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest); 108 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest);
109 }; 109 };
110 110
111 // Test the layout and visibility of the tabstrip, toolbar and TopContainerView 111 // Test the layout and visibility of the tabstrip, toolbar and TopContainerView
112 // in immersive fullscreen. 112 // in immersive fullscreen. For MD, tabstrip is considered as visible with top
113 // container offscreen.
113 TEST_F(ImmersiveModeControllerAshTest, Layout) { 114 TEST_F(ImmersiveModeControllerAshTest, Layout) {
114 AddTab(browser(), GURL("about:blank")); 115 AddTab(browser(), GURL("about:blank"));
115 116
116 TabStrip* tabstrip = browser_view()->tabstrip(); 117 TabStrip* tabstrip = browser_view()->tabstrip();
117 ToolbarView* toolbar = browser_view()->toolbar(); 118 ToolbarView* toolbar = browser_view()->toolbar();
118 views::WebView* contents_web_view = 119 views::WebView* contents_web_view =
119 browser_view()->GetContentsWebViewForTest(); 120 browser_view()->GetContentsWebViewForTest();
120 121
121 // Immersive fullscreen starts out disabled. 122 // Immersive fullscreen starts out disabled.
122 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen()); 123 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen());
123 ASSERT_FALSE(controller()->IsEnabled()); 124 ASSERT_FALSE(controller()->IsEnabled());
124 125
125 // By default, the tabstrip and toolbar should be visible. 126 // By default, the tabstrip and toolbar should be visible.
126 EXPECT_TRUE(tabstrip->visible()); 127 EXPECT_TRUE(tabstrip->visible());
127 EXPECT_TRUE(toolbar->visible()); 128 EXPECT_TRUE(toolbar->visible());
128 129
129 ToggleFullscreen(); 130 ToggleFullscreen();
130 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen()); 131 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen());
131 EXPECT_TRUE(controller()->IsEnabled()); 132 EXPECT_TRUE(controller()->IsEnabled());
132 EXPECT_FALSE(controller()->IsRevealed()); 133 EXPECT_FALSE(controller()->IsRevealed());
133 EXPECT_FALSE(toolbar->visible()); 134 EXPECT_FALSE(toolbar->visible());
134 // For MD, the browser's top chrome is completely hidden in immersive 135 // For MD, the browser's top chrome is completely offscreen with tapstrip
135 // fullscreen mode. 136 // visible.
136 bool is_using_material_design = 137 bool is_using_material_design =
137 ash::MaterialDesignController::IsImmersiveModeMaterial(); 138 ash::MaterialDesignController::IsImmersiveModeMaterial();
138 if (is_using_material_design) { 139 EXPECT_TRUE(tabstrip->visible());
139 EXPECT_FALSE(tabstrip->visible()); 140 if (!is_using_material_design)
140 } else {
141 EXPECT_TRUE(tabstrip->visible());
142 EXPECT_TRUE(tabstrip->IsImmersiveStyle()); 141 EXPECT_TRUE(tabstrip->IsImmersiveStyle());
143 }
144 142
145 // The tab indicators should be flush with the top of the widget. 143 // The tab indicators should be flush with the top of the widget.
146 EXPECT_EQ(0, GetBoundsInWidget(tabstrip).y()); 144 EXPECT_EQ(0, GetBoundsInWidget(tabstrip).y());
147 145
148 // In MD, since the tab strip and tool bar are both hidden in immersive 146 // In MD, since the tab strip and tool bar are both hidden in immersive
149 // fullscreen mode, the web contents should extend to the edge of screen. In 147 // fullscreen mode, the web contents should extend to the edge of screen. In
150 // non-MD, the web contents should be immediately below the tab indicators. 148 // non-MD, the web contents should be immediately below the tab indicators.
151 if (is_using_material_design) { 149 if (is_using_material_design) {
152 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); 150 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
153 } else { 151 } else {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 EXPECT_TRUE(controller()->IsRevealed()); 186 EXPECT_TRUE(controller()->IsRevealed());
189 EXPECT_TRUE(tabstrip->visible()); 187 EXPECT_TRUE(tabstrip->visible());
190 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); 188 EXPECT_FALSE(tabstrip->IsImmersiveStyle());
191 EXPECT_TRUE(toolbar->visible()); 189 EXPECT_TRUE(toolbar->visible());
192 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); 190 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y());
193 191
194 // The web contents should be flush with the top edge of the widget when in 192 // The web contents should be flush with the top edge of the widget when in
195 // both immersive and tab fullscreen. 193 // both immersive and tab fullscreen.
196 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); 194 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
197 195
198 // Hide the top-of-window views. Both the tab strip and the toolbar should 196 // Hide the top-of-window views. For MD, tabstrip is considered as visible.
199 // hide when in both immersive and tab fullscreen.
200 AttemptUnreveal(); 197 AttemptUnreveal();
201 EXPECT_FALSE(controller()->IsRevealed()); 198 EXPECT_FALSE(controller()->IsRevealed());
202 EXPECT_FALSE(tabstrip->visible()); 199 if (is_using_material_design)
200 EXPECT_TRUE(tabstrip->visible());
201 else
202 EXPECT_FALSE(tabstrip->visible());
203 EXPECT_FALSE(toolbar->visible()); 203 EXPECT_FALSE(toolbar->visible());
204 204
205 // The web contents should still be flush with the edge of the widget. 205 // The web contents should still be flush with the edge of the widget.
206 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); 206 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
207 207
208 // Exiting both immersive and tab fullscreen should show the tab strip and 208 // Exiting both immersive and tab fullscreen should show the tab strip and
209 // toolbar. 209 // toolbar.
210 ToggleFullscreen(); 210 ToggleFullscreen();
211 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); 211 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen());
212 EXPECT_FALSE(controller()->IsEnabled()); 212 EXPECT_FALSE(controller()->IsEnabled());
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 public: 316 public:
317 ImmersiveModeControllerAshTestHostedApp() 317 ImmersiveModeControllerAshTestHostedApp()
318 : ImmersiveModeControllerAshTest(Browser::TYPE_POPUP, true) {} 318 : ImmersiveModeControllerAshTest(Browser::TYPE_POPUP, true) {}
319 ~ImmersiveModeControllerAshTestHostedApp() override {} 319 ~ImmersiveModeControllerAshTestHostedApp() override {}
320 320
321 private: 321 private:
322 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestHostedApp); 322 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestHostedApp);
323 }; 323 };
324 324
325 // Test the layout and visibility of the TopContainerView and web contents when 325 // Test the layout and visibility of the TopContainerView and web contents when
326 // a hosted app is put into immersive fullscreen. 326 // a hosted app is put into immersive fullscreen. For MD, tabstrip is considered
327 // as visible with immersive fullsceen.
327 TEST_F(ImmersiveModeControllerAshTestHostedApp, Layout) { 328 TEST_F(ImmersiveModeControllerAshTestHostedApp, Layout) {
328 // Add a tab because the browser starts out without any tabs at all. 329 // Add a tab because the browser starts out without any tabs at all.
329 AddTab(browser(), GURL("about:blank")); 330 AddTab(browser(), GURL("about:blank"));
330 331
331 TabStrip* tabstrip = browser_view()->tabstrip(); 332 TabStrip* tabstrip = browser_view()->tabstrip();
332 ToolbarView* toolbar = browser_view()->toolbar(); 333 ToolbarView* toolbar = browser_view()->toolbar();
333 views::WebView* contents_web_view = 334 views::WebView* contents_web_view =
334 browser_view()->GetContentsWebViewForTest(); 335 browser_view()->GetContentsWebViewForTest();
335 views::View* top_container = browser_view()->top_container(); 336 views::View* top_container = browser_view()->top_container();
336 337
337 // Immersive fullscreen starts out disabled. 338 // Immersive fullscreen starts out disabled.
338 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen()); 339 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen());
339 ASSERT_FALSE(controller()->IsEnabled()); 340 ASSERT_FALSE(controller()->IsEnabled());
340 341
341 // The tabstrip and toolbar are not visible for hosted apps. 342 // The tabstrip and toolbar are not visible for hosted apps.
342 EXPECT_FALSE(tabstrip->visible()); 343 EXPECT_FALSE(tabstrip->visible());
343 EXPECT_FALSE(toolbar->visible()); 344 EXPECT_FALSE(toolbar->visible());
344 345
345 // The window header should be above the web contents. 346 // The window header should be above the web contents.
346 int header_height = GetBoundsInWidget(contents_web_view).y(); 347 int header_height = GetBoundsInWidget(contents_web_view).y();
347 348
348 ToggleFullscreen(); 349 ToggleFullscreen();
349 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen()); 350 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen());
350 EXPECT_TRUE(controller()->IsEnabled()); 351 EXPECT_TRUE(controller()->IsEnabled());
351 EXPECT_FALSE(controller()->IsRevealed()); 352 EXPECT_FALSE(controller()->IsRevealed());
352 353
353 // Entering immersive fullscreen should make the web contents flush with the 354 // Entering immersive fullscreen should make the web contents flush with the
354 // top of the widget. 355 // top of the widget.
355 EXPECT_FALSE(tabstrip->visible());
356 EXPECT_FALSE(toolbar->visible()); 356 EXPECT_FALSE(toolbar->visible());
357 EXPECT_TRUE(top_container->GetVisibleBounds().IsEmpty()); 357 bool is_using_material_design =
358 ash::MaterialDesignController::IsImmersiveModeMaterial();
359 if (is_using_material_design) {
360 EXPECT_TRUE(tabstrip->visible());
361 } else {
362 EXPECT_FALSE(tabstrip->visible());
363 EXPECT_TRUE(top_container->GetVisibleBounds().IsEmpty());
364 }
358 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); 365 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
359 366
360 // Reveal the window header. 367 // Reveal the window header.
361 AttemptReveal(); 368 AttemptReveal();
362 369
363 // The tabstrip and toolbar should still be hidden and the web contents should 370 // The tabstrip and toolbar should still be hidden and the web contents should
364 // still be flush with the top of the screen. 371 // still be flush with the top of the screen.
365 EXPECT_FALSE(tabstrip->visible()); 372 EXPECT_FALSE(tabstrip->visible());
366 EXPECT_FALSE(toolbar->visible()); 373 EXPECT_FALSE(toolbar->visible());
367 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); 374 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
368 375
369 // During an immersive reveal, the window header should be painted to the 376 // During an immersive reveal, the window header should be painted to the
370 // TopContainerView. The TopContainerView should be flush with the top of the 377 // TopContainerView. The TopContainerView should be flush with the top of the
371 // widget and have |header_height|. 378 // widget and have |header_height|.
372 gfx::Rect top_container_bounds_in_widget(GetBoundsInWidget(top_container)); 379 gfx::Rect top_container_bounds_in_widget(GetBoundsInWidget(top_container));
373 EXPECT_EQ(0, top_container_bounds_in_widget.y()); 380 EXPECT_EQ(0, top_container_bounds_in_widget.y());
374 EXPECT_EQ(header_height, top_container_bounds_in_widget.height()); 381 EXPECT_EQ(header_height, top_container_bounds_in_widget.height());
375 382
376 // Exit immersive fullscreen. The web contents should be back below the window 383 // Exit immersive fullscreen. The web contents should be back below the window
377 // header. 384 // header.
378 ToggleFullscreen(); 385 ToggleFullscreen();
379 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); 386 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen());
380 EXPECT_FALSE(controller()->IsEnabled()); 387 EXPECT_FALSE(controller()->IsEnabled());
381 EXPECT_FALSE(tabstrip->visible()); 388 EXPECT_FALSE(tabstrip->visible());
382 EXPECT_FALSE(toolbar->visible()); 389 EXPECT_FALSE(toolbar->visible());
383 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y()); 390 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y());
384 } 391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698