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

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: Created 7 years, 7 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 chrome::ToggleFullscreenMode(browser()); 605 chrome::ToggleFullscreenMode(browser());
604 ASSERT_TRUE(browser_view->IsFullscreen()); 606 ASSERT_TRUE(browser_view->IsFullscreen());
605 ASSERT_TRUE(immersive_controller->IsEnabled()); 607 ASSERT_TRUE(immersive_controller->IsEnabled());
606 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 608 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
607 609
608 // Disabling immersive mode maintains the user's auto-hide selection. 610 // Disabling immersive mode maintains the user's auto-hide selection.
609 chrome::ToggleFullscreenMode(browser()); 611 chrome::ToggleFullscreenMode(browser());
610 ASSERT_FALSE(browser_view->IsFullscreen()); 612 ASSERT_FALSE(browser_view->IsFullscreen());
611 ASSERT_FALSE(immersive_controller->IsEnabled()); 613 ASSERT_FALSE(immersive_controller->IsEnabled());
612 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 614 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
615 }
613 616
614 // Setting the window property directly toggles immersive mode. 617 // Test how being simultaneously in tab fullscreen and immersive fullscreen
615 aura::Window* window = browser_view->GetWidget()->GetNativeWindow(); 618 // affects the shelf visibility and whether the tab indicators are hidden.
616 window->SetProperty(ash::internal::kImmersiveModeKey, true); 619 IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerAshTest,
617 EXPECT_TRUE(immersive_controller->IsEnabled()); 620 TabAndBrowserFullscreen) {
618 window->SetProperty(ash::internal::kImmersiveModeKey, false); 621 ui::ScopedAnimationDurationScaleMode zero_duration_mode(
619 EXPECT_FALSE(immersive_controller->IsEnabled()); 622 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
623 ASSERT_TRUE(chrome::UseImmersiveFullscreen());
624
625 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
626 ash::internal::ShelfLayoutManager* shelf =
627 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
628 ImmersiveModeControllerAsh* controller =
629 static_cast<ImmersiveModeControllerAsh*>(
630 browser_view->immersive_mode_controller());
631
632 controller->SetForceHideTabIndicatorsForTest(false);
633
634 // The shelf should start out as visible.
635 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
636
637 // 1) Test that entering tab fullscreen from immersive mode hides the tab
638 // indicators and the shelf.
639 chrome::ToggleFullscreenMode(browser());
640 ASSERT_TRUE(controller->IsEnabled());
641 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
642 EXPECT_FALSE(controller->ShouldHideTabIndicators());
643
644 // The shelf visibility and the tab indicator visibility are updated as a
645 // result of NOTIFICATION_FULLSCREEN_CHANGED which is asynchronous. Wait for
646 // the notification before testing visibility.
647 scoped_ptr<FullscreenNotificationObserver> waiter(
648 new FullscreenNotificationObserver());
649
650 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
651 browser_view->GetActiveWebContents(), true);
652 waiter->Wait();
653 ASSERT_TRUE(controller->IsEnabled());
654 EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state());
655 EXPECT_TRUE(controller->ShouldHideTabIndicators());
656
657 // 2) Test that exiting tab fullscreen shows the tab indicators and autohides
658 // the shelf.
659 waiter.reset(new FullscreenNotificationObserver());
660 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
661 browser_view->GetActiveWebContents(), false);
662 waiter->Wait();
663 ASSERT_TRUE(controller->IsEnabled());
664 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
665 EXPECT_FALSE(controller->ShouldHideTabIndicators());
666
667 // 3) Test that exiting tab fullscreen and immersive fullscreen
668 // simultaneously correctly updates the shelf visibility and whether the tab
669 // indicators should be hidden.
670 waiter.reset(new FullscreenNotificationObserver());
671 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
672 browser_view->GetActiveWebContents(), true);
673 waiter->Wait();
674 waiter.reset(new FullscreenNotificationObserver());
675 chrome::ToggleFullscreenMode(browser());
676 waiter->Wait();
677
678 ASSERT_FALSE(controller->IsEnabled());
679 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
680 EXPECT_TRUE(controller->ShouldHideTabIndicators());
620 } 681 }
621 682
622 #endif // defined(OS_CHROMEOS) 683 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698