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

Side by Side Diff: chrome/browser/ui/views/immersive_mode_controller_browsertest.cc

Issue 11830008: ash/immersive mode: Hide the launcher when entering immersive mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move logic to RootWindowController Created 7 years, 11 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
« no previous file with comments | « chrome/browser/ui/views/immersive_mode_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/immersive_mode_controller.h" 5 #include "chrome/browser/ui/views/immersive_mode_controller.h"
6 6
7 #include "chrome/browser/ui/views/frame/browser_view.h" 7 #include "chrome/browser/ui/views/frame/browser_view.h"
8 #include "chrome/browser/ui/views/tabs/tab.h" 8 #include "chrome/browser/ui/views/tabs/tab.h"
9 #include "chrome/browser/ui/views/tabs/tab_strip.h" 9 #include "chrome/browser/ui/views/tabs/tab_strip.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "ui/compositor/layer_animator.h" 11 #include "ui/compositor/layer_animator.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 #include "ui/views/view.h" 13 #include "ui/views/view.h"
14 14
15 #if defined(USE_ASH)
16 #include "ash/root_window_controller.h"
17 #include "ash/shelf_types.h"
18 #include "ash/shell.h"
19 #include "ash/wm/shelf_layout_manager.h"
20 #endif
21
15 namespace { 22 namespace {
16 23
17 // Returns the bounds of |view| in widget coordinates. 24 // Returns the bounds of |view| in widget coordinates.
18 gfx::Rect GetRectInWidget(views::View* view) { 25 gfx::Rect GetRectInWidget(views::View* view) {
19 return view->ConvertRectToWidget(view->GetLocalBounds()); 26 return view->ConvertRectToWidget(view->GetLocalBounds());
20 } 27 }
21 28
22 } // namespace 29 } // namespace
23 30
24 typedef InProcessBrowserTest ImmersiveModeControllerTest; 31 typedef InProcessBrowserTest ImmersiveModeControllerTest;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 69
63 // Trigger a reveal keeps us in immersive mode, but top-of-window views 70 // Trigger a reveal keeps us in immersive mode, but top-of-window views
64 // become visible. 71 // become visible.
65 controller->StartRevealForTest(); 72 controller->StartRevealForTest();
66 EXPECT_TRUE(controller->enabled()); 73 EXPECT_TRUE(controller->enabled());
67 EXPECT_FALSE(controller->ShouldHideTopViews()); 74 EXPECT_FALSE(controller->ShouldHideTopViews());
68 EXPECT_TRUE(controller->IsRevealed()); 75 EXPECT_TRUE(controller->IsRevealed());
69 EXPECT_FALSE(browser_view->tabstrip()->IsImmersiveStyle()); 76 EXPECT_FALSE(browser_view->tabstrip()->IsImmersiveStyle());
70 EXPECT_TRUE(browser_view->IsTabStripVisible()); 77 EXPECT_TRUE(browser_view->IsTabStripVisible());
71 EXPECT_TRUE(browser_view->IsToolbarVisible()); 78 EXPECT_TRUE(browser_view->IsToolbarVisible());
79 // Shelf hide triggered by enabling immersive mode eventually changes the
80 // widget bounds and causes a Layout(). Force it to happen early for test.
81 browser_view->parent()->Layout();
72 // Content area is still immediately below the tab indicators. 82 // Content area is still immediately below the tab indicators.
73 EXPECT_EQ(GetRectInWidget(browser_view).y() + Tab::GetImmersiveHeight(), 83 EXPECT_EQ(GetRectInWidget(browser_view).y() + Tab::GetImmersiveHeight(),
74 GetRectInWidget(contents_view).y()); 84 GetRectInWidget(contents_view).y());
75 85
76 // Ending a reveal keeps us in immersive mode, but toolbar goes invisible. 86 // Ending a reveal keeps us in immersive mode, but toolbar goes invisible.
77 controller->CancelReveal(); 87 controller->CancelReveal();
78 EXPECT_TRUE(controller->enabled()); 88 EXPECT_TRUE(controller->enabled());
79 EXPECT_TRUE(controller->ShouldHideTopViews()); 89 EXPECT_TRUE(controller->ShouldHideTopViews());
80 EXPECT_FALSE(controller->IsRevealed()); 90 EXPECT_FALSE(controller->IsRevealed());
81 EXPECT_TRUE(browser_view->tabstrip()->IsImmersiveStyle()); 91 EXPECT_TRUE(browser_view->tabstrip()->IsImmersiveStyle());
(...skipping 24 matching lines...) Expand all
106 // When hiding the tab indicators, content is at the top of the browser view 116 // When hiding the tab indicators, content is at the top of the browser view
107 // both before and during reveal. 117 // both before and during reveal.
108 controller->SetEnabled(false); 118 controller->SetEnabled(false);
109 controller->SetHideTabIndicatorsForTest(true); 119 controller->SetHideTabIndicatorsForTest(true);
110 controller->SetEnabled(true); 120 controller->SetEnabled(true);
111 EXPECT_FALSE(browser_view->IsTabStripVisible()); 121 EXPECT_FALSE(browser_view->IsTabStripVisible());
112 EXPECT_EQ(GetRectInWidget(browser_view).y(), 122 EXPECT_EQ(GetRectInWidget(browser_view).y(),
113 GetRectInWidget(contents_view).y()); 123 GetRectInWidget(contents_view).y());
114 controller->StartRevealForTest(); 124 controller->StartRevealForTest();
115 EXPECT_TRUE(browser_view->IsTabStripVisible()); 125 EXPECT_TRUE(browser_view->IsTabStripVisible());
126 // Shelf hide triggered by enabling immersive mode eventually changes the
127 // widget bounds and causes a Layout(). Force it to happen early for test.
128 browser_view->parent()->Layout();
116 EXPECT_EQ(GetRectInWidget(browser_view).y(), 129 EXPECT_EQ(GetRectInWidget(browser_view).y(),
117 GetRectInWidget(contents_view).y()); 130 GetRectInWidget(contents_view).y());
118 controller->SetEnabled(false); 131 controller->SetEnabled(false);
119 controller->SetHideTabIndicatorsForTest(false); 132 controller->SetHideTabIndicatorsForTest(false);
120 133
121 // Reveal ends when the mouse moves out of the reveal view. 134 // Reveal ends when the mouse moves out of the reveal view.
122 controller->SetEnabled(true); 135 controller->SetEnabled(true);
123 controller->StartRevealForTest(); 136 controller->StartRevealForTest();
124 controller->OnRevealViewLostMouseForTest(); 137 controller->OnRevealViewLostMouseForTest();
125 EXPECT_FALSE(controller->IsRevealed()); 138 EXPECT_FALSE(controller->IsRevealed());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 EXPECT_FALSE(browser_view->tabstrip()->IsImmersiveStyle()); 173 EXPECT_FALSE(browser_view->tabstrip()->IsImmersiveStyle());
161 EXPECT_TRUE(browser_view->IsTabStripVisible()); 174 EXPECT_TRUE(browser_view->IsTabStripVisible());
162 EXPECT_TRUE(browser_view->IsToolbarVisible()); 175 EXPECT_TRUE(browser_view->IsToolbarVisible());
163 #endif // defined(USE_AURA) && !defined(OS_WIN) 176 #endif // defined(USE_AURA) && !defined(OS_WIN)
164 177
165 // Don't crash if we exit the test during a reveal. 178 // Don't crash if we exit the test during a reveal.
166 browser_view->GetWidget()->Maximize(); 179 browser_view->GetWidget()->Maximize();
167 controller->SetEnabled(true); 180 controller->SetEnabled(true);
168 controller->StartRevealForTest(); 181 controller->StartRevealForTest();
169 } 182 }
183
184 #if defined(USE_ASH)
185 // Test shelf auto-hide toggling behavior.
186 IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerTest, ImmersiveShelf) {
187 ui::LayerAnimator::set_disable_animations_for_test(true);
188
189 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
190 ImmersiveModeController* immersive_controller =
191 browser_view->immersive_mode_controller();
192 browser_view->GetWidget()->Maximize();
193
194 // Shelf is visible when the test starts.
195 ash::internal::ShelfLayoutManager* shelf =
196 ash::Shell::GetPrimaryRootWindowController()->shelf();
197 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
198
199 // Turning immersive mode on sets the shelf to auto-hide.
200 immersive_controller->SetEnabled(true);
201 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
202
203 // Disabling immersive mode puts it back.
204 immersive_controller->SetEnabled(false);
205 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
206
207 // The user could toggle the launcher behavior.
208 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
209 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
210
211 // Enabling immersive mode keeps auto-hide.
212 immersive_controller->SetEnabled(true);
213 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
214
215 // Disabling immersive mode maintains the user's auto-hide selection.
216 immersive_controller->SetEnabled(false);
217 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
218 }
219 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/immersive_mode_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698