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

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

Issue 14340007: Hide the tab indicators and the shelf when in immersive + tab fullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed kImmersiveModeKey Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_layout_manager.h" 9 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_types.h" 10 #include "ash/shelf/shelf_types.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/window_properties.h" 12 #include "ash/wm/window_properties.h"
13 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 17 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
18 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 18 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
19 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" 19 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h"
20 #include "chrome/browser/ui/browser_commands.h" 20 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
22 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
21 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 23 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
22 #include "chrome/browser/ui/views/browser_dialogs.h" 24 #include "chrome/browser/ui/views/browser_dialogs.h"
23 #include "chrome/browser/ui/views/frame/browser_view.h" 25 #include "chrome/browser/ui/views/frame/browser_view.h"
24 #include "chrome/browser/ui/views/frame/top_container_view.h" 26 #include "chrome/browser/ui/views/frame/top_container_view.h"
25 #include "chrome/browser/ui/views/tabs/tab.h" 27 #include "chrome/browser/ui/views/tabs/tab.h"
26 #include "chrome/browser/ui/views/tabs/tab_strip.h" 28 #include "chrome/browser/ui/views/tabs/tab_strip.h"
27 #include "chrome/test/base/in_process_browser_test.h" 29 #include "chrome/test/base/in_process_browser_test.h"
28 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
29 #include "content/public/browser/javascript_dialog_manager.h" 31 #include "content/public/browser/javascript_dialog_manager.h"
30 #include "ui/compositor/layer_animator.h" 32 #include "ui/compositor/layer_animator.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ASSERT_FALSE(browser_view->IsFullscreen()); 158 ASSERT_FALSE(browser_view->IsFullscreen());
157 EXPECT_FALSE(controller->IsEnabled()); 159 EXPECT_FALSE(controller->IsEnabled());
158 EXPECT_FALSE(controller->ShouldHideTopViews()); 160 EXPECT_FALSE(controller->ShouldHideTopViews());
159 EXPECT_FALSE(controller->IsRevealed()); 161 EXPECT_FALSE(controller->IsRevealed());
160 EXPECT_FALSE(browser_view->tabstrip()->IsImmersiveStyle()); 162 EXPECT_FALSE(browser_view->tabstrip()->IsImmersiveStyle());
161 EXPECT_TRUE(browser_view->IsTabStripVisible()); 163 EXPECT_TRUE(browser_view->IsTabStripVisible());
162 EXPECT_TRUE(browser_view->IsToolbarVisible()); 164 EXPECT_TRUE(browser_view->IsToolbarVisible());
163 165
164 // When hiding the tab indicators, content is at the top of the browser view 166 // When hiding the tab indicators, content is at the top of the browser view
165 // both before and during reveal. 167 // both before and during reveal.
166 controller->SetHideTabIndicatorsForTest(true); 168 controller->SetForceHideTabIndicatorsForTest(true);
167 chrome::ToggleFullscreenMode(browser()); 169 chrome::ToggleFullscreenMode(browser());
168 ASSERT_TRUE(browser_view->IsFullscreen()); 170 ASSERT_TRUE(browser_view->IsFullscreen());
169 EXPECT_FALSE(browser_view->IsTabStripVisible()); 171 EXPECT_FALSE(browser_view->IsTabStripVisible());
170 EXPECT_EQ(GetRectInWidget(browser_view).y(), 172 EXPECT_EQ(GetRectInWidget(browser_view).y(),
171 GetRectInWidget(contents_view).y()); 173 GetRectInWidget(contents_view).y());
172 controller->StartRevealForTest(true); 174 controller->StartRevealForTest(true);
173 EXPECT_TRUE(browser_view->IsTabStripVisible()); 175 EXPECT_TRUE(browser_view->IsTabStripVisible());
174 // Shelf hide triggered by enabling immersive mode eventually changes the 176 // Shelf hide triggered by enabling immersive mode eventually changes the
175 // widget bounds and causes a Layout(). Force it to happen early for test. 177 // widget bounds and causes a Layout(). Force it to happen early for test.
176 browser_view->parent()->Layout(); 178 browser_view->parent()->Layout();
177 EXPECT_EQ(GetRectInWidget(browser_view).y(), 179 EXPECT_EQ(GetRectInWidget(browser_view).y(),
178 GetRectInWidget(contents_view).y()); 180 GetRectInWidget(contents_view).y());
179 chrome::ToggleFullscreenMode(browser()); 181 chrome::ToggleFullscreenMode(browser());
180 ASSERT_FALSE(browser_view->IsFullscreen()); 182 ASSERT_FALSE(browser_view->IsFullscreen());
181 controller->SetHideTabIndicatorsForTest(false); 183 controller->SetForceHideTabIndicatorsForTest(false);
182 184
183 // Reveal ends when the mouse moves out of the reveal view. 185 // Reveal ends when the mouse moves out of the reveal view.
184 chrome::ToggleFullscreenMode(browser()); 186 chrome::ToggleFullscreenMode(browser());
185 ASSERT_TRUE(browser_view->IsFullscreen()); 187 ASSERT_TRUE(browser_view->IsFullscreen());
186 EXPECT_TRUE(controller->IsEnabled()); 188 EXPECT_TRUE(controller->IsEnabled());
187 controller->StartRevealForTest(true); 189 controller->StartRevealForTest(true);
188 controller->SetMouseHoveredForTest(false); 190 controller->SetMouseHoveredForTest(false);
189 EXPECT_FALSE(controller->IsRevealed()); 191 EXPECT_FALSE(controller->IsRevealed());
190 192
191 // Window restore tracking is only implemented in the Aura port. 193 // Window restore tracking is only implemented in the Aura port.
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 chrome::ToggleFullscreenMode(browser()); 600 chrome::ToggleFullscreenMode(browser());
599 ASSERT_TRUE(browser_view->IsFullscreen()); 601 ASSERT_TRUE(browser_view->IsFullscreen());
600 ASSERT_TRUE(immersive_controller->IsEnabled()); 602 ASSERT_TRUE(immersive_controller->IsEnabled());
601 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 603 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
602 604
603 // Disabling immersive mode maintains the user's auto-hide selection. 605 // Disabling immersive mode maintains the user's auto-hide selection.
604 chrome::ToggleFullscreenMode(browser()); 606 chrome::ToggleFullscreenMode(browser());
605 ASSERT_FALSE(browser_view->IsFullscreen()); 607 ASSERT_FALSE(browser_view->IsFullscreen());
606 ASSERT_FALSE(immersive_controller->IsEnabled()); 608 ASSERT_FALSE(immersive_controller->IsEnabled());
607 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 609 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
610 }
608 611
609 // Setting the window property directly toggles immersive mode. 612 // Test how being simultaneously in tab fullscreen and immersive fullscreen
610 aura::Window* window = browser_view->GetWidget()->GetNativeWindow(); 613 // affects the shelf visibility and whether the tab indicators are hidden.
611 window->SetProperty(ash::internal::kImmersiveModeKey, true); 614 IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerAshTest,
612 EXPECT_TRUE(immersive_controller->IsEnabled()); 615 TabAndBrowserFullscreen) {
613 window->SetProperty(ash::internal::kImmersiveModeKey, false); 616 ui::ScopedAnimationDurationScaleMode zero_duration_mode(
614 EXPECT_FALSE(immersive_controller->IsEnabled()); 617 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
618 ASSERT_TRUE(chrome::UseImmersiveFullscreen());
619
620 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
621 ash::internal::ShelfLayoutManager* shelf =
622 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
623 ImmersiveModeControllerAsh* controller =
624 static_cast<ImmersiveModeControllerAsh*>(
625 browser_view->immersive_mode_controller());
626
627 controller->SetForceHideTabIndicatorsForTest(false);
628
629 // The shelf should start out as visible.
630 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
631
632 // 1) Test that entering tab fullscreen from immersive mode hides the tab
633 // indicators and the shelf.
634 chrome::ToggleFullscreenMode(browser());
635 ASSERT_TRUE(controller->IsEnabled());
636 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
637 EXPECT_FALSE(controller->ShouldHideTabIndicators());
638
639 // The shelf visibility and the tab indicator visibility are updated as a
640 // result of NOTIFICATION_FULLSCREEN_CHANGED which is asynchronous. Wait for
641 // the notification before testing visibility.
642 scoped_ptr<FullscreenNotificationObserver> waiter(
643 new FullscreenNotificationObserver());
644
645 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
646 browser_view->GetActiveWebContents(), true);
647 waiter->Wait();
648 ASSERT_TRUE(controller->IsEnabled());
649 EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state());
650 EXPECT_TRUE(controller->ShouldHideTabIndicators());
651
652 // 2) Test that exiting tab fullscreen shows the tab indicators and autohides
653 // the shelf.
654 waiter.reset(new FullscreenNotificationObserver());
655 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
656 browser_view->GetActiveWebContents(), false);
657 waiter->Wait();
658 ASSERT_TRUE(controller->IsEnabled());
659 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
660 EXPECT_FALSE(controller->ShouldHideTabIndicators());
661
662 // 3) Test that exiting tab fullscreen and immersive fullscreen
663 // simultaneously correctly updates the shelf visibility and whether the tab
664 // indicators should be hidden.
665 waiter.reset(new FullscreenNotificationObserver());
666 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
667 browser_view->GetActiveWebContents(), true);
668 waiter->Wait();
669 waiter.reset(new FullscreenNotificationObserver());
670 chrome::ToggleFullscreenMode(browser());
671 waiter->Wait();
672
673 ASSERT_FALSE(controller->IsEnabled());
674 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
675 EXPECT_TRUE(controller->ShouldHideTabIndicators());
615 } 676 }
616 677
617 #endif // defined(OS_CHROMEOS) 678 #endif // defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698