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

Unified Diff: chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc

Issue 83343006: Enable immersive fullscreen for hosted apps part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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: chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
index a98b987481f62ed17acfd60dc7e91aabd781e0c4..6885cf7db192663121573801e0e6164a292f799f 100644
--- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
+++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash_unittest.cc
@@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// For now, immersive fullscreen is Chrome OS only.
+#if defined(OS_CHROMEOS)
+
#include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
+#include "ash/ash_switches.h"
#include "ash/root_window_controller.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 "base/command_line.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
@@ -21,8 +26,14 @@
#include "ui/aura/window.h"
#include "ui/views/controls/webview/webview.h"
-// For now, immersive fullscreen is Chrome OS only.
-#if defined(OS_CHROMEOS)
+namespace {
+
+// Returns the bounds of |view| in widget coordinates.
+gfx::Rect GetBoundsInWidget(views::View* view) {
+ return view->ConvertRectToWidget(view->GetLocalBounds());
+}
+
+} // namespace
class ImmersiveModeControllerAshTest : public TestWithBrowserView {
public:
@@ -39,11 +50,6 @@ class ImmersiveModeControllerAshTest : public TestWithBrowserView {
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
@@ -251,4 +257,98 @@ TEST_F(ImmersiveModeControllerAshTest, TabAndBrowserFullscreen) {
EXPECT_TRUE(controller()->ShouldHideTabIndicators());
}
+class ImmersiveModeControllerAshTestHostedApp : public TestWithBrowserView {
+ public:
+ ImmersiveModeControllerAshTestHostedApp() {}
+ virtual ~ImmersiveModeControllerAshTestHostedApp() {}
+
+ // TestWithBrowserView override:
+ virtual void SetUp() OVERRIDE {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ ash::switches::kAshEnableImmersiveFullscreenForAllWindows);
+
+ TestWithBrowserView::SetUp();
+ browser()->window()->Show();
+ controller_ = browser_view()->immersive_mode_controller();
+ controller_->SetupForTest();
+ }
+
+ // BrowserWithTestWindowTest override:
+ virtual void PopulateBrowserCreateParams(
+ Browser::CreateParams* params) OVERRIDE {
+ params->type = Browser::TYPE_POPUP;
+ params->app_name = "Test";
+ }
+
+ ImmersiveModeController* controller() { return controller_; }
+
+ private:
+ // Not owned.
+ ImmersiveModeController* controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestHostedApp);
+};
+
+// Test the layout and visibility of the TopContainerView and web contents when
+// a hosted app is put into immersive fullscreen.
+TEST_F(ImmersiveModeControllerAshTestHostedApp, Layout) {
+ AddTab(browser(), GURL("about:blank"));
James Cook 2013/11/25 19:09:20 You might want to comment here about how it's stil
+
+ TabStrip* tabstrip = browser_view()->tabstrip();
+ ToolbarView* toolbar = browser_view()->toolbar();
+ views::WebView* contents_web_view =
+ browser_view()->GetContentsWebViewForTest();
+ views::View* top_container = browser_view()->top_container();
+
+ // Immersive fullscreen starts out disabled.
+ ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen());
+ ASSERT_FALSE(controller()->IsEnabled());
+
+ // The tabstrip and toolbar are not visible for hosted apps.
+ EXPECT_FALSE(tabstrip->visible());
+ EXPECT_FALSE(toolbar->visible());
+
+ // The window header should be above the web contents.
+ int header_height = GetBoundsInWidget(contents_web_view).y();
+
+ chrome::ToggleFullscreenMode(browser());
+ EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen());
+ EXPECT_TRUE(controller()->IsEnabled());
+ EXPECT_FALSE(controller()->IsRevealed());
+
+ // Entering immersive fullscreen should make the web contents flush with the
+ // top of the widget.
+ EXPECT_FALSE(tabstrip->visible());
+ EXPECT_FALSE(toolbar->visible());
+ EXPECT_TRUE(top_container->GetVisibleBounds().IsEmpty());
+ EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
+
+ // Reveal the window header.
+ scoped_ptr<ImmersiveRevealedLock> revealed_lock(
+ controller()->GetRevealedLock(
+ ImmersiveModeControllerAsh::ANIMATE_REVEAL_NO));
+
+ // The tabstrip and toolbar should still be hidden and the web contents should
+ // still be flush with the top of the screen.
+ EXPECT_FALSE(tabstrip->visible());
+ EXPECT_FALSE(toolbar->visible());
+ EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
+
+ // During an immersive reveal, the window header should be painted to the
+ // TopContainerView. The TopContainerView should be flush with the top of the
+ // widget and have |header_height|.
+ gfx::Rect top_container_bounds_in_widget(GetBoundsInWidget(top_container));
+ EXPECT_EQ(0, top_container_bounds_in_widget.y());
+ EXPECT_EQ(header_height, top_container_bounds_in_widget.height());
+
+ // Exit immersive fullscreen. The web contents should be back below the window
+ // header.
+ chrome::ToggleFullscreenMode(browser());
+ EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen());
+ EXPECT_FALSE(controller()->IsEnabled());
+ EXPECT_FALSE(tabstrip->visible());
+ EXPECT_FALSE(toolbar->visible());
+ EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y());
+}
+
#endif // defined(OS_CHROMEOS)

Powered by Google App Engine
This is Rietveld 408576698