Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / immersive_mode_controller_ash_browsertest.cc
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.
4
5 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
6
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"
14
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 {
18  public:
19   ImmersiveModeControllerAshTest() : browser_view_(NULL), controller_(NULL) {}
20   virtual ~ImmersiveModeControllerAshTest() {}
21
22   BrowserView* browser_view() { return browser_view_; }
23   ImmersiveModeController* controller() { return controller_; }
24
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();
30   }
31
32  private:
33   BrowserView* browser_view_;
34   ImmersiveModeController* controller_;
35
36   DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest);
37 };
38
39 // Validate top container touch insets are being updated at the correct time in
40 // immersive mode.
41 IN_PROC_BROWSER_TEST_F(ImmersiveModeControllerAshTest,
42                        ImmersiveTopContainerInsets) {
43   content::WebContents* contents = browser_view()->GetActiveWebContents();
44   aura::Window* window = contents->GetView()->GetContentNativeView();
45
46   // Turning immersive mode on sets positive top touch insets on the render view
47   // window.
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);
53
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);
60
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
63   // target.
64   lock.reset();
65   EXPECT_FALSE(controller()->IsRevealed());
66   EXPECT_TRUE(window->hit_test_bounds_override_outer_touch().top() > 0);
67
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);
73 }