| 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/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 widget_->Show(); | 101 widget_->Show(); |
| 102 | 102 |
| 103 top_container_ = new views::View(); | 103 top_container_ = new views::View(); |
| 104 top_container_->SetBounds(0, 0, 500, 100); | 104 top_container_->SetBounds(0, 0, 500, 100); |
| 105 top_container_->set_focusable(true); | 105 top_container_->set_focusable(true); |
| 106 | 106 |
| 107 widget_->GetContentsView()->AddChildView(top_container_); | 107 widget_->GetContentsView()->AddChildView(top_container_); |
| 108 | 108 |
| 109 controller_->Init(delegate_.get(), widget_, top_container_); | 109 controller_->Init(delegate_.get(), widget_, top_container_); |
| 110 SetAnimationsDisabled(true); | 110 SetAnimationsDisabled(true); |
| 111 |
| 112 // The mouse is moved so that it is not over |top_container_| by |
| 113 // AshTestBase. |
| 111 } | 114 } |
| 112 | 115 |
| 113 // Enable or disable the immersive mode controller's animations. When the | 116 // Enable or disable the immersive mode controller's animations. When the |
| 114 // immersive mode controller's animations are disabled, some behavior is | 117 // immersive mode controller's animations are disabled, some behavior is |
| 115 // slightly different. In particular, the behavior is different when there | 118 // slightly different. In particular, the behavior is different when there |
| 116 // is a transfer in which lock keeps the top-of-window views revealed (eg | 119 // is a transfer in which lock keeps the top-of-window views revealed (eg |
| 117 // bubble keeps top-of-window views revealed -> mouse keeps top-of-window | 120 // bubble keeps top-of-window views revealed -> mouse keeps top-of-window |
| 118 // views revealed). It is necessary to temparily enable the immersive | 121 // views revealed). It is necessary to temparily enable the immersive |
| 119 // controller's animations to get the correct behavior in tests. | 122 // controller's animations to get the correct behavior in tests. |
| 120 void SetAnimationsDisabled(bool disabled) { | 123 void SetAnimationsDisabled(bool disabled) { |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 TestWithBrowserView::SetUp(); | 802 TestWithBrowserView::SetUp(); |
| 800 | 803 |
| 801 browser()->window()->Show(); | 804 browser()->window()->Show(); |
| 802 | 805 |
| 803 ImmersiveFullscreenConfiguration::EnableImmersiveFullscreenForTest(); | 806 ImmersiveFullscreenConfiguration::EnableImmersiveFullscreenForTest(); |
| 804 ASSERT_TRUE(ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()); | 807 ASSERT_TRUE(ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()); |
| 805 | 808 |
| 806 controller_ = static_cast<ImmersiveModeControllerAsh*>( | 809 controller_ = static_cast<ImmersiveModeControllerAsh*>( |
| 807 browser_view()->immersive_mode_controller()); | 810 browser_view()->immersive_mode_controller()); |
| 808 controller_->DisableAnimationsForTest(); | 811 controller_->DisableAnimationsForTest(); |
| 812 |
| 813 // Move the mouse so that it is not over the top-of-window views. The mouse |
| 814 // position matters because entering immersive fullscreen causes synthesized |
| 815 // mouse moves. (If the mouse is at the very top of the screen when entering |
| 816 // immersive fullscreen, the top-of-window views will hide, then reveal as |
| 817 // a result of the synthesized mouse moves). |
| 818 controller()->SetMouseHoveredForTest(false); |
| 809 } | 819 } |
| 810 | 820 |
| 811 // Returns the bounds of |view| in widget coordinates. | 821 // Returns the bounds of |view| in widget coordinates. |
| 812 gfx::Rect GetBoundsInWidget(views::View* view) { | 822 gfx::Rect GetBoundsInWidget(views::View* view) { |
| 813 return view->ConvertRectToWidget(view->GetLocalBounds()); | 823 return view->ConvertRectToWidget(view->GetLocalBounds()); |
| 814 } | 824 } |
| 815 | 825 |
| 816 ImmersiveModeControllerAsh* controller() { return controller_; } | 826 ImmersiveModeControllerAsh* controller() { return controller_; } |
| 817 | 827 |
| 818 private: | 828 private: |
| 819 // Not owned. | 829 // Not owned. |
| 820 ImmersiveModeControllerAsh* controller_; | 830 ImmersiveModeControllerAsh* controller_; |
| 821 | 831 |
| 822 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestWithBrowserView); | 832 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTestWithBrowserView); |
| 823 }; | 833 }; |
| 824 | 834 |
| 825 // Test the layout and visibility of the tabstrip, toolbar and TopContainerView | 835 // Test the layout and visibility of the tabstrip, toolbar and TopContainerView |
| 826 // in immersive fullscreen. | 836 // in immersive fullscreen. |
| 827 // Flaky. See http://crbug.com/302908 . | 837 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, Layout) { |
| 828 TEST_F(ImmersiveModeControllerAshTestWithBrowserView, DISABLED_Layout) { | |
| 829 AddTab(browser(), GURL("about:blank")); | 838 AddTab(browser(), GURL("about:blank")); |
| 830 | 839 |
| 831 TabStrip* tabstrip = browser_view()->tabstrip(); | 840 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 832 ToolbarView* toolbar = browser_view()->toolbar(); | 841 ToolbarView* toolbar = browser_view()->toolbar(); |
| 833 views::WebView* contents_web_view = | 842 views::WebView* contents_web_view = |
| 834 browser_view()->GetContentsWebViewForTest(); | 843 browser_view()->GetContentsWebViewForTest(); |
| 835 | 844 |
| 836 // Immersive fullscreen starts out disabled. | 845 // Immersive fullscreen starts out disabled. |
| 837 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen()); | 846 ASSERT_FALSE(browser_view()->GetWidget()->IsFullscreen()); |
| 838 ASSERT_FALSE(controller()->IsEnabled()); | 847 ASSERT_FALSE(controller()->IsEnabled()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 969 |
| 961 browser_view()->GetWidget()->Restore(); | 970 browser_view()->GetWidget()->Restore(); |
| 962 // Exiting immersive fullscreen occurs as a result of a task posted to the | 971 // Exiting immersive fullscreen occurs as a result of a task posted to the |
| 963 // message loop. | 972 // message loop. |
| 964 content::RunAllPendingInMessageLoop(); | 973 content::RunAllPendingInMessageLoop(); |
| 965 | 974 |
| 966 EXPECT_FALSE(controller()->IsEnabled()); | 975 EXPECT_FALSE(controller()->IsEnabled()); |
| 967 } | 976 } |
| 968 | 977 |
| 969 #endif // defined(OS_CHROMEOS) | 978 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |