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

Unified Diff: ash/wm/immersive_fullscreen_controller_unittest.cc

Issue 48963002: [Refactor] Move the non-browser specific logic of ImmersiveModeControllerAsh into ash part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/immersive_fullscreen_controller_unittest.cc
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc b/ash/wm/immersive_fullscreen_controller_unittest.cc
similarity index 63%
copy from chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
copy to ash/wm/immersive_fullscreen_controller_unittest.cc
index ce917169d388a5bfcfab5d06dfb260ebc8c13775..5345c3cdebe038592a9d8ced772994f9ec982c0d 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
+++ b/ash/wm/immersive_fullscreen_controller_unittest.cc
@@ -2,23 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
+#include "ash/wm/immersive_fullscreen_controller.h"
#include "ash/display/display_manager.h"
#include "ash/root_window_controller.h"
+#include "ash/screen_ash.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_types.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
-#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
-#include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
-#include "chrome/browser/ui/views/frame/browser_view.h"
-#include "chrome/browser/ui/views/frame/test_with_browser_view.h"
-#include "chrome/browser/ui/views/frame/top_container_view.h"
-#include "chrome/browser/ui/views/tabs/tab_strip.h"
-#include "chrome/browser/ui/views/toolbar_view.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
@@ -26,42 +19,68 @@
#include "ui/aura/window.h"
#include "ui/gfx/animation/slide_animation.h"
#include "ui/views/bubble/bubble_delegate.h"
-#include "ui/views/controls/webview/webview.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
// For now, immersive fullscreen is Chrome OS only.
#if defined(OS_CHROMEOS)
-/////////////////////////////////////////////////////////////////////////////
+namespace ash {
-class MockImmersiveModeControllerDelegate
- : public ImmersiveModeController::Delegate {
- public:
- MockImmersiveModeControllerDelegate() : immersive_style_(false) {}
- virtual ~MockImmersiveModeControllerDelegate() {}
+namespace {
- bool immersive_style() const { return immersive_style_; }
+class MockImmersiveFullscreenControllerDelegate
+ : public ImmersiveFullscreenController::Delegate {
+ public:
+ MockImmersiveFullscreenControllerDelegate(views::View* top_container_view)
+ : top_container_view_(top_container_view),
+ enabled_(false),
+ visible_fraction_(1) {
+ }
+ virtual ~MockImmersiveFullscreenControllerDelegate() {}
- // ImmersiveModeController::Delegate overrides:
- virtual FullscreenController* GetFullscreenController() OVERRIDE {
- return NULL;
+ // ImmersiveFullscreenController::Delegate overrides:
+ virtual void OnImmersiveRevealStarted() OVERRIDE {
+ enabled_ = true;
+ visible_fraction_ = 0;
+ }
+ virtual void OnImmersiveRevealEnded() OVERRIDE {
+ visible_fraction_ = 0;
}
- virtual void FullscreenStateChanged() OVERRIDE {}
- virtual void SetImmersiveStyle(bool immersive) OVERRIDE {
- immersive_style_ = immersive;
+ virtual void OnImmersiveFullscreenExited() OVERRIDE {
+ enabled_ = false;
+ visible_fraction_ = 1;
+ }
+ virtual void SetVisibleFraction(double visible_fraction) OVERRIDE {
+ visible_fraction_ = visible_fraction;
+ }
+ virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() OVERRIDE {
+ std::vector<gfx::Rect> bounds_in_screen;
+ bounds_in_screen.push_back(top_container_view_->GetBoundsInScreen());
+ return bounds_in_screen;
+ }
+
+ bool is_enabled() const {
+ return enabled_;
}
- virtual content::WebContents* GetWebContents() OVERRIDE {
- return NULL;
+
+ double visible_fraction() const {
+ return visible_fraction_;
}
private:
- bool immersive_style_;
+ views::View* top_container_view_;
+ bool enabled_;
+ double visible_fraction_;
- DISALLOW_COPY_AND_ASSIGN(MockImmersiveModeControllerDelegate);
+ DISALLOW_COPY_AND_ASSIGN(MockImmersiveFullscreenControllerDelegate);
};
+} // namespace
+
/////////////////////////////////////////////////////////////////////////////
-class ImmersiveModeControllerAshTest : public ash::test::AshTestBase {
+class ImmersiveFullscreenControllerTest : public ash::test::AshTestBase {
public:
enum Modality {
MODALITY_MOUSE,
@@ -69,12 +88,24 @@ class ImmersiveModeControllerAshTest : public ash::test::AshTestBase {
MODALITY_GESTURE
};
- ImmersiveModeControllerAshTest() : widget_(NULL), top_container_(NULL) {}
- virtual ~ImmersiveModeControllerAshTest() {}
+ ImmersiveFullscreenControllerTest() : widget_(NULL), top_container_(NULL) {}
+ virtual ~ImmersiveFullscreenControllerTest() {}
- ImmersiveModeControllerAsh* controller() { return controller_.get(); }
- views::View* top_container() { return top_container_; }
- MockImmersiveModeControllerDelegate* delegate() { return delegate_.get(); }
+ ImmersiveFullscreenController* controller() {
+ return controller_.get();
+ }
+
+ views::View* top_container() {
+ return top_container_;
+ }
+
+ aura::Window* window() {
+ return widget_->GetNativeWindow();
+ }
+
+ MockImmersiveFullscreenControllerDelegate* delegate() {
+ return delegate_.get();
+ }
// Access to private data from the controller.
bool top_edge_hover_timer_running() const {
@@ -88,22 +119,24 @@ class ImmersiveModeControllerAshTest : public ash::test::AshTestBase {
virtual void SetUp() OVERRIDE {
ash::test::AshTestBase::SetUp();
- controller_.reset(new ImmersiveModeControllerAsh);
- delegate_.reset(new MockImmersiveModeControllerDelegate);
-
widget_ = new views::Widget();
views::Widget::InitParams params;
params.context = CurrentContext();
- params.bounds = gfx::Rect(0, 0, 500, 500);
widget_->Init(params);
widget_->Show();
+ window()->SetProperty(aura::client::kShowStateKey,
+ ui::SHOW_STATE_FULLSCREEN);
+
top_container_ = new views::View();
- top_container_->SetBounds(0, 0, 500, 100);
+ top_container_->SetBounds(
+ 0, 0, widget_->GetWindowBoundsInScreen().width(), 100);
top_container_->set_focusable(true);
-
widget_->GetContentsView()->AddChildView(top_container_);
+ delegate_.reset(
+ new MockImmersiveFullscreenControllerDelegate(top_container_));
+ controller_.reset(new ImmersiveFullscreenController);
controller_->Init(delegate_.get(), widget_, top_container_);
SetAnimationsDisabled(true);
@@ -111,13 +144,14 @@ class ImmersiveModeControllerAshTest : public ash::test::AshTestBase {
// AshTestBase.
}
- // Enable or disable the immersive mode controller's animations. When the
- // immersive mode controller's animations are disabled, some behavior is
+ // Enable or disable the ImmersiveFullscreenController's animations. When the
+ // ImmersiveFullscreenController's animations are disabled, some behavior is
// slightly different. In particular, the behavior is different when there
// is a transfer in which lock keeps the top-of-window views revealed (eg
// bubble keeps top-of-window views revealed -> mouse keeps top-of-window
- // views revealed). It is necessary to temparily enable the immersive
- // controller's animations to get the correct behavior in tests.
+ // views revealed). It is necessary to temporarily enable the
+ // ImmersiveFullscreenController's animations to get the correct behavior in
+ // tests.
void SetAnimationsDisabled(bool disabled) {
controller_->animations_disabled_for_test_ = disabled;
// Force any in progress animations to finish.
@@ -184,69 +218,54 @@ class ImmersiveModeControllerAshTest : public ash::test::AshTestBase {
}
case MODALITY_GESTURE: {
aura::client::GetCursorClient(CurrentContext())->DisableMouseEvents();
- ImmersiveModeControllerAsh::SwipeType swipe_type = revealed ?
- ImmersiveModeControllerAsh::SWIPE_OPEN :
- ImmersiveModeControllerAsh::SWIPE_CLOSE;
+ ImmersiveFullscreenController::SwipeType swipe_type = revealed ?
+ ImmersiveFullscreenController::SWIPE_OPEN :
+ ImmersiveFullscreenController::SWIPE_CLOSE;
controller_->UpdateRevealedLocksForSwipe(swipe_type);
break;
}
}
}
- scoped_ptr<ImmersiveModeControllerAsh> controller_;
- scoped_ptr<MockImmersiveModeControllerDelegate> delegate_;
+ scoped_ptr<ImmersiveFullscreenController> controller_;
+ scoped_ptr<MockImmersiveFullscreenControllerDelegate> delegate_;
views::Widget* widget_; // Owned by the native widget.
views::View* top_container_; // Owned by |root_view_|.
- DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest);
+ DISALLOW_COPY_AND_ASSIGN(ImmersiveFullscreenControllerTest);
};
-// Test of initial state and basic functionality.
-TEST_F(ImmersiveModeControllerAshTest, ImmersiveModeControllerAsh) {
+// Test the initial state and that the delegate gets notified of the
+// top-of-window views getting hidden and revealed.
+TEST_F(ImmersiveFullscreenControllerTest, Delegate) {
// Initial state.
EXPECT_FALSE(controller()->IsEnabled());
- EXPECT_FALSE(controller()->ShouldHideTopViews());
EXPECT_FALSE(controller()->IsRevealed());
- EXPECT_FALSE(delegate()->immersive_style());
+ EXPECT_FALSE(delegate()->is_enabled());
- // Enabling hides the top views.
+ // Enabling initially hides the top views.
controller()->SetEnabled(true);
EXPECT_TRUE(controller()->IsEnabled());
EXPECT_FALSE(controller()->IsRevealed());
- EXPECT_TRUE(controller()->ShouldHideTopViews());
- EXPECT_FALSE(controller()->ShouldHideTabIndicators());
- EXPECT_TRUE(delegate()->immersive_style());
+ EXPECT_TRUE(delegate()->is_enabled());
+ EXPECT_EQ(0, delegate()->visible_fraction());
// Revealing shows the top views.
AttemptReveal(MODALITY_MOUSE);
- EXPECT_TRUE(controller()->IsRevealed());
- EXPECT_FALSE(controller()->ShouldHideTopViews());
- // Tabs are painting in the normal style during a reveal.
- EXPECT_FALSE(delegate()->immersive_style());
-
- // Disabling immersive fullscreen keeps the top views shown.
- controller()->SetEnabled(false);
- EXPECT_FALSE(controller()->IsEnabled());
- EXPECT_FALSE(controller()->IsRevealed());
- EXPECT_FALSE(controller()->ShouldHideTopViews());
- EXPECT_FALSE(delegate()->immersive_style());
-
- // Test disabling immersive fullscreen when the top views are hidden.
- controller()->SetEnabled(true);
EXPECT_TRUE(controller()->IsEnabled());
- EXPECT_FALSE(controller()->IsRevealed());
- EXPECT_TRUE(controller()->ShouldHideTopViews());
- EXPECT_TRUE(delegate()->immersive_style());
+ EXPECT_TRUE(controller()->IsRevealed());
+ EXPECT_TRUE(delegate()->is_enabled());
+ EXPECT_EQ(1, delegate()->visible_fraction());
+ // Disabling ends the immersive reveal.
controller()->SetEnabled(false);
EXPECT_FALSE(controller()->IsEnabled());
EXPECT_FALSE(controller()->IsRevealed());
- EXPECT_FALSE(controller()->ShouldHideTopViews());
- EXPECT_FALSE(delegate()->immersive_style());
+ EXPECT_FALSE(delegate()->is_enabled());
}
// GetRevealedLock() specific tests.
-TEST_F(ImmersiveModeControllerAshTest, RevealedLock) {
+TEST_F(ImmersiveFullscreenControllerTest, RevealedLock) {
scoped_ptr<ImmersiveRevealedLock> lock1;
scoped_ptr<ImmersiveRevealedLock> lock2;
@@ -257,7 +276,7 @@ TEST_F(ImmersiveModeControllerAshTest, RevealedLock) {
// fullscreen is disabled. Acquiring or releasing the lock should have no
// effect till immersive fullscreen is enabled.
lock1.reset(controller()->GetRevealedLock(
- ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
EXPECT_FALSE(controller()->IsEnabled());
EXPECT_FALSE(controller()->IsRevealed());
@@ -283,13 +302,13 @@ TEST_F(ImmersiveModeControllerAshTest, RevealedLock) {
// 2) Test that acquiring a lock reveals the top-of-window views if they are
// hidden.
lock1.reset(controller()->GetRevealedLock(
- ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
EXPECT_TRUE(controller()->IsRevealed());
// 3) Test that the top-of-window views are only hidden when all of the locks
// are released.
lock2.reset(controller()->GetRevealedLock(
- ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
lock1.reset();
EXPECT_TRUE(controller()->IsRevealed());
@@ -298,7 +317,13 @@ TEST_F(ImmersiveModeControllerAshTest, RevealedLock) {
}
// Test mouse event processing for top-of-screen reveal triggering.
-TEST_F(ImmersiveModeControllerAshTest, OnMouseEvent) {
+TEST_F(ImmersiveFullscreenControllerTest, OnMouseEvent) {
+ // Set up initial state.
+ UpdateDisplay("800x600,800x600");
+ ash::DisplayLayout display_layout(ash::DisplayLayout::RIGHT, 0);
+ ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
+ display_layout);
+
// Set up initial state.
controller()->SetEnabled(true);
ASSERT_TRUE(controller()->IsEnabled());
@@ -324,8 +349,8 @@ TEST_F(ImmersiveModeControllerAshTest, OnMouseEvent) {
EXPECT_TRUE(top_edge_hover_timer_running());
EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top());
- // Moving |ImmersiveModeControllerAsh::kMouseRevealBoundsHeight| down from
- // the top edge stops it.
+ // Moving |ImmersiveFullscreenControllerTest::kMouseRevealBoundsHeight| down
+ // from the top edge stops it.
event_generator.MoveMouseBy(0, 3);
EXPECT_FALSE(top_edge_hover_timer_running());
@@ -351,8 +376,7 @@ TEST_F(ImmersiveModeControllerAshTest, OnMouseEvent) {
EXPECT_EQ(top_edge_pos.x() + 100, mouse_x_when_hit_top());
// Moving off the top edge horizontally stops the timer.
- EXPECT_GT(CurrentContext()->bounds().width(), top_container()->width());
- event_generator.MoveMouseTo(top_container_bounds_in_screen.right(),
+ event_generator.MoveMouseTo(top_container_bounds_in_screen.right() + 1,
top_container_bounds_in_screen.y());
EXPECT_FALSE(top_edge_hover_timer_running());
@@ -399,7 +423,7 @@ TEST_F(ImmersiveModeControllerAshTest, OnMouseEvent) {
// Test mouse event processing for top-of-screen reveal triggering when the user
// has a vertical display layout (primary display above/below secondary display)
// and the immersive fullscreen window is on the bottom display.
-TEST_F(ImmersiveModeControllerAshTest, MouseEventsVerticalDisplayLayout) {
+TEST_F(ImmersiveFullscreenControllerTest, MouseEventsVerticalDisplayLayout) {
if (!SupportsMultipleDisplays())
return;
@@ -473,64 +497,8 @@ TEST_F(ImmersiveModeControllerAshTest, MouseEventsVerticalDisplayLayout) {
EXPECT_FALSE(controller()->IsRevealed());
}
-// Test that hovering the mouse over the find bar does not end a reveal.
-TEST_F(ImmersiveModeControllerAshTest, FindBar) {
- // Set up initial state.
- controller()->SetEnabled(true);
- ASSERT_TRUE(controller()->IsEnabled());
- ASSERT_FALSE(controller()->IsRevealed());
-
- // Compute the find bar bounds relative to TopContainerView. The find
- // bar is aligned with the bottom right of the TopContainerView.
- gfx::Rect find_bar_bounds(top_container()->bounds().right() - 100,
- top_container()->bounds().bottom(),
- 100,
- 50);
-
- gfx::Point find_bar_position_in_screen = find_bar_bounds.origin();
- views::View::ConvertPointToScreen(top_container(),
- &find_bar_position_in_screen);
- gfx::Rect find_bar_bounds_in_screen(find_bar_position_in_screen,
- find_bar_bounds.size());
- controller()->OnFindBarVisibleBoundsChanged(find_bar_bounds_in_screen);
-
- // Moving the mouse over the find bar does not end the reveal.
- gfx::Point over_find_bar(find_bar_bounds.x() + 25, find_bar_bounds.y() + 25);
- AttemptReveal(MODALITY_MOUSE);
- EXPECT_TRUE(controller()->IsRevealed());
- MoveMouse(over_find_bar.x(), over_find_bar.y());
- EXPECT_TRUE(controller()->IsRevealed());
-
- // Moving the mouse off of the find bar horizontally ends the reveal.
- MoveMouse(find_bar_bounds.x() - 25, find_bar_bounds.y() + 25);
- EXPECT_FALSE(controller()->IsRevealed());
-
- // Moving the mouse off of the find bar vertically ends the reveal.
- AttemptReveal(MODALITY_MOUSE);
- EXPECT_TRUE(controller()->IsRevealed());
- MoveMouse(find_bar_bounds.x() + 25, find_bar_bounds.bottom() + 25);
-
- // Similar to the TopContainerView, moving the mouse slightly off vertically
- // of the find bar does not end the reveal.
- AttemptReveal(MODALITY_MOUSE);
- MoveMouse(find_bar_bounds.x() + 25, find_bar_bounds.bottom() + 1);
- EXPECT_TRUE(controller()->IsRevealed());
-
- // Similar to the TopContainerView, clicking the mouse even slightly off of
- // the find bar ends the reveal.
- GetEventGenerator().ClickLeftButton();
- EXPECT_FALSE(controller()->IsRevealed());
-
- // Set the find bar bounds to empty. Hovering over the position previously
- // occupied by the find bar, |over_find_bar|, should end the reveal.
- controller()->OnFindBarVisibleBoundsChanged(gfx::Rect());
- AttemptReveal(MODALITY_MOUSE);
- MoveMouse(over_find_bar.x(), over_find_bar.y());
- EXPECT_FALSE(controller()->IsRevealed());
-}
-
// Test behavior when the mouse becomes hovered without moving.
-TEST_F(ImmersiveModeControllerAshTest, MouseHoveredWithoutMoving) {
+TEST_F(ImmersiveFullscreenControllerTest, MouseHoveredWithoutMoving) {
controller()->SetEnabled(true);
scoped_ptr<ImmersiveRevealedLock> lock;
@@ -541,7 +509,7 @@ TEST_F(ImmersiveModeControllerAshTest, MouseHoveredWithoutMoving) {
SetHovered(true);
EXPECT_FALSE(controller()->IsRevealed());
lock.reset(controller()->GetRevealedLock(
- ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
EXPECT_TRUE(controller()->IsRevealed());
lock.reset();
EXPECT_TRUE(controller()->IsRevealed());
@@ -549,7 +517,7 @@ TEST_F(ImmersiveModeControllerAshTest, MouseHoveredWithoutMoving) {
EXPECT_FALSE(controller()->IsRevealed());
// 2) Test that if the mouse becomes hovered without moving because of a
- // reveal in ImmersiveModeControllerAshTest::controller()->SetEnabled(true)
+ // reveal in ImmersiveFullscreenController::controller()->SetEnabled(true)
// and there are no locks keeping the top-of-window views revealed, that mouse
// hover does not prevent the top-of-window views from closing.
controller()->SetEnabled(false);
@@ -559,14 +527,14 @@ TEST_F(ImmersiveModeControllerAshTest, MouseHoveredWithoutMoving) {
EXPECT_FALSE(controller()->IsRevealed());
// 3) Test that if the mouse becomes hovered without moving because of a
- // reveal in ImmersiveModeControllerAshTest::controller()->SetEnabled(true)
+ // reveal in ImmersiveFullscreenController::controller()->SetEnabled(true)
// and there is a lock keeping the top-of-window views revealed, that the
// top-of-window views do not hide till the mouse moves off of the
// top-of-window views.
controller()->SetEnabled(false);
SetHovered(true);
lock.reset(controller()->GetRevealedLock(
- ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
EXPECT_FALSE(controller()->IsRevealed());
controller()->SetEnabled(true);
EXPECT_TRUE(controller()->IsRevealed());
@@ -580,7 +548,7 @@ TEST_F(ImmersiveModeControllerAshTest, MouseHoveredWithoutMoving) {
// the reveal via another. For instance, initiating the reveal via a SWIPE_OPEN
// edge gesture, switching to using the mouse and ending the reveal by moving
// the mouse off of the top-of-window views.
-TEST_F(ImmersiveModeControllerAshTest, DifferentModalityEnterExit) {
+TEST_F(ImmersiveFullscreenControllerTest, DifferentModalityEnterExit) {
controller()->SetEnabled(true);
EXPECT_TRUE(controller()->IsEnabled());
EXPECT_FALSE(controller()->IsRevealed());
@@ -613,7 +581,7 @@ TEST_F(ImmersiveModeControllerAshTest, DifferentModalityEnterExit) {
}
// Test when the SWIPE_CLOSE edge gesture closes the top-of-window views.
-TEST_F(ImmersiveModeControllerAshTest, EndRevealViaGesture) {
+TEST_F(ImmersiveFullscreenControllerTest, EndRevealViaGesture) {
controller()->SetEnabled(true);
EXPECT_TRUE(controller()->IsEnabled());
EXPECT_FALSE(controller()->IsRevealed());
@@ -631,7 +599,7 @@ TEST_F(ImmersiveModeControllerAshTest, EndRevealViaGesture) {
// end the reveal.
AttemptReveal(MODALITY_MOUSE);
scoped_ptr<ImmersiveRevealedLock> lock(controller()->GetRevealedLock(
- ImmersiveModeController::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
EXPECT_TRUE(controller()->IsRevealed());
AttemptUnreveal(MODALITY_GESTURE);
EXPECT_TRUE(controller()->IsRevealed());
@@ -645,7 +613,7 @@ TEST_F(ImmersiveModeControllerAshTest, EndRevealViaGesture) {
// Test how focus and activation affects whether the top-of-window views are
// revealed.
-TEST_F(ImmersiveModeControllerAshTest, Focus) {
+TEST_F(ImmersiveFullscreenControllerTest, Focus) {
// Add views to the view hierarchy which we will focus and unfocus during the
// test.
views::View* child_view = new views::View();
@@ -699,7 +667,7 @@ TEST_F(ImmersiveModeControllerAshTest, Focus) {
EXPECT_TRUE(controller()->IsRevealed());
controller()->SetEnabled(false);
scoped_ptr<ImmersiveRevealedLock> lock(controller()->GetRevealedLock(
- ImmersiveModeController::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
EXPECT_FALSE(controller()->IsRevealed());
unrelated_view->RequestFocus();
controller()->SetEnabled(true);
@@ -710,8 +678,8 @@ TEST_F(ImmersiveModeControllerAshTest, Focus) {
// Test how activation affects whether the top-of-window views are revealed.
// The behavior when a bubble is activated is tested in
-// ImmersiveModeControllerAshTest.Bubbles.
-TEST_F(ImmersiveModeControllerAshTest, Activation) {
+// ImmersiveFullscreenControllerTest.Bubbles.
+TEST_F(ImmersiveFullscreenControllerTest, Activation) {
views::Widget* top_container_widget = top_container()->GetWidget();
controller()->SetEnabled(true);
@@ -758,7 +726,7 @@ TEST_F(ImmersiveModeControllerAshTest, Activation) {
}
// Test how bubbles affect whether the top-of-window views are revealed.
-TEST_F(ImmersiveModeControllerAshTest, Bubbles) {
+TEST_F(ImmersiveFullscreenControllerTest, Bubbles) {
scoped_ptr<ImmersiveRevealedLock> revealed_lock;
views::Widget* top_container_widget = top_container()->GetWidget();
@@ -785,7 +753,7 @@ TEST_F(ImmersiveModeControllerAshTest, Bubbles) {
top_container_widget->Activate();
AttemptReveal(MODALITY_MOUSE);
revealed_lock.reset(controller()->GetRevealedLock(
- ImmersiveModeController::ANIMATE_REVEAL_NO));
+ ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
EXPECT_TRUE(controller()->IsRevealed());
views::Widget* bubble_widget2 = views::BubbleDelegateView::CreateBubble(
@@ -887,213 +855,26 @@ TEST_F(ImmersiveModeControllerAshTest, Bubbles) {
#endif // defined(OS_WIN)
-class ImmersiveModeControllerAshTestWithBrowserView
- : public TestWithBrowserView {
- public:
- ImmersiveModeControllerAshTestWithBrowserView() {}
- virtual ~ImmersiveModeControllerAshTestWithBrowserView() {}
-
- // TestWithBrowserView override:
- virtual void SetUp() OVERRIDE {
- TestWithBrowserView::SetUp();
-
- browser()->window()->Show();
-
- controller_ = browser_view()->immersive_mode_controller();
- controller_->SetupForTest();
- }
-
- // Returns the bounds of |view| in widget coordinates.
- gfx::Rect GetBoundsInWidget(views::View* view) {
- return view->ConvertRectToWidget(view->GetLocalBounds());
- }
-
- // Toggle the browser's fullscreen state.
- void ToggleFullscreen() {
- // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. The notification
- // is used to trigger changes in whether the shelf is auto hidden and
- // whether a "light bar" version of the tab strip is used when the
- // top-of-window views are hidden.
- scoped_ptr<FullscreenNotificationObserver> waiter(
- new FullscreenNotificationObserver());
- chrome::ToggleFullscreenMode(browser());
- waiter->Wait();
- }
-
- // Set whether the browser is in tab fullscreen.
- void SetTabFullscreen(bool tab_fullscreen) {
- content::WebContents* web_contents =
- browser_view()->GetContentsWebViewForTest()->GetWebContents();
- scoped_ptr<FullscreenNotificationObserver> waiter(
- new FullscreenNotificationObserver());
- browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
- web_contents, tab_fullscreen);
- waiter->Wait();
- }
-
- // Attempt revealing the top-of-window views.
- void AttemptReveal() {
- if (!revealed_lock_.get()) {
- revealed_lock_.reset(controller_->GetRevealedLock(
- ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO));
- }
- }
-
- // Attempt unrevealing the top-of-window views.
- void AttemptUnreveal() {
- revealed_lock_.reset();
- }
-
- ImmersiveModeController* controller() { return controller_; }
-
- private:
- // Not owned.
- ImmersiveModeController* controller_;
-
- scoped_ptr<ImmersiveRevealedLock> revealed_lock_;
-
- DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestWithBrowserView);
-};
-
-// Test the layout and visibility of the tabstrip, toolbar and TopContainerView
-// in immersive fullscreen.
-TEST_F(ImmersiveModeControllerAshTestWithBrowserView, Layout) {
- AddTab(browser(), GURL("about:blank"));
-
- TabStrip* tabstrip = browser_view()->tabstrip();
- ToolbarView* toolbar = browser_view()->toolbar();
- views::WebView* contents_web_view =
- browser_view()->GetContentsWebViewForTest();
-
- // Immersive fullscreen starts out disabled.
- ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen());
- ASSERT_FALSE(controller()->IsEnabled());
-
- // By default, the tabstrip and toolbar should be visible.
- EXPECT_TRUE(tabstrip->visible());
- EXPECT_TRUE(toolbar->visible());
-
- ToggleFullscreen();
- EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen());
- EXPECT_TRUE(controller()->IsEnabled());
- EXPECT_FALSE(controller()->IsRevealed());
-
- // Entering immersive fullscreen should make the tab strip use the immersive
- // style and hide the toolbar.
- EXPECT_TRUE(tabstrip->visible());
- EXPECT_TRUE(tabstrip->IsImmersiveStyle());
- EXPECT_FALSE(toolbar->visible());
-
- // The tab indicators should be flush with the top of the widget.
- EXPECT_EQ(0, GetBoundsInWidget(tabstrip).y());
-
- // The web contents should be immediately below the tab indicators.
- EXPECT_EQ(Tab::GetImmersiveHeight(),
- GetBoundsInWidget(contents_web_view).y());
-
- // Revealing the top-of-window views should set the tab strip back to the
- // normal style and show the toolbar.
- AttemptReveal();
- EXPECT_TRUE(controller()->IsRevealed());
- EXPECT_TRUE(tabstrip->visible());
- EXPECT_FALSE(tabstrip->IsImmersiveStyle());
- EXPECT_TRUE(toolbar->visible());
-
- // The TopContainerView should be flush with the top edge of the widget. If
- // it is not flush with the top edge the immersive reveal animation looks
- // wonky.
- EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y());
-
- // The web contents should be at the same y position as they were when the
- // top-of-window views were hidden.
- EXPECT_EQ(Tab::GetImmersiveHeight(),
- GetBoundsInWidget(contents_web_view).y());
-
- // Repeat the test for when in both immersive fullscreen and tab fullscreen.
- SetTabFullscreen(true);
- // Hide and reveal the top-of-window views so that they get relain out.
- AttemptUnreveal();
- AttemptReveal();
-
- // The tab strip and toolbar should still be visible and the TopContainerView
- // should still be flush with the top edge of the widget.
- EXPECT_TRUE(controller()->IsRevealed());
- EXPECT_TRUE(tabstrip->visible());
- EXPECT_FALSE(tabstrip->IsImmersiveStyle());
- EXPECT_TRUE(toolbar->visible());
- EXPECT_EQ(0, GetBoundsInWidget(browser_view()->top_container()).y());
-
- // The web contents should be flush with the top edge of the widget when in
- // both immersive and tab fullscreen.
- EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
-
- // Hide the top-of-window views. Both the tab strip and the toolbar should
- // hide when in both immersive and tab fullscreen.
- AttemptUnreveal();
- EXPECT_FALSE(controller()->IsRevealed());
- EXPECT_FALSE(tabstrip->visible());
- EXPECT_FALSE(toolbar->visible());
-
- // The web contents should still be flush with the edge of the widget.
- EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
-
- // Exiting both immersive and tab fullscreen should show the tab strip and
- // toolbar.
- ToggleFullscreen();
- EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen());
- EXPECT_FALSE(controller()->IsEnabled());
- EXPECT_FALSE(controller()->IsRevealed());
- EXPECT_TRUE(tabstrip->visible());
- EXPECT_FALSE(tabstrip->IsImmersiveStyle());
- EXPECT_TRUE(toolbar->visible());
-}
-
-// Test that the browser commands which are usually disabled in fullscreen are
-// are enabled in immersive fullscreen.
-TEST_F(ImmersiveModeControllerAshTestWithBrowserView, EnabledCommands) {
- ASSERT_FALSE(controller()->IsEnabled());
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL));
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION));
-
- ToggleFullscreen();
- EXPECT_TRUE(controller()->IsEnabled());
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL));
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
- EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION));
-}
-
-// Test that restoring a window properly exits immersive fullscreen.
-TEST_F(ImmersiveModeControllerAshTestWithBrowserView, ExitUponRestore) {
- ASSERT_FALSE(controller()->IsEnabled());
- ToggleFullscreen();
- AttemptReveal();
- ASSERT_TRUE(controller()->IsEnabled());
- ASSERT_TRUE(controller()->IsRevealed());
- ASSERT_TRUE(browser_view()->GetWidget()->IsFullscreen());
-
- browser_view()->GetWidget()->Restore();
- EXPECT_FALSE(controller()->IsEnabled());
-}
-
// Test that the shelf is set to auto hide as long as the window is in
// immersive fullscreen and that the shelf's state before entering immersive
// fullscreen is restored upon exiting immersive fullscreen.
-TEST_F(ImmersiveModeControllerAshTestWithBrowserView, Shelf) {
- // Shelf is visible when the test starts.
+TEST_F(ImmersiveFullscreenControllerTest, Shelf) {
ash::internal::ShelfLayoutManager* shelf =
ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
+
+ // Shelf is visible by default.
+ window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+ ASSERT_FALSE(controller()->IsEnabled());
ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
// Entering immersive fullscreen sets the shelf to auto hide.
- ToggleFullscreen();
- ASSERT_TRUE(browser_view()->IsFullscreen());
- ASSERT_TRUE(controller()->IsEnabled());
+ window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
+ controller()->SetEnabled(true);
EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
// Disabling immersive fullscreen puts it back.
- ToggleFullscreen();
- ASSERT_FALSE(browser_view()->IsFullscreen());
+ controller()->SetEnabled(false);
+ window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
ASSERT_FALSE(controller()->IsEnabled());
EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
@@ -1102,55 +883,17 @@ TEST_F(ImmersiveModeControllerAshTestWithBrowserView, Shelf) {
EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
// Entering immersive fullscreen keeps auto-hide.
- ToggleFullscreen();
- ASSERT_TRUE(browser_view()->IsFullscreen());
- ASSERT_TRUE(controller()->IsEnabled());
+ window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
+ controller()->SetEnabled(true);
EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
// Disabling immersive fullscreen maintains the user's auto-hide selection.
- ToggleFullscreen();
- ASSERT_FALSE(browser_view()->IsFullscreen());
- ASSERT_FALSE(controller()->IsEnabled());
+ controller()->SetEnabled(false);
+ window()->SetProperty(aura::client::kShowStateKey,
+ ui::SHOW_STATE_NORMAL);
EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
}
-// Test how being simultaneously in tab fullscreen and immersive fullscreen
-// affects the shelf visibility and whether the tab indicators are hidden.
-TEST_F(ImmersiveModeControllerAshTestWithBrowserView, TabAndBrowserFullscreen) {
- AddTab(browser(), GURL("about:blank"));
-
- // The shelf should start out as visible.
- ash::internal::ShelfLayoutManager* shelf =
- ash::Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
- ASSERT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
-
- // 1) Test that entering tab fullscreen from immersive fullscreen hides the
- // tab indicators and the shelf.
- ToggleFullscreen();
- ASSERT_TRUE(controller()->IsEnabled());
- EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_FALSE(controller()->ShouldHideTabIndicators());
-
- SetTabFullscreen(true);
- ASSERT_TRUE(controller()->IsEnabled());
- EXPECT_EQ(ash::SHELF_HIDDEN, shelf->visibility_state());
- EXPECT_TRUE(controller()->ShouldHideTabIndicators());
-
- // 2) Test that exiting tab fullscreen shows the tab indicators and autohides
- // the shelf.
- SetTabFullscreen(false);
- ASSERT_TRUE(controller()->IsEnabled());
- EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
- EXPECT_FALSE(controller()->ShouldHideTabIndicators());
-
- // 3) Test that exiting tab fullscreen and immersive fullscreen
- // simultaneously correctly updates the shelf visibility and whether the tab
- // indicators should be hidden.
- SetTabFullscreen(true);
- ToggleFullscreen();
- ASSERT_FALSE(controller()->IsEnabled());
- EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
- EXPECT_TRUE(controller()->ShouldHideTabIndicators());
-}
+} // namespase ash
#endif // defined(OS_CHROMEOS)

Powered by Google App Engine
This is Rietveld 408576698