OLD | NEW |
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 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" | 5 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/screen_ash.h" |
8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
10 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
12 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 13 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
13 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" | 14 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" |
14 #include "chrome/browser/ui/immersive_fullscreen_configuration.h" | 15 #include "chrome/browser/ui/immersive_fullscreen_configuration.h" |
15 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
16 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" | 17 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" |
17 #include "chrome/browser/ui/views/frame/top_container_view.h" | 18 #include "chrome/browser/ui/views/frame/top_container_view.h" |
(...skipping 23 matching lines...) Expand all Loading... |
41 | 42 |
42 // ImmersiveModeController::Delegate overrides: | 43 // ImmersiveModeController::Delegate overrides: |
43 virtual BookmarkBarView* GetBookmarkBar() OVERRIDE { return NULL; } | 44 virtual BookmarkBarView* GetBookmarkBar() OVERRIDE { return NULL; } |
44 virtual FullscreenController* GetFullscreenController() OVERRIDE { | 45 virtual FullscreenController* GetFullscreenController() OVERRIDE { |
45 return NULL; | 46 return NULL; |
46 } | 47 } |
47 virtual void FullscreenStateChanged() OVERRIDE {} | 48 virtual void FullscreenStateChanged() OVERRIDE {} |
48 virtual void SetImmersiveStyle(bool immersive) OVERRIDE { | 49 virtual void SetImmersiveStyle(bool immersive) OVERRIDE { |
49 immersive_style_ = immersive; | 50 immersive_style_ = immersive; |
50 } | 51 } |
51 virtual content::WebContents* GetWebContents() OVERRIDE { | |
52 return NULL; | |
53 } | |
54 | 52 |
55 private: | 53 private: |
56 bool immersive_style_; | 54 bool immersive_style_; |
57 | 55 |
58 DISALLOW_COPY_AND_ASSIGN(MockImmersiveModeControllerDelegate); | 56 DISALLOW_COPY_AND_ASSIGN(MockImmersiveModeControllerDelegate); |
59 }; | 57 }; |
60 | 58 |
| 59 // View which consumes all touch events. |
| 60 class TouchEventConsumerView : public views::View { |
| 61 public: |
| 62 TouchEventConsumerView() { |
| 63 } |
| 64 virtual ~TouchEventConsumerView() { |
| 65 } |
| 66 |
| 67 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
| 68 event->SetHandled(); |
| 69 } |
| 70 private: |
| 71 DISALLOW_COPY_AND_ASSIGN(TouchEventConsumerView); |
| 72 }; |
| 73 |
61 ///////////////////////////////////////////////////////////////////////////// | 74 ///////////////////////////////////////////////////////////////////////////// |
62 | 75 |
63 class ImmersiveModeControllerAshTest : public ash::test::AshTestBase { | 76 class ImmersiveModeControllerAshTest : public ash::test::AshTestBase { |
64 public: | 77 public: |
65 enum Modality { | 78 enum Modality { |
66 MODALITY_MOUSE, | 79 MODALITY_MOUSE, |
67 MODALITY_TOUCH, | 80 MODALITY_TOUCH, |
68 MODALITY_GESTURE | 81 MODALITY_GESTURE |
69 }; | 82 }; |
70 | 83 |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 ASSERT_TRUE(browser_view()->GetWidget()->IsFullscreen()); | 981 ASSERT_TRUE(browser_view()->GetWidget()->IsFullscreen()); |
969 | 982 |
970 browser_view()->GetWidget()->Restore(); | 983 browser_view()->GetWidget()->Restore(); |
971 // Exiting immersive fullscreen occurs as a result of a task posted to the | 984 // Exiting immersive fullscreen occurs as a result of a task posted to the |
972 // message loop. | 985 // message loop. |
973 content::RunAllPendingInMessageLoop(); | 986 content::RunAllPendingInMessageLoop(); |
974 | 987 |
975 EXPECT_FALSE(controller()->IsEnabled()); | 988 EXPECT_FALSE(controller()->IsEnabled()); |
976 } | 989 } |
977 | 990 |
| 991 // Test that it is still possible to reveal and hide the top-of-window views |
| 992 // via a gesture when a child window consumes touch events. |
| 993 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, |
| 994 RevealViaGestureChildWindowConsumesTouchEvents) { |
| 995 views::Widget* browser_widget = browser_view()->GetWidget(); |
| 996 |
| 997 // Create a child widget which consumes all touch events. |
| 998 views::Widget::InitParams child_params( |
| 999 views::Widget::InitParams::TYPE_CONTROL); |
| 1000 child_params.ownership = |
| 1001 views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 1002 child_params.parent = browser_widget->GetNativeView(); |
| 1003 child_params.bounds = |
| 1004 gfx::Rect(browser_widget->GetWindowBoundsInScreen().size()); |
| 1005 scoped_ptr<views::Widget> child_widget(new views::Widget()); |
| 1006 child_widget->Init(child_params); |
| 1007 child_widget->SetContentsView(new TouchEventConsumerView()); |
| 1008 child_widget->Show(); |
| 1009 |
| 1010 ASSERT_FALSE(controller()->IsEnabled()); |
| 1011 chrome::ToggleFullscreenMode(browser()); |
| 1012 ASSERT_TRUE(controller()->IsEnabled()); |
| 1013 EXPECT_FALSE(controller()->IsRevealed()); |
| 1014 |
| 1015 gfx::Rect top_container_bounds_in_root = |
| 1016 ash::ScreenAsh::ConvertRectFromScreen( |
| 1017 browser_widget->GetNativeView()->GetRootWindow(), |
| 1018 browser_view()->top_container()->GetBoundsInScreen()); |
| 1019 |
| 1020 gfx::Point top(top_container_bounds_in_root.origin()); |
| 1021 gfx::Point bottom = top + gfx::Vector2d(0, 100); |
| 1022 aura::test::EventGenerator generator( |
| 1023 browser_widget->GetNativeView()->GetRootWindow()); |
| 1024 generator.GestureScrollSequence(top, |
| 1025 bottom, |
| 1026 base::TimeDelta::FromMilliseconds(10), |
| 1027 3); |
| 1028 EXPECT_TRUE(controller()->IsRevealed()); |
| 1029 |
| 1030 generator.GestureScrollSequence(bottom, |
| 1031 top, |
| 1032 base::TimeDelta::FromMilliseconds(10), |
| 1033 3); |
| 1034 EXPECT_FALSE(controller()->IsRevealed()); |
| 1035 } |
| 1036 |
978 #endif // defined(OS_CHROMEOS) | 1037 #endif // defined(OS_CHROMEOS) |
OLD | NEW |