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

Side by Side 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 ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 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 // For now, immersive fullscreen is Chrome OS only.
6 #if defined(OS_CHROMEOS)
7
5 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" 8 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
6 9
10 #include "ash/ash_switches.h"
7 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
8 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shelf/shelf_types.h" 13 #include "ash/shelf/shelf_types.h"
10 #include "ash/shell.h" 14 #include "ash/shell.h"
11 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "base/command_line.h"
12 #include "chrome/app/chrome_command_ids.h" 17 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/ui/browser_commands.h" 18 #include "chrome/browser/ui/browser_commands.h"
14 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 19 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
15 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" 20 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 21 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" 22 #include "chrome/browser/ui/views/frame/test_with_browser_view.h"
18 #include "chrome/browser/ui/views/frame/top_container_view.h" 23 #include "chrome/browser/ui/views/frame/top_container_view.h"
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" 24 #include "chrome/browser/ui/views/tabs/tab_strip.h"
20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 25 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
21 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
22 #include "ui/views/controls/webview/webview.h" 27 #include "ui/views/controls/webview/webview.h"
23 28
24 // For now, immersive fullscreen is Chrome OS only.
25 #if defined(OS_CHROMEOS)
26
27 class ImmersiveModeControllerAshTest : public TestWithBrowserView { 29 class ImmersiveModeControllerAshTest : public TestWithBrowserView {
28 public: 30 public:
29 ImmersiveModeControllerAshTest() {} 31 ImmersiveModeControllerAshTest() {}
30 virtual ~ImmersiveModeControllerAshTest() {} 32 virtual ~ImmersiveModeControllerAshTest() {}
31 33
32 // TestWithBrowserView override: 34 // TestWithBrowserView override:
33 virtual void SetUp() OVERRIDE { 35 virtual void SetUp() OVERRIDE {
34 TestWithBrowserView::SetUp(); 36 TestWithBrowserView::SetUp();
35 37
36 browser()->window()->Show(); 38 browser()->window()->Show();
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // 3) Test that exiting tab fullscreen and immersive fullscreen 246 // 3) Test that exiting tab fullscreen and immersive fullscreen
245 // simultaneously correctly updates the shelf visibility and whether the tab 247 // simultaneously correctly updates the shelf visibility and whether the tab
246 // indicators should be hidden. 248 // indicators should be hidden.
247 SetTabFullscreen(true); 249 SetTabFullscreen(true);
248 ToggleFullscreen(); 250 ToggleFullscreen();
249 ASSERT_FALSE(controller()->IsEnabled()); 251 ASSERT_FALSE(controller()->IsEnabled());
250 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state()); 252 EXPECT_EQ(ash::SHELF_VISIBLE, shelf->visibility_state());
251 EXPECT_TRUE(controller()->ShouldHideTabIndicators()); 253 EXPECT_TRUE(controller()->ShouldHideTabIndicators());
252 } 254 }
253 255
256 class ImmersiveModeControllerAshTestHostedApp
257 : public ImmersiveModeControllerAshTest {
258 public:
259 ImmersiveModeControllerAshTestHostedApp() {}
260 virtual ~ImmersiveModeControllerAshTestHostedApp() {}
261
262 // ImmersiveModeControllerAshTest override:
263 virtual void SetUp() OVERRIDE {
264 CommandLine::ForCurrentProcess()->AppendSwitch(
265 ash::switches::kAshEnableImmersiveFullscreenForAllWindows);
266 ImmersiveModeControllerAshTest::SetUp();
267 }
268
269 // BrowserWithTestWindowTest override:
270 virtual Browser* CreateBrowser(Profile* profile,
271 chrome::HostDesktopType host_desktop_type,
272 BrowserWindow* browser_window) OVERRIDE {
273 Browser::CreateParams params(profile, host_desktop_type);
274 params.type = Browser::TYPE_POPUP;
275 params.app_name = "Test";
276 params.window = browser_window;
277 return new Browser(params);
278 }
279
280 private:
281 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestHostedApp);
282 };
283
284 // Test the layout and visibility of the TopContainerView and web contents when
285 // a hosted app is put into immersive fullscreen.
286 TEST_F(ImmersiveModeControllerAshTestHostedApp, Layout) {
287 // Add a tab because the browser starts out without any tabs at all.
288 AddTab(browser(), GURL("about:blank"));
289
290 TabStrip* tabstrip = browser_view()->tabstrip();
291 ToolbarView* toolbar = browser_view()->toolbar();
292 views::WebView* contents_web_view =
293 browser_view()->GetContentsWebViewForTest();
294 views::View* top_container = browser_view()->top_container();
295
296 // Immersive fullscreen starts out disabled.
297 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen());
298 ASSERT_FALSE(controller()->IsEnabled());
299
300 // The tabstrip and toolbar are not visible for hosted apps.
301 EXPECT_FALSE(tabstrip->visible());
302 EXPECT_FALSE(toolbar->visible());
303
304 // The window header should be above the web contents.
305 int header_height = GetBoundsInWidget(contents_web_view).y();
306
307 ToggleFullscreen();
308 EXPECT_TRUE(browser_view()->GetWidget()->IsFullscreen());
309 EXPECT_TRUE(controller()->IsEnabled());
310 EXPECT_FALSE(controller()->IsRevealed());
311
312 // Entering immersive fullscreen should make the web contents flush with the
313 // top of the widget.
314 EXPECT_FALSE(tabstrip->visible());
315 EXPECT_FALSE(toolbar->visible());
316 EXPECT_TRUE(top_container->GetVisibleBounds().IsEmpty());
317 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
318
319 // Reveal the window header.
320 AttemptReveal();
321
322 // The tabstrip and toolbar should still be hidden and the web contents should
323 // still be flush with the top of the screen.
324 EXPECT_FALSE(tabstrip->visible());
325 EXPECT_FALSE(toolbar->visible());
326 EXPECT_EQ(0, GetBoundsInWidget(contents_web_view).y());
327
328 // During an immersive reveal, the window header should be painted to the
329 // TopContainerView. The TopContainerView should be flush with the top of the
330 // widget and have |header_height|.
331 gfx::Rect top_container_bounds_in_widget(GetBoundsInWidget(top_container));
332 EXPECT_EQ(0, top_container_bounds_in_widget.y());
333 EXPECT_EQ(header_height, top_container_bounds_in_widget.height());
334
335 // Exit immersive fullscreen. The web contents should be back below the window
336 // header.
337 ToggleFullscreen();
338 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen());
339 EXPECT_FALSE(controller()->IsEnabled());
340 EXPECT_FALSE(tabstrip->visible());
341 EXPECT_FALSE(toolbar->visible());
342 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y());
343 }
344
254 #endif // defined(OS_CHROMEOS) 345 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc ('k') | chrome/browser/ui/views/frame/top_container_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698