| 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 "ash/wm/immersive_fullscreen_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_ash.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 13 #include "chrome/app/chrome_command_ids.h" | 14 #include "ui/aura/client/aura_constants.h" |
| 14 #include "chrome/browser/ui/browser_commands.h" | |
| 15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | |
| 16 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" | |
| 17 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 18 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" | |
| 19 #include "chrome/browser/ui/views/frame/top_container_view.h" | |
| 20 #include "chrome/browser/ui/views/tabs/tab_strip.h" | |
| 21 #include "chrome/browser/ui/views/toolbar_view.h" | |
| 22 #include "ui/aura/client/cursor_client.h" | 15 #include "ui/aura/client/cursor_client.h" |
| 23 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
| 24 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
| 25 #include "ui/aura/test/event_generator.h" | 18 #include "ui/aura/test/event_generator.h" |
| 26 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 27 #include "ui/gfx/animation/slide_animation.h" | 20 #include "ui/gfx/animation/slide_animation.h" |
| 28 #include "ui/views/bubble/bubble_delegate.h" | 21 #include "ui/views/bubble/bubble_delegate.h" |
| 29 #include "ui/views/controls/webview/webview.h" | 22 #include "ui/views/view.h" |
| 23 #include "ui/views/widget/widget.h" |
| 30 | 24 |
| 31 // For now, immersive fullscreen is Chrome OS only. | 25 // For now, immersive fullscreen is Chrome OS only. |
| 32 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| 33 | 27 |
| 34 ///////////////////////////////////////////////////////////////////////////// | 28 namespace ash { |
| 35 | 29 |
| 36 class MockImmersiveModeControllerDelegate | 30 namespace { |
| 37 : public ImmersiveModeController::Delegate { | 31 |
| 32 class MockImmersiveFullscreenControllerDelegate |
| 33 : public ImmersiveFullscreenController::Delegate { |
| 38 public: | 34 public: |
| 39 MockImmersiveModeControllerDelegate() : immersive_style_(false) {} | 35 MockImmersiveFullscreenControllerDelegate(views::View* top_container_view) |
| 40 virtual ~MockImmersiveModeControllerDelegate() {} | 36 : top_container_view_(top_container_view), |
| 37 enabled_(false), |
| 38 visible_fraction_(1) { |
| 39 } |
| 40 virtual ~MockImmersiveFullscreenControllerDelegate() {} |
| 41 | 41 |
| 42 bool immersive_style() const { return immersive_style_; } | 42 // ImmersiveFullscreenController::Delegate overrides: |
| 43 virtual void OnImmersiveRevealStarted() OVERRIDE { |
| 44 enabled_ = true; |
| 45 visible_fraction_ = 0; |
| 46 } |
| 47 virtual void OnImmersiveRevealEnded() OVERRIDE { |
| 48 visible_fraction_ = 0; |
| 49 } |
| 50 virtual void OnImmersiveFullscreenExited() OVERRIDE { |
| 51 enabled_ = false; |
| 52 visible_fraction_ = 0; |
| 53 } |
| 54 virtual void SetVisibility(double visible_fraction) OVERRIDE { |
| 55 visible_fraction_ = visible_fraction; |
| 56 } |
| 57 virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() OVERRIDE { |
| 58 std::vector<gfx::Rect> bounds_in_screen; |
| 59 bounds_in_screen.push_back(top_container_view_->GetBoundsInScreen()); |
| 60 return bounds_in_screen; |
| 61 } |
| 43 | 62 |
| 44 // ImmersiveModeController::Delegate overrides: | 63 bool is_enabled() const { |
| 45 virtual FullscreenController* GetFullscreenController() OVERRIDE { | 64 return enabled_; |
| 46 return NULL; | |
| 47 } | 65 } |
| 48 virtual void FullscreenStateChanged() OVERRIDE {} | 66 |
| 49 virtual void SetImmersiveStyle(bool immersive) OVERRIDE { | 67 double visible_fraction() const { |
| 50 immersive_style_ = immersive; | 68 return visible_fraction_; |
| 51 } | |
| 52 virtual content::WebContents* GetWebContents() OVERRIDE { | |
| 53 return NULL; | |
| 54 } | 69 } |
| 55 | 70 |
| 56 private: | 71 private: |
| 57 bool immersive_style_; | 72 views::View* top_container_view_; |
| 73 bool enabled_; |
| 74 double visible_fraction_; |
| 58 | 75 |
| 59 DISALLOW_COPY_AND_ASSIGN(MockImmersiveModeControllerDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(MockImmersiveFullscreenControllerDelegate); |
| 60 }; | 77 }; |
| 61 | 78 |
| 79 } // namespace |
| 80 |
| 62 ///////////////////////////////////////////////////////////////////////////// | 81 ///////////////////////////////////////////////////////////////////////////// |
| 63 | 82 |
| 64 class ImmersiveModeControllerAshTest : public ash::test::AshTestBase { | 83 class ImmersiveFullscreenControllerTest : public ash::test::AshTestBase { |
| 65 public: | 84 public: |
| 66 enum Modality { | 85 enum Modality { |
| 67 MODALITY_MOUSE, | 86 MODALITY_MOUSE, |
| 68 MODALITY_TOUCH, | 87 MODALITY_TOUCH, |
| 69 MODALITY_GESTURE | 88 MODALITY_GESTURE |
| 70 }; | 89 }; |
| 71 | 90 |
| 72 ImmersiveModeControllerAshTest() : widget_(NULL), top_container_(NULL) {} | 91 ImmersiveFullscreenControllerTest() : widget_(NULL), top_container_(NULL) {} |
| 73 virtual ~ImmersiveModeControllerAshTest() {} | 92 virtual ~ImmersiveFullscreenControllerTest() {} |
| 74 | 93 |
| 75 ImmersiveModeControllerAsh* controller() { return controller_.get(); } | 94 ImmersiveFullscreenController* controller() { |
| 76 views::View* top_container() { return top_container_; } | 95 return controller_.get(); |
| 77 MockImmersiveModeControllerDelegate* delegate() { return delegate_.get(); } | 96 } |
| 97 |
| 98 views::View* top_container() { |
| 99 return top_container_; |
| 100 } |
| 101 |
| 102 aura::Window* window() { |
| 103 return widget_->GetNativeWindow(); |
| 104 } |
| 105 |
| 106 MockImmersiveFullscreenControllerDelegate* delegate() { |
| 107 return delegate_.get(); |
| 108 } |
| 78 | 109 |
| 79 // Access to private data from the controller. | 110 // Access to private data from the controller. |
| 80 bool top_edge_hover_timer_running() const { | 111 bool top_edge_hover_timer_running() const { |
| 81 return controller_->top_edge_hover_timer_.IsRunning(); | 112 return controller_->top_edge_hover_timer_.IsRunning(); |
| 82 } | 113 } |
| 83 int mouse_x_when_hit_top() const { | 114 int mouse_x_when_hit_top() const { |
| 84 return controller_->mouse_x_when_hit_top_in_screen_; | 115 return controller_->mouse_x_when_hit_top_in_screen_; |
| 85 } | 116 } |
| 86 | 117 |
| 87 // ash::test::AshTestBase overrides: | 118 // ash::test::AshTestBase overrides: |
| 88 virtual void SetUp() OVERRIDE { | 119 virtual void SetUp() OVERRIDE { |
| 89 ash::test::AshTestBase::SetUp(); | 120 ash::test::AshTestBase::SetUp(); |
| 90 | 121 |
| 91 controller_.reset(new ImmersiveModeControllerAsh); | |
| 92 delegate_.reset(new MockImmersiveModeControllerDelegate); | |
| 93 | |
| 94 widget_ = new views::Widget(); | 122 widget_ = new views::Widget(); |
| 95 views::Widget::InitParams params; | 123 views::Widget::InitParams params; |
| 96 params.context = CurrentContext(); | 124 params.context = CurrentContext(); |
| 97 params.bounds = gfx::Rect(0, 0, 500, 500); | |
| 98 widget_->Init(params); | 125 widget_->Init(params); |
| 99 widget_->Show(); | 126 widget_->Show(); |
| 100 | 127 |
| 128 window()->SetProperty(aura::client::kShowStateKey, |
| 129 ui::SHOW_STATE_FULLSCREEN); |
| 130 |
| 101 top_container_ = new views::View(); | 131 top_container_ = new views::View(); |
| 102 top_container_->SetBounds(0, 0, 500, 100); | 132 top_container_->SetBounds( |
| 133 0, 0, widget_->GetWindowBoundsInScreen().width(), 100); |
| 103 top_container_->set_focusable(true); | 134 top_container_->set_focusable(true); |
| 104 | |
| 105 widget_->GetContentsView()->AddChildView(top_container_); | 135 widget_->GetContentsView()->AddChildView(top_container_); |
| 106 | 136 |
| 137 delegate_.reset( |
| 138 new MockImmersiveFullscreenControllerDelegate(top_container_)); |
| 139 controller_.reset(new ImmersiveFullscreenController); |
| 107 controller_->Init(delegate_.get(), widget_, top_container_); | 140 controller_->Init(delegate_.get(), widget_, top_container_); |
| 108 SetAnimationsDisabled(true); | 141 SetAnimationsDisabled(true); |
| 109 | 142 |
| 110 // The mouse is moved so that it is not over |top_container_| by | 143 // The mouse is moved so that it is not over |top_container_| by |
| 111 // AshTestBase. | 144 // AshTestBase. |
| 112 } | 145 } |
| 113 | 146 |
| 114 // Enable or disable the immersive mode controller's animations. When the | 147 // Enable or disable the ImmersiveFullscreenController's animations. When the |
| 115 // immersive mode controller's animations are disabled, some behavior is | 148 // ImmersiveFullscreenController's animations are disabled, some behavior is |
| 116 // slightly different. In particular, the behavior is different when there | 149 // slightly different. In particular, the behavior is different when there |
| 117 // is a transfer in which lock keeps the top-of-window views revealed (eg | 150 // is a transfer in which lock keeps the top-of-window views revealed (eg |
| 118 // bubble keeps top-of-window views revealed -> mouse keeps top-of-window | 151 // bubble keeps top-of-window views revealed -> mouse keeps top-of-window |
| 119 // views revealed). It is necessary to temparily enable the immersive | 152 // views revealed). It is necessary to temporarily enable the |
| 120 // controller's animations to get the correct behavior in tests. | 153 // ImmersiveFullscreenController's animations to get the correct behavior in |
| 154 // tests. |
| 121 void SetAnimationsDisabled(bool disabled) { | 155 void SetAnimationsDisabled(bool disabled) { |
| 122 controller_->animations_disabled_for_test_ = disabled; | 156 controller_->animations_disabled_for_test_ = disabled; |
| 123 // Force any in progress animations to finish. | 157 // Force any in progress animations to finish. |
| 124 if (disabled) | 158 if (disabled) |
| 125 controller_->animation_->End(); | 159 controller_->animation_->End(); |
| 126 } | 160 } |
| 127 | 161 |
| 128 // Attempt to reveal the top-of-window views via |modality|. | 162 // Attempt to reveal the top-of-window views via |modality|. |
| 129 // The top-of-window views can only be revealed via mouse hover or a gesture. | 163 // The top-of-window views can only be revealed via mouse hover or a gesture. |
| 130 void AttemptReveal(Modality modality) { | 164 void AttemptReveal(Modality modality) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 views::View::ConvertPointToScreen(top_container_, &screen_position); | 211 views::View::ConvertPointToScreen(top_container_, &screen_position); |
| 178 | 212 |
| 179 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 213 aura::test::EventGenerator& event_generator(GetEventGenerator()); |
| 180 event_generator.MoveTouch(event_position); | 214 event_generator.MoveTouch(event_position); |
| 181 event_generator.PressTouch(); | 215 event_generator.PressTouch(); |
| 182 event_generator.ReleaseTouch(); | 216 event_generator.ReleaseTouch(); |
| 183 break; | 217 break; |
| 184 } | 218 } |
| 185 case MODALITY_GESTURE: { | 219 case MODALITY_GESTURE: { |
| 186 aura::client::GetCursorClient(CurrentContext())->DisableMouseEvents(); | 220 aura::client::GetCursorClient(CurrentContext())->DisableMouseEvents(); |
| 187 ImmersiveModeControllerAsh::SwipeType swipe_type = revealed ? | 221 ImmersiveFullscreenController::SwipeType swipe_type = revealed ? |
| 188 ImmersiveModeControllerAsh::SWIPE_OPEN : | 222 ImmersiveFullscreenController::SWIPE_OPEN : |
| 189 ImmersiveModeControllerAsh::SWIPE_CLOSE; | 223 ImmersiveFullscreenController::SWIPE_CLOSE; |
| 190 controller_->UpdateRevealedLocksForSwipe(swipe_type); | 224 controller_->UpdateRevealedLocksForSwipe(swipe_type); |
| 191 break; | 225 break; |
| 192 } | 226 } |
| 193 } | 227 } |
| 194 } | 228 } |
| 195 | 229 |
| 196 scoped_ptr<ImmersiveModeControllerAsh> controller_; | 230 scoped_ptr<ImmersiveFullscreenController> controller_; |
| 197 scoped_ptr<MockImmersiveModeControllerDelegate> delegate_; | 231 scoped_ptr<MockImmersiveFullscreenControllerDelegate> delegate_; |
| 198 views::Widget* widget_; // Owned by the native widget. | 232 views::Widget* widget_; // Owned by the native widget. |
| 199 views::View* top_container_; // Owned by |root_view_|. | 233 views::View* top_container_; // Owned by |root_view_|. |
| 200 | 234 |
| 201 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest); | 235 DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenControllerTest); |
| 202 }; | 236 }; |
| 203 | 237 |
| 204 // Test of initial state and basic functionality. | 238 // Test the initial state and that the delegate gets notified of the |
| 205 TEST_F(ImmersiveModeControllerAshTest, ImmersiveModeControllerAsh) { | 239 // top-of-window views getting hidden and revealed. |
| 240 TEST_F(ImmersiveFullscreenControllerTest, Delegate) { |
| 206 // Initial state. | 241 // Initial state. |
| 207 EXPECT_FALSE(controller()->IsEnabled()); | 242 EXPECT_FALSE(controller()->IsEnabled()); |
| 208 EXPECT_FALSE(controller()->ShouldHideTopViews()); | |
| 209 EXPECT_FALSE(controller()->IsRevealed()); | 243 EXPECT_FALSE(controller()->IsRevealed()); |
| 210 EXPECT_FALSE(delegate()->immersive_style()); | 244 EXPECT_FALSE(delegate()->is_enabled()); |
| 211 | 245 |
| 212 // Enabling hides the top views. | 246 // Enabling initially hides the top views. |
| 213 controller()->SetEnabled(true); | 247 controller()->SetEnabled(true); |
| 214 EXPECT_TRUE(controller()->IsEnabled()); | 248 EXPECT_TRUE(controller()->IsEnabled()); |
| 215 EXPECT_FALSE(controller()->IsRevealed()); | 249 EXPECT_FALSE(controller()->IsRevealed()); |
| 216 EXPECT_TRUE(controller()->ShouldHideTopViews()); | 250 EXPECT_TRUE(delegate()->is_enabled()); |
| 217 EXPECT_FALSE(controller()->ShouldHideTabIndicators()); | 251 EXPECT_EQ(0, delegate()->visible_fraction()); |
| 218 EXPECT_TRUE(delegate()->immersive_style()); | |
| 219 | 252 |
| 220 // Revealing shows the top views. | 253 // Revealing shows the top views. |
| 221 AttemptReveal(MODALITY_MOUSE); | 254 AttemptReveal(MODALITY_MOUSE); |
| 255 EXPECT_TRUE(controller()->IsEnabled()); |
| 222 EXPECT_TRUE(controller()->IsRevealed()); | 256 EXPECT_TRUE(controller()->IsRevealed()); |
| 223 EXPECT_FALSE(controller()->ShouldHideTopViews()); | 257 EXPECT_TRUE(delegate()->is_enabled()); |
| 224 // Tabs are painting in the normal style during a reveal. | 258 EXPECT_EQ(1, delegate()->visible_fraction()); |
| 225 EXPECT_FALSE(delegate()->immersive_style()); | |
| 226 | 259 |
| 227 // Disabling immersive fullscreen keeps the top views shown. | 260 // Disabling ends the immersive reveal. |
| 228 controller()->SetEnabled(false); | 261 controller()->SetEnabled(false); |
| 229 EXPECT_FALSE(controller()->IsEnabled()); | 262 EXPECT_FALSE(controller()->IsEnabled()); |
| 230 EXPECT_FALSE(controller()->IsRevealed()); | 263 EXPECT_FALSE(controller()->IsRevealed()); |
| 231 EXPECT_FALSE(controller()->ShouldHideTopViews()); | 264 EXPECT_FALSE(delegate()->is_enabled()); |
| 232 EXPECT_FALSE(delegate()->immersive_style()); | |
| 233 | |
| 234 // Test disabling immersive fullscreen when the top views are hidden. | |
| 235 controller()->SetEnabled(true); | |
| 236 EXPECT_TRUE(controller()->IsEnabled()); | |
| 237 EXPECT_FALSE(controller()->IsRevealed()); | |
| 238 EXPECT_TRUE(controller()->ShouldHideTopViews()); | |
| 239 EXPECT_TRUE(delegate()->immersive_style()); | |
| 240 | |
| 241 controller()->SetEnabled(false); | |
| 242 EXPECT_FALSE(controller()->IsEnabled()); | |
| 243 EXPECT_FALSE(controller()->IsRevealed()); | |
| 244 EXPECT_FALSE(controller()->ShouldHideTopViews()); | |
| 245 EXPECT_FALSE(delegate()->immersive_style()); | |
| 246 } | 265 } |
| 247 | 266 |
| 248 // GetRevealedLock() specific tests. | 267 // GetRevealedLock() specific tests. |
| 249 TEST_F(ImmersiveModeControllerAshTest, RevealedLock) { | 268 TEST_F(ImmersiveFullscreenControllerTest, RevealedLock) { |
| 250 scoped_ptr<ImmersiveRevealedLock> lock1; | 269 scoped_ptr<ImmersiveRevealedLock> lock1; |
| 251 scoped_ptr<ImmersiveRevealedLock> lock2; | 270 scoped_ptr<ImmersiveRevealedLock> lock2; |
| 252 | 271 |
| 253 // Immersive fullscreen is not on by default. | 272 // Immersive fullscreen is not on by default. |
| 254 EXPECT_FALSE(controller()->IsEnabled()); | 273 EXPECT_FALSE(controller()->IsEnabled()); |
| 255 | 274 |
| 256 // 1) Test acquiring and releasing a revealed state lock while immersive | 275 // 1) Test acquiring and releasing a revealed state lock while immersive |
| 257 // fullscreen is disabled. Acquiring or releasing the lock should have no | 276 // fullscreen is disabled. Acquiring or releasing the lock should have no |
| 258 // effect till immersive fullscreen is enabled. | 277 // effect till immersive fullscreen is enabled. |
| 259 lock1.reset(controller()->GetRevealedLock( | 278 lock1.reset(controller()->GetRevealedLock( |
| 260 ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO)); | 279 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 261 EXPECT_FALSE(controller()->IsEnabled()); | 280 EXPECT_FALSE(controller()->IsEnabled()); |
| 262 EXPECT_FALSE(controller()->IsRevealed()); | 281 EXPECT_FALSE(controller()->IsRevealed()); |
| 263 | 282 |
| 264 // Immersive fullscreen should start in the revealed state due to the lock. | 283 // Immersive fullscreen should start in the revealed state due to the lock. |
| 265 controller()->SetEnabled(true); | 284 controller()->SetEnabled(true); |
| 266 EXPECT_TRUE(controller()->IsEnabled()); | 285 EXPECT_TRUE(controller()->IsEnabled()); |
| 267 EXPECT_TRUE(controller()->IsRevealed()); | 286 EXPECT_TRUE(controller()->IsRevealed()); |
| 268 | 287 |
| 269 controller()->SetEnabled(false); | 288 controller()->SetEnabled(false); |
| 270 EXPECT_FALSE(controller()->IsEnabled()); | 289 EXPECT_FALSE(controller()->IsEnabled()); |
| 271 EXPECT_FALSE(controller()->IsRevealed()); | 290 EXPECT_FALSE(controller()->IsRevealed()); |
| 272 | 291 |
| 273 lock1.reset(); | 292 lock1.reset(); |
| 274 EXPECT_FALSE(controller()->IsEnabled()); | 293 EXPECT_FALSE(controller()->IsEnabled()); |
| 275 EXPECT_FALSE(controller()->IsRevealed()); | 294 EXPECT_FALSE(controller()->IsRevealed()); |
| 276 | 295 |
| 277 // Immersive fullscreen should start in the closed state because the lock is | 296 // Immersive fullscreen should start in the closed state because the lock is |
| 278 // no longer held. | 297 // no longer held. |
| 279 controller()->SetEnabled(true); | 298 controller()->SetEnabled(true); |
| 280 EXPECT_TRUE(controller()->IsEnabled()); | 299 EXPECT_TRUE(controller()->IsEnabled()); |
| 281 EXPECT_FALSE(controller()->IsRevealed()); | 300 EXPECT_FALSE(controller()->IsRevealed()); |
| 282 | 301 |
| 283 // 2) Test that acquiring a lock reveals the top-of-window views if they are | 302 // 2) Test that acquiring a lock reveals the top-of-window views if they are |
| 284 // hidden. | 303 // hidden. |
| 285 lock1.reset(controller()->GetRevealedLock( | 304 lock1.reset(controller()->GetRevealedLock( |
| 286 ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO)); | 305 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 287 EXPECT_TRUE(controller()->IsRevealed()); | 306 EXPECT_TRUE(controller()->IsRevealed()); |
| 288 | 307 |
| 289 // 3) Test that the top-of-window views are only hidden when all of the locks | 308 // 3) Test that the top-of-window views are only hidden when all of the locks |
| 290 // are released. | 309 // are released. |
| 291 lock2.reset(controller()->GetRevealedLock( | 310 lock2.reset(controller()->GetRevealedLock( |
| 292 ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO)); | 311 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 293 lock1.reset(); | 312 lock1.reset(); |
| 294 EXPECT_TRUE(controller()->IsRevealed()); | 313 EXPECT_TRUE(controller()->IsRevealed()); |
| 295 | 314 |
| 296 lock2.reset(); | 315 lock2.reset(); |
| 297 EXPECT_FALSE(controller()->IsRevealed()); | 316 EXPECT_FALSE(controller()->IsRevealed()); |
| 298 } | 317 } |
| 299 | 318 |
| 300 // Test mouse event processing for top-of-screen reveal triggering. | 319 // Test mouse event processing for top-of-screen reveal triggering. |
| 301 TEST_F(ImmersiveModeControllerAshTest, OnMouseEvent) { | 320 TEST_F(ImmersiveFullscreenControllerTest, OnMouseEvent) { |
| 321 // Set up initial state. |
| 322 UpdateDisplay("800x600,800x600"); |
| 323 ash::DisplayLayout display_layout(ash::DisplayLayout::RIGHT, 0); |
| 324 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 325 display_layout); |
| 326 |
| 302 // Set up initial state. | 327 // Set up initial state. |
| 303 controller()->SetEnabled(true); | 328 controller()->SetEnabled(true); |
| 304 ASSERT_TRUE(controller()->IsEnabled()); | 329 ASSERT_TRUE(controller()->IsEnabled()); |
| 305 ASSERT_FALSE(controller()->IsRevealed()); | 330 ASSERT_FALSE(controller()->IsRevealed()); |
| 306 | 331 |
| 307 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 332 aura::test::EventGenerator& event_generator(GetEventGenerator()); |
| 308 | 333 |
| 309 gfx::Rect top_container_bounds_in_screen = | 334 gfx::Rect top_container_bounds_in_screen = |
| 310 top_container()->GetBoundsInScreen(); | 335 top_container()->GetBoundsInScreen(); |
| 311 // A position along the top edge of TopContainerView in screen coordinates. | 336 // A position along the top edge of TopContainerView in screen coordinates. |
| 312 gfx::Point top_edge_pos(top_container_bounds_in_screen.x() + 100, | 337 gfx::Point top_edge_pos(top_container_bounds_in_screen.x() + 100, |
| 313 top_container_bounds_in_screen.y()); | 338 top_container_bounds_in_screen.y()); |
| 314 | 339 |
| 315 // Mouse wheel event does nothing. | 340 // Mouse wheel event does nothing. |
| 316 ui::MouseEvent wheel( | 341 ui::MouseEvent wheel( |
| 317 ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, ui::EF_NONE); | 342 ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, ui::EF_NONE); |
| 318 event_generator.Dispatch(&wheel); | 343 event_generator.Dispatch(&wheel); |
| 319 EXPECT_FALSE(top_edge_hover_timer_running()); | 344 EXPECT_FALSE(top_edge_hover_timer_running()); |
| 320 | 345 |
| 321 // Move to top edge of screen starts hover timer running. We cannot use | 346 // Move to top edge of screen starts hover timer running. We cannot use |
| 322 // MoveMouse() because MoveMouse() stops the timer if it started running. | 347 // MoveMouse() because MoveMouse() stops the timer if it started running. |
| 323 event_generator.MoveMouseTo(top_edge_pos); | 348 event_generator.MoveMouseTo(top_edge_pos); |
| 324 EXPECT_TRUE(top_edge_hover_timer_running()); | 349 EXPECT_TRUE(top_edge_hover_timer_running()); |
| 325 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); | 350 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); |
| 326 | 351 |
| 327 // Moving |ImmersiveModeControllerAsh::kMouseRevealBoundsHeight| down from | 352 // Moving |ImmersiveFullscreenControllerTest::kMouseRevealBoundsHeight| down |
| 328 // the top edge stops it. | 353 // from the top edge stops it. |
| 329 event_generator.MoveMouseBy(0, 3); | 354 event_generator.MoveMouseBy(0, 3); |
| 330 EXPECT_FALSE(top_edge_hover_timer_running()); | 355 EXPECT_FALSE(top_edge_hover_timer_running()); |
| 331 | 356 |
| 332 // Moving back to the top starts the timer again. | 357 // Moving back to the top starts the timer again. |
| 333 event_generator.MoveMouseTo(top_edge_pos); | 358 event_generator.MoveMouseTo(top_edge_pos); |
| 334 EXPECT_TRUE(top_edge_hover_timer_running()); | 359 EXPECT_TRUE(top_edge_hover_timer_running()); |
| 335 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); | 360 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); |
| 336 | 361 |
| 337 // Slight move to the right keeps the timer running for the same hit point. | 362 // Slight move to the right keeps the timer running for the same hit point. |
| 338 event_generator.MoveMouseBy(1, 0); | 363 event_generator.MoveMouseBy(1, 0); |
| 339 EXPECT_TRUE(top_edge_hover_timer_running()); | 364 EXPECT_TRUE(top_edge_hover_timer_running()); |
| 340 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); | 365 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); |
| 341 | 366 |
| 342 // Moving back to the left also keeps the timer running. | 367 // Moving back to the left also keeps the timer running. |
| 343 event_generator.MoveMouseBy(-1, 0); | 368 event_generator.MoveMouseBy(-1, 0); |
| 344 EXPECT_TRUE(top_edge_hover_timer_running()); | 369 EXPECT_TRUE(top_edge_hover_timer_running()); |
| 345 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); | 370 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); |
| 346 | 371 |
| 347 // Large move right restarts the timer (so it is still running) and considers | 372 // Large move right restarts the timer (so it is still running) and considers |
| 348 // this a new hit at the top. | 373 // this a new hit at the top. |
| 349 event_generator.MoveMouseTo(top_edge_pos.x() + 100, top_edge_pos.y()); | 374 event_generator.MoveMouseTo(top_edge_pos.x() + 100, top_edge_pos.y()); |
| 350 EXPECT_TRUE(top_edge_hover_timer_running()); | 375 EXPECT_TRUE(top_edge_hover_timer_running()); |
| 351 EXPECT_EQ(top_edge_pos.x() + 100, mouse_x_when_hit_top()); | 376 EXPECT_EQ(top_edge_pos.x() + 100, mouse_x_when_hit_top()); |
| 352 | 377 |
| 353 // Moving off the top edge horizontally stops the timer. | 378 // Moving off the top edge horizontally stops the timer. |
| 354 EXPECT_GT(CurrentContext()->bounds().width(), top_container()->width()); | 379 event_generator.MoveMouseTo(top_container_bounds_in_screen.right() + 1, |
| 355 event_generator.MoveMouseTo(top_container_bounds_in_screen.right(), | |
| 356 top_container_bounds_in_screen.y()); | 380 top_container_bounds_in_screen.y()); |
| 357 EXPECT_FALSE(top_edge_hover_timer_running()); | 381 EXPECT_FALSE(top_edge_hover_timer_running()); |
| 358 | 382 |
| 359 // Once revealed, a move just a little below the top container doesn't end a | 383 // Once revealed, a move just a little below the top container doesn't end a |
| 360 // reveal. | 384 // reveal. |
| 361 AttemptReveal(MODALITY_MOUSE); | 385 AttemptReveal(MODALITY_MOUSE); |
| 362 event_generator.MoveMouseTo(top_container_bounds_in_screen.x(), | 386 event_generator.MoveMouseTo(top_container_bounds_in_screen.x(), |
| 363 top_container_bounds_in_screen.bottom() + 1); | 387 top_container_bounds_in_screen.bottom() + 1); |
| 364 EXPECT_TRUE(controller()->IsRevealed()); | 388 EXPECT_TRUE(controller()->IsRevealed()); |
| 365 | 389 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 392 EXPECT_TRUE(controller()->IsRevealed()); | 416 EXPECT_TRUE(controller()->IsRevealed()); |
| 393 | 417 |
| 394 // Releasing capture should end the reveal. | 418 // Releasing capture should end the reveal. |
| 395 widget->ReleaseCapture(); | 419 widget->ReleaseCapture(); |
| 396 EXPECT_FALSE(controller()->IsRevealed()); | 420 EXPECT_FALSE(controller()->IsRevealed()); |
| 397 } | 421 } |
| 398 | 422 |
| 399 // Test mouse event processing for top-of-screen reveal triggering when the user | 423 // Test mouse event processing for top-of-screen reveal triggering when the user |
| 400 // has a vertical display layout (primary display above/below secondary display) | 424 // has a vertical display layout (primary display above/below secondary display) |
| 401 // and the immersive fullscreen window is on the bottom display. | 425 // and the immersive fullscreen window is on the bottom display. |
| 402 TEST_F(ImmersiveModeControllerAshTest, MouseEventsVerticalDisplayLayout) { | 426 TEST_F(ImmersiveFullscreenControllerTest, MouseEventsVerticalDisplayLayout) { |
| 403 if (!SupportsMultipleDisplays()) | 427 if (!SupportsMultipleDisplays()) |
| 404 return; | 428 return; |
| 405 | 429 |
| 406 // Set up initial state. | 430 // Set up initial state. |
| 407 UpdateDisplay("800x600,800x600"); | 431 UpdateDisplay("800x600,800x600"); |
| 408 ash::DisplayLayout display_layout(ash::DisplayLayout::TOP, 0); | 432 ash::DisplayLayout display_layout(ash::DisplayLayout::TOP, 0); |
| 409 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 433 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 410 display_layout); | 434 display_layout); |
| 411 | 435 |
| 412 controller()->SetEnabled(true); | 436 controller()->SetEnabled(true); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 // around in the bottom region of the secondary display. | 490 // around in the bottom region of the secondary display. |
| 467 event_generator.MoveMouseTo(x + 10, y_top_edge - 3); | 491 event_generator.MoveMouseTo(x + 10, y_top_edge - 3); |
| 468 EXPECT_TRUE(controller()->IsRevealed()); | 492 EXPECT_TRUE(controller()->IsRevealed()); |
| 469 | 493 |
| 470 // The top-of-window views should hide if the user moves the mouse away from | 494 // The top-of-window views should hide if the user moves the mouse away from |
| 471 // the bottom region of the secondary display. | 495 // the bottom region of the secondary display. |
| 472 event_generator.MoveMouseTo(x, y_top_edge - 20); | 496 event_generator.MoveMouseTo(x, y_top_edge - 20); |
| 473 EXPECT_FALSE(controller()->IsRevealed()); | 497 EXPECT_FALSE(controller()->IsRevealed()); |
| 474 } | 498 } |
| 475 | 499 |
| 476 // Test that hovering the mouse over the find bar does not end a reveal. | |
| 477 TEST_F(ImmersiveModeControllerAshTest, FindBar) { | |
| 478 // Set up initial state. | |
| 479 controller()->SetEnabled(true); | |
| 480 ASSERT_TRUE(controller()->IsEnabled()); | |
| 481 ASSERT_FALSE(controller()->IsRevealed()); | |
| 482 | |
| 483 // Compute the find bar bounds relative to TopContainerView. The find | |
| 484 // bar is aligned with the bottom right of the TopContainerView. | |
| 485 gfx::Rect find_bar_bounds(top_container()->bounds().right() - 100, | |
| 486 top_container()->bounds().bottom(), | |
| 487 100, | |
| 488 50); | |
| 489 | |
| 490 gfx::Point find_bar_position_in_screen = find_bar_bounds.origin(); | |
| 491 views::View::ConvertPointToScreen(top_container(), | |
| 492 &find_bar_position_in_screen); | |
| 493 gfx::Rect find_bar_bounds_in_screen(find_bar_position_in_screen, | |
| 494 find_bar_bounds.size()); | |
| 495 controller()->OnFindBarVisibleBoundsChanged(find_bar_bounds_in_screen); | |
| 496 | |
| 497 // Moving the mouse over the find bar does not end the reveal. | |
| 498 gfx::Point over_find_bar(find_bar_bounds.x() + 25, find_bar_bounds.y() + 25); | |
| 499 AttemptReveal(MODALITY_MOUSE); | |
| 500 EXPECT_TRUE(controller()->IsRevealed()); | |
| 501 MoveMouse(over_find_bar.x(), over_find_bar.y()); | |
| 502 EXPECT_TRUE(controller()->IsRevealed()); | |
| 503 | |
| 504 // Moving the mouse off of the find bar horizontally ends the reveal. | |
| 505 MoveMouse(find_bar_bounds.x() - 25, find_bar_bounds.y() + 25); | |
| 506 EXPECT_FALSE(controller()->IsRevealed()); | |
| 507 | |
| 508 // Moving the mouse off of the find bar vertically ends the reveal. | |
| 509 AttemptReveal(MODALITY_MOUSE); | |
| 510 EXPECT_TRUE(controller()->IsRevealed()); | |
| 511 MoveMouse(find_bar_bounds.x() + 25, find_bar_bounds.bottom() + 25); | |
| 512 | |
| 513 // Similar to the TopContainerView, moving the mouse slightly off vertically | |
| 514 // of the find bar does not end the reveal. | |
| 515 AttemptReveal(MODALITY_MOUSE); | |
| 516 MoveMouse(find_bar_bounds.x() + 25, find_bar_bounds.bottom() + 1); | |
| 517 EXPECT_TRUE(controller()->IsRevealed()); | |
| 518 | |
| 519 // Similar to the TopContainerView, clicking the mouse even slightly off of | |
| 520 // the find bar ends the reveal. | |
| 521 GetEventGenerator().ClickLeftButton(); | |
| 522 EXPECT_FALSE(controller()->IsRevealed()); | |
| 523 | |
| 524 // Set the find bar bounds to empty. Hovering over the position previously | |
| 525 // occupied by the find bar, |over_find_bar|, should end the reveal. | |
| 526 controller()->OnFindBarVisibleBoundsChanged(gfx::Rect()); | |
| 527 AttemptReveal(MODALITY_MOUSE); | |
| 528 MoveMouse(over_find_bar.x(), over_find_bar.y()); | |
| 529 EXPECT_FALSE(controller()->IsRevealed()); | |
| 530 } | |
| 531 | |
| 532 // Test behavior when the mouse becomes hovered without moving. | 500 // Test behavior when the mouse becomes hovered without moving. |
| 533 TEST_F(ImmersiveModeControllerAshTest, MouseHoveredWithoutMoving) { | 501 TEST_F(ImmersiveFullscreenControllerTest, MouseHoveredWithoutMoving) { |
| 534 controller()->SetEnabled(true); | 502 controller()->SetEnabled(true); |
| 535 scoped_ptr<ImmersiveRevealedLock> lock; | 503 scoped_ptr<ImmersiveRevealedLock> lock; |
| 536 | 504 |
| 537 // 1) Test that if the mouse becomes hovered without the mouse moving due to a | 505 // 1) Test that if the mouse becomes hovered without the mouse moving due to a |
| 538 // lock causing the top-of-window views to be revealed (and the mouse | 506 // lock causing the top-of-window views to be revealed (and the mouse |
| 539 // happening to be near the top of the screen), the top-of-window views do not | 507 // happening to be near the top of the screen), the top-of-window views do not |
| 540 // hide till the mouse moves off of the top-of-window views. | 508 // hide till the mouse moves off of the top-of-window views. |
| 541 SetHovered(true); | 509 SetHovered(true); |
| 542 EXPECT_FALSE(controller()->IsRevealed()); | 510 EXPECT_FALSE(controller()->IsRevealed()); |
| 543 lock.reset(controller()->GetRevealedLock( | 511 lock.reset(controller()->GetRevealedLock( |
| 544 ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO)); | 512 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 545 EXPECT_TRUE(controller()->IsRevealed()); | 513 EXPECT_TRUE(controller()->IsRevealed()); |
| 546 lock.reset(); | 514 lock.reset(); |
| 547 EXPECT_TRUE(controller()->IsRevealed()); | 515 EXPECT_TRUE(controller()->IsRevealed()); |
| 548 SetHovered(false); | 516 SetHovered(false); |
| 549 EXPECT_FALSE(controller()->IsRevealed()); | 517 EXPECT_FALSE(controller()->IsRevealed()); |
| 550 | 518 |
| 551 // 2) Test that if the mouse becomes hovered without moving because of a | 519 // 2) Test that if the mouse becomes hovered without moving because of a |
| 552 // reveal in ImmersiveModeControllerAshTest::controller()->SetEnabled(true) | 520 // reveal in ImmersiveFullscreenController::controller()->SetEnabled(true) |
| 553 // and there are no locks keeping the top-of-window views revealed, that mouse | 521 // and there are no locks keeping the top-of-window views revealed, that mouse |
| 554 // hover does not prevent the top-of-window views from closing. | 522 // hover does not prevent the top-of-window views from closing. |
| 555 controller()->SetEnabled(false); | 523 controller()->SetEnabled(false); |
| 556 SetHovered(true); | 524 SetHovered(true); |
| 557 EXPECT_FALSE(controller()->IsRevealed()); | 525 EXPECT_FALSE(controller()->IsRevealed()); |
| 558 controller()->SetEnabled(true); | 526 controller()->SetEnabled(true); |
| 559 EXPECT_FALSE(controller()->IsRevealed()); | 527 EXPECT_FALSE(controller()->IsRevealed()); |
| 560 | 528 |
| 561 // 3) Test that if the mouse becomes hovered without moving because of a | 529 // 3) Test that if the mouse becomes hovered without moving because of a |
| 562 // reveal in ImmersiveModeControllerAshTest::controller()->SetEnabled(true) | 530 // reveal in ImmersiveFullscreenController::controller()->SetEnabled(true) |
| 563 // and there is a lock keeping the top-of-window views revealed, that the | 531 // and there is a lock keeping the top-of-window views revealed, that the |
| 564 // top-of-window views do not hide till the mouse moves off of the | 532 // top-of-window views do not hide till the mouse moves off of the |
| 565 // top-of-window views. | 533 // top-of-window views. |
| 566 controller()->SetEnabled(false); | 534 controller()->SetEnabled(false); |
| 567 SetHovered(true); | 535 SetHovered(true); |
| 568 lock.reset(controller()->GetRevealedLock( | 536 lock.reset(controller()->GetRevealedLock( |
| 569 ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO)); | 537 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 570 EXPECT_FALSE(controller()->IsRevealed()); | 538 EXPECT_FALSE(controller()->IsRevealed()); |
| 571 controller()->SetEnabled(true); | 539 controller()->SetEnabled(true); |
| 572 EXPECT_TRUE(controller()->IsRevealed()); | 540 EXPECT_TRUE(controller()->IsRevealed()); |
| 573 lock.reset(); | 541 lock.reset(); |
| 574 EXPECT_TRUE(controller()->IsRevealed()); | 542 EXPECT_TRUE(controller()->IsRevealed()); |
| 575 SetHovered(false); | 543 SetHovered(false); |
| 576 EXPECT_FALSE(controller()->IsRevealed()); | 544 EXPECT_FALSE(controller()->IsRevealed()); |
| 577 } | 545 } |
| 578 | 546 |
| 579 // Test revealing the top-of-window views using one modality and ending | 547 // Test revealing the top-of-window views using one modality and ending |
| 580 // the reveal via another. For instance, initiating the reveal via a SWIPE_OPEN | 548 // the reveal via another. For instance, initiating the reveal via a SWIPE_OPEN |
| 581 // edge gesture, switching to using the mouse and ending the reveal by moving | 549 // edge gesture, switching to using the mouse and ending the reveal by moving |
| 582 // the mouse off of the top-of-window views. | 550 // the mouse off of the top-of-window views. |
| 583 TEST_F(ImmersiveModeControllerAshTest, DifferentModalityEnterExit) { | 551 TEST_F(ImmersiveFullscreenControllerTest, DifferentModalityEnterExit) { |
| 584 controller()->SetEnabled(true); | 552 controller()->SetEnabled(true); |
| 585 EXPECT_TRUE(controller()->IsEnabled()); | 553 EXPECT_TRUE(controller()->IsEnabled()); |
| 586 EXPECT_FALSE(controller()->IsRevealed()); | 554 EXPECT_FALSE(controller()->IsRevealed()); |
| 587 | 555 |
| 588 // Initiate reveal via gesture, end reveal via mouse. | 556 // Initiate reveal via gesture, end reveal via mouse. |
| 589 AttemptReveal(MODALITY_GESTURE); | 557 AttemptReveal(MODALITY_GESTURE); |
| 590 EXPECT_TRUE(controller()->IsRevealed()); | 558 EXPECT_TRUE(controller()->IsRevealed()); |
| 591 MoveMouse(1, 1); | 559 MoveMouse(1, 1); |
| 592 EXPECT_TRUE(controller()->IsRevealed()); | 560 EXPECT_TRUE(controller()->IsRevealed()); |
| 593 AttemptUnreveal(MODALITY_MOUSE); | 561 AttemptUnreveal(MODALITY_MOUSE); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 606 EXPECT_FALSE(controller()->IsRevealed()); | 574 EXPECT_FALSE(controller()->IsRevealed()); |
| 607 | 575 |
| 608 // Initiate reveal via mouse, end reveal via touch. | 576 // Initiate reveal via mouse, end reveal via touch. |
| 609 AttemptReveal(MODALITY_MOUSE); | 577 AttemptReveal(MODALITY_MOUSE); |
| 610 EXPECT_TRUE(controller()->IsRevealed()); | 578 EXPECT_TRUE(controller()->IsRevealed()); |
| 611 AttemptUnreveal(MODALITY_TOUCH); | 579 AttemptUnreveal(MODALITY_TOUCH); |
| 612 EXPECT_FALSE(controller()->IsRevealed()); | 580 EXPECT_FALSE(controller()->IsRevealed()); |
| 613 } | 581 } |
| 614 | 582 |
| 615 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views. | 583 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views. |
| 616 TEST_F(ImmersiveModeControllerAshTest, EndRevealViaGesture) { | 584 TEST_F(ImmersiveFullscreenControllerTest, EndRevealViaGesture) { |
| 617 controller()->SetEnabled(true); | 585 controller()->SetEnabled(true); |
| 618 EXPECT_TRUE(controller()->IsEnabled()); | 586 EXPECT_TRUE(controller()->IsEnabled()); |
| 619 EXPECT_FALSE(controller()->IsRevealed()); | 587 EXPECT_FALSE(controller()->IsRevealed()); |
| 620 | 588 |
| 621 // A gesture should be able to close the top-of-window views when | 589 // A gesture should be able to close the top-of-window views when |
| 622 // top-of-window views have focus. | 590 // top-of-window views have focus. |
| 623 AttemptReveal(MODALITY_MOUSE); | 591 AttemptReveal(MODALITY_MOUSE); |
| 624 top_container()->RequestFocus(); | 592 top_container()->RequestFocus(); |
| 625 EXPECT_TRUE(controller()->IsRevealed()); | 593 EXPECT_TRUE(controller()->IsRevealed()); |
| 626 AttemptUnreveal(MODALITY_GESTURE); | 594 AttemptUnreveal(MODALITY_GESTURE); |
| 627 EXPECT_FALSE(controller()->IsRevealed()); | 595 EXPECT_FALSE(controller()->IsRevealed()); |
| 628 top_container()->GetFocusManager()->ClearFocus(); | 596 top_container()->GetFocusManager()->ClearFocus(); |
| 629 | 597 |
| 630 // If some other code is holding onto a lock, a gesture should not be able to | 598 // If some other code is holding onto a lock, a gesture should not be able to |
| 631 // end the reveal. | 599 // end the reveal. |
| 632 AttemptReveal(MODALITY_MOUSE); | 600 AttemptReveal(MODALITY_MOUSE); |
| 633 scoped_ptr<ImmersiveRevealedLock> lock(controller()->GetRevealedLock( | 601 scoped_ptr<ImmersiveRevealedLock> lock(controller()->GetRevealedLock( |
| 634 ImmersiveModeController::ANIMATE_REVEAL_NO)); | 602 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 635 EXPECT_TRUE(controller()->IsRevealed()); | 603 EXPECT_TRUE(controller()->IsRevealed()); |
| 636 AttemptUnreveal(MODALITY_GESTURE); | 604 AttemptUnreveal(MODALITY_GESTURE); |
| 637 EXPECT_TRUE(controller()->IsRevealed()); | 605 EXPECT_TRUE(controller()->IsRevealed()); |
| 638 lock.reset(); | 606 lock.reset(); |
| 639 EXPECT_FALSE(controller()->IsRevealed()); | 607 EXPECT_FALSE(controller()->IsRevealed()); |
| 640 } | 608 } |
| 641 | 609 |
| 642 // Do not test under windows because focus testing is not reliable on | 610 // Do not test under windows because focus testing is not reliable on |
| 643 // Windows. (crbug.com/79493) | 611 // Windows. (crbug.com/79493) |
| 644 #if !defined(OS_WIN) | 612 #if !defined(OS_WIN) |
| 645 | 613 |
| 646 // Test how focus and activation affects whether the top-of-window views are | 614 // Test how focus and activation affects whether the top-of-window views are |
| 647 // revealed. | 615 // revealed. |
| 648 TEST_F(ImmersiveModeControllerAshTest, Focus) { | 616 TEST_F(ImmersiveFullscreenControllerTest, Focus) { |
| 649 // Add views to the view hierarchy which we will focus and unfocus during the | 617 // Add views to the view hierarchy which we will focus and unfocus during the |
| 650 // test. | 618 // test. |
| 651 views::View* child_view = new views::View(); | 619 views::View* child_view = new views::View(); |
| 652 child_view->SetBounds(0, 0, 10, 10); | 620 child_view->SetBounds(0, 0, 10, 10); |
| 653 child_view->set_focusable(true); | 621 child_view->set_focusable(true); |
| 654 top_container()->AddChildView(child_view); | 622 top_container()->AddChildView(child_view); |
| 655 views::View* unrelated_view = new views::View(); | 623 views::View* unrelated_view = new views::View(); |
| 656 unrelated_view->SetBounds(0, 100, 10, 10); | 624 unrelated_view->SetBounds(0, 100, 10, 10); |
| 657 unrelated_view->set_focusable(true); | 625 unrelated_view->set_focusable(true); |
| 658 top_container()->parent()->AddChildView(unrelated_view); | 626 top_container()->parent()->AddChildView(unrelated_view); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 unrelated_view->RequestFocus(); | 660 unrelated_view->RequestFocus(); |
| 693 controller()->SetEnabled(true); | 661 controller()->SetEnabled(true); |
| 694 EXPECT_FALSE(controller()->IsRevealed()); | 662 EXPECT_FALSE(controller()->IsRevealed()); |
| 695 | 663 |
| 696 // Repeat test but with a revealed lock acquired when immersive mode is | 664 // Repeat test but with a revealed lock acquired when immersive mode is |
| 697 // disabled because the code path is different. | 665 // disabled because the code path is different. |
| 698 child_view->RequestFocus(); | 666 child_view->RequestFocus(); |
| 699 EXPECT_TRUE(controller()->IsRevealed()); | 667 EXPECT_TRUE(controller()->IsRevealed()); |
| 700 controller()->SetEnabled(false); | 668 controller()->SetEnabled(false); |
| 701 scoped_ptr<ImmersiveRevealedLock> lock(controller()->GetRevealedLock( | 669 scoped_ptr<ImmersiveRevealedLock> lock(controller()->GetRevealedLock( |
| 702 ImmersiveModeController::ANIMATE_REVEAL_NO)); | 670 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 703 EXPECT_FALSE(controller()->IsRevealed()); | 671 EXPECT_FALSE(controller()->IsRevealed()); |
| 704 unrelated_view->RequestFocus(); | 672 unrelated_view->RequestFocus(); |
| 705 controller()->SetEnabled(true); | 673 controller()->SetEnabled(true); |
| 706 EXPECT_TRUE(controller()->IsRevealed()); | 674 EXPECT_TRUE(controller()->IsRevealed()); |
| 707 lock.reset(); | 675 lock.reset(); |
| 708 EXPECT_FALSE(controller()->IsRevealed()); | 676 EXPECT_FALSE(controller()->IsRevealed()); |
| 709 } | 677 } |
| 710 | 678 |
| 711 // Test how activation affects whether the top-of-window views are revealed. | 679 // Test how activation affects whether the top-of-window views are revealed. |
| 712 // The behavior when a bubble is activated is tested in | 680 // The behavior when a bubble is activated is tested in |
| 713 // ImmersiveModeControllerAshTest.Bubbles. | 681 // ImmersiveFullscreenControllerTest.Bubbles. |
| 714 TEST_F(ImmersiveModeControllerAshTest, Activation) { | 682 TEST_F(ImmersiveFullscreenControllerTest, Activation) { |
| 715 views::Widget* top_container_widget = top_container()->GetWidget(); | 683 views::Widget* top_container_widget = top_container()->GetWidget(); |
| 716 | 684 |
| 717 controller()->SetEnabled(true); | 685 controller()->SetEnabled(true); |
| 718 ASSERT_FALSE(controller()->IsRevealed()); | 686 ASSERT_FALSE(controller()->IsRevealed()); |
| 719 | 687 |
| 720 // 1) Test that a transient window which is not a bubble does not trigger a | 688 // 1) Test that a transient window which is not a bubble does not trigger a |
| 721 // reveal but does keep the top-of-window views revealed if they are already | 689 // reveal but does keep the top-of-window views revealed if they are already |
| 722 // revealed. | 690 // revealed. |
| 723 views::Widget::InitParams transient_params; | 691 views::Widget::InitParams transient_params; |
| 724 transient_params.ownership = | 692 transient_params.ownership = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 751 | 719 |
| 752 EXPECT_FALSE(controller()->IsRevealed()); | 720 EXPECT_FALSE(controller()->IsRevealed()); |
| 753 top_container_widget->Activate(); | 721 top_container_widget->Activate(); |
| 754 AttemptReveal(MODALITY_MOUSE); | 722 AttemptReveal(MODALITY_MOUSE); |
| 755 EXPECT_TRUE(controller()->IsRevealed()); | 723 EXPECT_TRUE(controller()->IsRevealed()); |
| 756 non_transient_widget->Activate(); | 724 non_transient_widget->Activate(); |
| 757 EXPECT_FALSE(controller()->IsRevealed()); | 725 EXPECT_FALSE(controller()->IsRevealed()); |
| 758 } | 726 } |
| 759 | 727 |
| 760 // Test how bubbles affect whether the top-of-window views are revealed. | 728 // Test how bubbles affect whether the top-of-window views are revealed. |
| 761 TEST_F(ImmersiveModeControllerAshTest, Bubbles) { | 729 TEST_F(ImmersiveFullscreenControllerTest, Bubbles) { |
| 762 scoped_ptr<ImmersiveRevealedLock> revealed_lock; | 730 scoped_ptr<ImmersiveRevealedLock> revealed_lock; |
| 763 views::Widget* top_container_widget = top_container()->GetWidget(); | 731 views::Widget* top_container_widget = top_container()->GetWidget(); |
| 764 | 732 |
| 765 // Add views to the view hierarchy to which we will anchor bubbles. | 733 // Add views to the view hierarchy to which we will anchor bubbles. |
| 766 views::View* child_view = new views::View(); | 734 views::View* child_view = new views::View(); |
| 767 child_view->SetBounds(0, 0, 10, 10); | 735 child_view->SetBounds(0, 0, 10, 10); |
| 768 top_container()->AddChildView(child_view); | 736 top_container()->AddChildView(child_view); |
| 769 views::View* unrelated_view = new views::View(); | 737 views::View* unrelated_view = new views::View(); |
| 770 unrelated_view->SetBounds(0, 100, 10, 10); | 738 unrelated_view->SetBounds(0, 100, 10, 10); |
| 771 top_container()->parent()->AddChildView(unrelated_view); | 739 top_container()->parent()->AddChildView(unrelated_view); |
| 772 | 740 |
| 773 controller()->SetEnabled(true); | 741 controller()->SetEnabled(true); |
| 774 ASSERT_FALSE(controller()->IsRevealed()); | 742 ASSERT_FALSE(controller()->IsRevealed()); |
| 775 | 743 |
| 776 // 1) Test that a bubble anchored to a child of the top container triggers | 744 // 1) Test that a bubble anchored to a child of the top container triggers |
| 777 // a reveal and keeps the top-of-window views revealed for the duration of | 745 // a reveal and keeps the top-of-window views revealed for the duration of |
| 778 // its visibility. | 746 // its visibility. |
| 779 views::Widget* bubble_widget1(views::BubbleDelegateView::CreateBubble( | 747 views::Widget* bubble_widget1(views::BubbleDelegateView::CreateBubble( |
| 780 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE))); | 748 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE))); |
| 781 bubble_widget1->Show(); | 749 bubble_widget1->Show(); |
| 782 EXPECT_TRUE(controller()->IsRevealed()); | 750 EXPECT_TRUE(controller()->IsRevealed()); |
| 783 | 751 |
| 784 // Activating |top_container_widget| will close |bubble_widget1|. | 752 // Activating |top_container_widget| will close |bubble_widget1|. |
| 785 top_container_widget->Activate(); | 753 top_container_widget->Activate(); |
| 786 AttemptReveal(MODALITY_MOUSE); | 754 AttemptReveal(MODALITY_MOUSE); |
| 787 revealed_lock.reset(controller()->GetRevealedLock( | 755 revealed_lock.reset(controller()->GetRevealedLock( |
| 788 ImmersiveModeController::ANIMATE_REVEAL_NO)); | 756 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); |
| 789 EXPECT_TRUE(controller()->IsRevealed()); | 757 EXPECT_TRUE(controller()->IsRevealed()); |
| 790 | 758 |
| 791 views::Widget* bubble_widget2 = views::BubbleDelegateView::CreateBubble( | 759 views::Widget* bubble_widget2 = views::BubbleDelegateView::CreateBubble( |
| 792 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE)); | 760 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE)); |
| 793 bubble_widget2->Show(); | 761 bubble_widget2->Show(); |
| 794 EXPECT_TRUE(controller()->IsRevealed()); | 762 EXPECT_TRUE(controller()->IsRevealed()); |
| 795 revealed_lock.reset(); | 763 revealed_lock.reset(); |
| 796 SetHovered(false); | 764 SetHovered(false); |
| 797 EXPECT_TRUE(controller()->IsRevealed()); | 765 EXPECT_TRUE(controller()->IsRevealed()); |
| 798 bubble_widget2->Close(); | 766 bubble_widget2->Close(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 views::Widget* bubble_widget8 = views::BubbleDelegateView::CreateBubble( | 848 views::Widget* bubble_widget8 = views::BubbleDelegateView::CreateBubble( |
| 881 new views::BubbleDelegateView(unrelated_view, views::BubbleBorder::NONE)); | 849 new views::BubbleDelegateView(unrelated_view, views::BubbleBorder::NONE)); |
| 882 bubble_widget8->Show(); | 850 bubble_widget8->Show(); |
| 883 SetHovered(false); | 851 SetHovered(false); |
| 884 EXPECT_FALSE(controller()->IsRevealed()); | 852 EXPECT_FALSE(controller()->IsRevealed()); |
| 885 bubble_widget8->Close(); | 853 bubble_widget8->Close(); |
| 886 } | 854 } |
| 887 | 855 |
| 888 #endif // defined(OS_WIN) | 856 #endif // defined(OS_WIN) |
| 889 | 857 |
| 890 class ImmersiveModeControllerAshTestWithBrowserView | |
| 891 : public TestWithBrowserView { | |
| 892 public: | |
| 893 ImmersiveModeControllerAshTestWithBrowserView() {} | |
| 894 virtual ~ImmersiveModeControllerAshTestWithBrowserView() {} | |
| 895 | |
| 896 // TestWithBrowserView override: | |
| 897 virtual void SetUp() OVERRIDE { | |
| 898 TestWithBrowserView::SetUp(); | |
| 899 | |
| 900 browser()->window()->Show(); | |
| 901 | |
| 902 controller_ = browser_view()->immersive_mode_controller(); | |
| 903 controller_->SetupForTest(); | |
| 904 } | |
| 905 | |
| 906 // Returns the bounds of |view| in widget coordinates. | |
| 907 gfx::Rect GetBoundsInWidget(views::View* view) { | |
| 908 return view->ConvertRectToWidget(view->GetLocalBounds()); | |
| 909 } | |
| 910 | |
| 911 // Toggle the browser's fullscreen state. | |
| 912 void ToggleFullscreen() { | |
| 913 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. The notification | |
| 914 // is used to trigger changes in whether the shelf is auto hidden and | |
| 915 // whether a "light bar" version of the tab strip is used when the | |
| 916 // top-of-window views are hidden. | |
| 917 scoped_ptr<FullscreenNotificationObserver> waiter( | |
| 918 new FullscreenNotificationObserver()); | |
| 919 chrome::ToggleFullscreenMode(browser()); | |
| 920 waiter->Wait(); | |
| 921 } | |
| 922 | |
| 923 // Set whether the browser is in tab fullscreen. | |
| 924 void SetTabFullscreen(bool tab_fullscreen) { | |
| 925 content::WebContents* web_contents = | |
| 926 browser_view()->GetContentsWebViewForTest()->GetWebContents(); | |
| 927 scoped_ptr<FullscreenNotificationObserver> waiter( | |
| 928 new FullscreenNotificationObserver()); | |
| 929 browser()->fullscreen_controller()->ToggleFullscreenModeForTab( | |
| 930 web_contents, tab_fullscreen); | |
| 931 waiter->Wait(); | |
| 932 } | |
| 933 | |
| 934 // Attempt revealing the top-of-window views. | |
| 935 void AttemptReveal() { | |
| 936 if (!revealed_lock_.get()) { | |
| 937 revealed_lock_.reset(controller_->GetRevealedLock( | |
| 938 ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO)); | |
| 939 } | |
| 940 } | |
| 941 | |
| 942 // Attempt unrevealing the top-of-window views. | |
| 943 void AttemptUnreveal() { | |
| 944 revealed_lock_.reset(); | |
| 945 } | |
| 946 | |
| 947 ImmersiveModeController* controller() { return controller_; } | |
| 948 | |
| 949 private: | |
| 950 // Not owned. | |
| 951 ImmersiveModeController* controller_; | |
| 952 | |
| 953 scoped_ptr<ImmersiveRevealedLock> revealed_lock_; | |
| 954 | |
| 955 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestWithBrowserView); | |
| 956 }; | |
| 957 | |
| 958 // Test the layout and visibility of the tabstrip, toolbar and TopContainerView | |
| 959 // in immersive fullscreen. | |
| 960 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, Layout) { | |
| 961 AddTab(browser(), GURL("about:blank")); | |
| 962 | |
| 963 TabStrip* tabstrip = browser_view()->tabstrip(); | |
| 964 ToolbarView* toolbar = browser_view()->toolbar(); | |
| 965 views::WebView* contents_web_view = | |
| 966 browser_view()->GetContentsWebViewForTest(); | |
| 967 | |
| 968 // Immersive fullscreen starts out disabled. | |
| 969 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen()); | |
| 970 ASSERT_FALSE(controller()->IsEnabled()); | |
| 971 | |
| 972 // By default, the tabstrip and toolbar should be visible. | |
| 973 EXPECT_TRUE(tabstrip->visible()); | |
| 974 EXPECT_TRUE(toolbar->visible()); | |
| 975 | |
| 976 ToggleFullscreen(); | |
| 977 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen()); | |
| 978 EXPECT_TRUE(controller()->IsEnabled()); | |
| 979 EXPECT_FALSE(controller()->IsRevealed()); | |
| 980 | |
| 981 // Entering immersive fullscreen should make the tab strip use the immersive | |
| 982 // style and hide the toolbar. | |
| 983 EXPECT_TRUE(tabstrip->visible()); | |
| 984 EXPECT_TRUE(tabstrip->IsImmersiveStyle()); | |
| 985 EXPECT_FALSE(toolbar->visible()); | |
| 986 | |
| 987 // The tab indicators should be flush with the top of the widget. | |
| 988 EXPECT_EQ(0, GetBoundsInWidget(tabstrip).y()); | |
| 989 | |
| 990 // The web contents should be immediately below the tab indicators. | |
| 991 EXPECT_EQ(Tab::GetImmersiveHeight(), | |
| 992 GetBoundsInWidget(contents_web_view).y()); | |
| 993 | |
| 994 // Revealing the top-of-window views should set the tab strip back to the | |
| 995 // normal style and show the toolbar. | |
| 996 AttemptReveal(); | |
| 997 EXPECT_TRUE(controller()->IsRevealed()); | |
| 998 EXPECT_TRUE(tabstrip->visible()); | |
| 999 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); | |
| 1000 EXPECT_TRUE(toolbar->visible()); | |
| 1001 | |
| 1002 // The TopContainerView should be flush with the top edge of the widget. If | |
| 1003 // it is not flush with the top edge the immersive reveal animation looks | |
| 1004 // wonky. | |
| 1005 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); | |
| 1006 | |
| 1007 // The web contents should be at the same y position as they were when the | |
| 1008 // top-of-window views were hidden. | |
| 1009 EXPECT_EQ(Tab::GetImmersiveHeight(), | |
| 1010 GetBoundsInWidget(contents_web_view).y()); | |
| 1011 | |
| 1012 // Repeat the test for when in both immersive fullscreen and tab fullscreen. | |
| 1013 SetTabFullscreen(true); | |
| 1014 // Hide and reveal the top-of-window views so that they get relain out. | |
| 1015 AttemptUnreveal(); | |
| 1016 AttemptReveal(); | |
| 1017 | |
| 1018 // The tab strip and toolbar should still be visible and the TopContainerView | |
| 1019 // should still be flush with the top edge of the widget. | |
| 1020 EXPECT_TRUE(controller()->IsRevealed()); | |
| 1021 EXPECT_TRUE(tabstrip->visible()); | |
| 1022 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); | |
| 1023 EXPECT_TRUE(toolbar->visible()); | |
| 1024 EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y()); | |
| 1025 | |
| 1026 // The web contents should be flush with the top edge of the widget when in | |
| 1027 // both immersive and tab fullscreen. | |
| 1028 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); | |
| 1029 | |
| 1030 // Hide the top-of-window views. Both the tab strip and the toolbar should | |
| 1031 // hide when in both immersive and tab fullscreen. | |
| 1032 AttemptUnreveal(); | |
| 1033 EXPECT_FALSE(controller()->IsRevealed()); | |
| 1034 EXPECT_FALSE(tabstrip->visible()); | |
| 1035 EXPECT_FALSE(toolbar->visible()); | |
| 1036 | |
| 1037 // The web contents should still be flush with the edge of the widget. | |
| 1038 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y()); | |
| 1039 | |
| 1040 // Exiting both immersive and tab fullscreen should show the tab strip and | |
| 1041 // toolbar. | |
| 1042 ToggleFullscreen(); | |
| 1043 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); | |
| 1044 EXPECT_FALSE(controller()->IsEnabled()); | |
| 1045 EXPECT_FALSE(controller()->IsRevealed()); | |
| 1046 EXPECT_TRUE(tabstrip->visible()); | |
| 1047 EXPECT_FALSE(tabstrip->IsImmersiveStyle()); | |
| 1048 EXPECT_TRUE(toolbar->visible()); | |
| 1049 } | |
| 1050 | |
| 1051 // Test that the browser commands which are usually disabled in fullscreen are | |
| 1052 // are enabled in immersive fullscreen. | |
| 1053 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, EnabledCommands) { | |
| 1054 ASSERT_FALSE(controller()->IsEnabled()); | |
| 1055 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | |
| 1056 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
| 1057 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | |
| 1058 | |
| 1059 ToggleFullscreen(); | |
| 1060 EXPECT_TRUE(controller()->IsEnabled()); | |
| 1061 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | |
| 1062 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
| 1063 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | |
| 1064 } | |
| 1065 | |
| 1066 // Test that restoring a window properly exits immersive fullscreen. | |
| 1067 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, ExitUponRestore) { | |
| 1068 ASSERT_FALSE(controller()->IsEnabled()); | |
| 1069 ToggleFullscreen(); | |
| 1070 AttemptReveal(); | |
| 1071 ASSERT_TRUE(controller()->IsEnabled()); | |
| 1072 ASSERT_TRUE(controller()->IsRevealed()); | |
| 1073 ASSERT_TRUE(browser_view()->GetWidget()->IsFullscreen()); | |
| 1074 | |
| 1075 browser_view()->GetWidget()->Restore(); | |
| 1076 EXPECT_FALSE(controller()->IsEnabled()); | |
| 1077 } | |
| 1078 | |
| 1079 // Test that the shelf is set to auto hide as long as the window is in | 858 // Test that the shelf is set to auto hide as long as the window is in |
| 1080 // immersive fullscreen and that the shelf's state before entering immersive | 859 // immersive fullscreen and that the shelf's state before entering immersive |
| 1081 // fullscreen is restored upon exiting immersive fullscreen. | 860 // fullscreen is restored upon exiting immersive fullscreen. |
| 1082 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, Shelf) { | 861 TEST_F(ImmersiveFullscreenControllerTest, Shelf) { |
| 1083 // Shelf is visible when the test starts. | |
| 1084 ash::internal::ShelfLayoutManager* shelf = | 862 ash::internal::ShelfLayoutManager* shelf = |
| 1085 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | 863 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 864 |
| 865 // Shelf is visible by default. |
| 866 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 867 ASSERT_FALSE(controller()->IsEnabled()); |
| 1086 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); | 868 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); |
| 1087 | 869 |
| 1088 // Entering immersive fullscreen sets the shelf to auto hide. | 870 // Entering immersive fullscreen sets the shelf to auto hide. |
| 1089 ToggleFullscreen(); | 871 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1090 ASSERT_TRUE(browser_view()->IsFullscreen()); | 872 controller()->SetEnabled(true); |
| 1091 ASSERT_TRUE(controller()->IsEnabled()); | |
| 1092 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 873 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1093 | 874 |
| 1094 // Disabling immersive fullscreen puts it back. | 875 // Disabling immersive fullscreen puts it back. |
| 1095 ToggleFullscreen(); | 876 controller()->SetEnabled(false); |
| 1096 ASSERT_FALSE(browser_view()->IsFullscreen()); | 877 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1097 ASSERT_FALSE(controller()->IsEnabled()); | 878 ASSERT_FALSE(controller()->IsEnabled()); |
| 1098 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); | 879 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); |
| 1099 | 880 |
| 1100 // The user could toggle the shelf auto-hide behavior. | 881 // The user could toggle the shelf auto-hide behavior. |
| 1101 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 882 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1102 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 883 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1103 | 884 |
| 1104 // Entering immersive fullscreen keeps auto-hide. | 885 // Entering immersive fullscreen keeps auto-hide. |
| 1105 ToggleFullscreen(); | 886 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1106 ASSERT_TRUE(browser_view()->IsFullscreen()); | 887 controller()->SetEnabled(true); |
| 1107 ASSERT_TRUE(controller()->IsEnabled()); | |
| 1108 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 888 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1109 | 889 |
| 1110 // Disabling immersive fullscreen maintains the user's auto-hide selection. | 890 // Disabling immersive fullscreen maintains the user's auto-hide selection. |
| 1111 ToggleFullscreen(); | 891 controller()->SetEnabled(false); |
| 1112 ASSERT_FALSE(browser_view()->IsFullscreen()); | 892 window()->SetProperty(aura::client::kShowStateKey, |
| 1113 ASSERT_FALSE(controller()->IsEnabled()); | 893 ui::SHOW_STATE_NORMAL); |
| 1114 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 894 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1115 } | 895 } |
| 1116 | 896 |
| 1117 // Test how being simultaneously in tab fullscreen and immersive fullscreen | 897 } // namespase ash |
| 1118 // affects the shelf visibility and whether the tab indicators are hidden. | |
| 1119 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, TabAndBrowserFullscreen) { | |
| 1120 AddTab(browser(), GURL("about:blank")); | |
| 1121 | |
| 1122 // The shelf should start out as visible. | |
| 1123 ash::internal::ShelfLayoutManager* shelf = | |
| 1124 ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | |
| 1125 ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); | |
| 1126 | |
| 1127 // 1) Test that entering tab fullscreen from immersive fullscreen hides the | |
| 1128 // tab indicators and the shelf. | |
| 1129 ToggleFullscreen(); | |
| 1130 ASSERT_TRUE(controller()->IsEnabled()); | |
| 1131 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | |
| 1132 EXPECT_FALSE(controller()->ShouldHideTabIndicators()); | |
| 1133 | |
| 1134 SetTabFullscreen(true); | |
| 1135 ASSERT_TRUE(controller()->IsEnabled()); | |
| 1136 EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state()); | |
| 1137 EXPECT_TRUE(controller()->ShouldHideTabIndicators()); | |
| 1138 | |
| 1139 // 2) Test that exiting tab fullscreen shows the tab indicators and autohides | |
| 1140 // the shelf. | |
| 1141 SetTabFullscreen(false); | |
| 1142 ASSERT_TRUE(controller()->IsEnabled()); | |
| 1143 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | |
| 1144 EXPECT_FALSE(controller()->ShouldHideTabIndicators()); | |
| 1145 | |
| 1146 // 3) Test that exiting tab fullscreen and immersive fullscreen | |
| 1147 // simultaneously correctly updates the shelf visibility and whether the tab | |
| 1148 // indicators should be hidden. | |
| 1149 SetTabFullscreen(true); | |
| 1150 ToggleFullscreen(); | |
| 1151 ASSERT_FALSE(controller()->IsEnabled()); | |
| 1152 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); | |
| 1153 EXPECT_TRUE(controller()->ShouldHideTabIndicators()); | |
| 1154 } | |
| 1155 | 898 |
| 1156 #endif // defined(OS_CHROMEOS) | 899 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |