1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/ui/browser_commands.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_contents_view.h"
13 #include "ui/aura/window.h"
15 // TODO(jamescook): If immersive mode becomes popular on CrOS, consider porting
16 // it to other Aura platforms (win_aura, linux_aura). http://crbug.com/163931
17 class ImmersiveModeControllerAshTest : public InProcessBrowserTest {
19 ImmersiveModeControllerAshTest() : browser_view_(NULL), controller_(NULL) {}
20 virtual ~ImmersiveModeControllerAshTest() {}
22 BrowserView* browser_view() { return browser_view_; }
23 ImmersiveModeController* controller() { return controller_; }
25 // content::BrowserTestBase overrides:
26 virtual void SetUpOnMainThread() OVERRIDE {
27 browser_view_ = static_cast<BrowserView*>(browser()->window());
28 controller_ = browser_view_->immersive_mode_controller();
29 controller_->SetupForTest();
33 BrowserView* browser_view_;
34 ImmersiveModeController* controller_;
36 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest);
39 // Validate top container touch insets are being updated at the correct time in
41 IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerAshTest,
42 ImmersiveTopContainerInsets) {
43 content::WebContents* contents = browser_view()->GetActiveWebContents();
44 aura::Window* window = contents->GetView()->GetContentNativeView();
46 // Turning immersive mode on sets positive top touch insets on the render view
48 chrome::ToggleFullscreenMode(browser());
49 ASSERT_TRUE(browser_view()->IsFullscreen());
50 ASSERT_TRUE(controller()->IsEnabled());
51 ASSERT_FALSE(controller()->IsRevealed());
52 EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() > 0);
54 // Trigger a reveal resets insets as now the touch target for the top
55 // container is large enough.
56 scoped_ptr<ImmersiveRevealedLock> lock(controller()->GetRevealedLock(
57 ImmersiveModeController::ANIMATE_REVEAL_NO));
58 EXPECT_TRUE(controller()->IsRevealed());
59 EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() == 0);
61 // End reveal by moving the mouse off the top-of-window views. We
62 // should see the top insets being positive again to allow a bigger touch
65 EXPECT_FALSE(controller()->IsRevealed());
66 EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() > 0);
68 // Disabling immersive mode resets the top touch insets to 0.
69 chrome::ToggleFullscreenMode(browser());
70 ASSERT_FALSE(browser_view()->IsFullscreen());
71 ASSERT_FALSE(controller()->IsEnabled());
72 EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() == 0);