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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 gfx::Rect GetBoundsInWidget(views::View* view) { | 46 gfx::Rect GetBoundsInWidget(views::View* view) { |
47 return view->ConvertRectToWidget(view->GetLocalBounds()); | 47 return view->ConvertRectToWidget(view->GetLocalBounds()); |
48 } | 48 } |
49 | 49 |
50 // Toggle the browser's fullscreen state. | 50 // Toggle the browser's fullscreen state. |
51 void ToggleFullscreen() { | 51 void ToggleFullscreen() { |
52 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. The notification | 52 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. The notification |
53 // is used to trigger changes in whether the shelf is auto hidden and | 53 // is used to trigger changes in whether the shelf is auto hidden and |
54 // whether a "light bar" version of the tab strip is used when the | 54 // whether a "light bar" version of the tab strip is used when the |
55 // top-of-window views are hidden. | 55 // top-of-window views are hidden. |
56 scoped_ptr<FullscreenNotificationObserver> waiter( | 56 std::unique_ptr<FullscreenNotificationObserver> waiter( |
57 new FullscreenNotificationObserver()); | 57 new FullscreenNotificationObserver()); |
58 chrome::ToggleFullscreenMode(browser()); | 58 chrome::ToggleFullscreenMode(browser()); |
59 waiter->Wait(); | 59 waiter->Wait(); |
60 } | 60 } |
61 | 61 |
62 // Set whether the browser is in tab fullscreen. | 62 // Set whether the browser is in tab fullscreen. |
63 void SetTabFullscreen(bool tab_fullscreen) { | 63 void SetTabFullscreen(bool tab_fullscreen) { |
64 content::WebContents* web_contents = | 64 content::WebContents* web_contents = |
65 browser_view()->GetContentsWebViewForTest()->GetWebContents(); | 65 browser_view()->GetContentsWebViewForTest()->GetWebContents(); |
66 scoped_ptr<FullscreenNotificationObserver> waiter( | 66 std::unique_ptr<FullscreenNotificationObserver> waiter( |
67 new FullscreenNotificationObserver()); | 67 new FullscreenNotificationObserver()); |
68 if (tab_fullscreen) { | 68 if (tab_fullscreen) { |
69 browser() | 69 browser() |
70 ->exclusive_access_manager() | 70 ->exclusive_access_manager() |
71 ->fullscreen_controller() | 71 ->fullscreen_controller() |
72 ->EnterFullscreenModeForTab(web_contents, GURL()); | 72 ->EnterFullscreenModeForTab(web_contents, GURL()); |
73 } else { | 73 } else { |
74 browser() | 74 browser() |
75 ->exclusive_access_manager() | 75 ->exclusive_access_manager() |
76 ->fullscreen_controller() | 76 ->fullscreen_controller() |
(...skipping 14 matching lines...) Expand all Loading... |
91 void AttemptUnreveal() { | 91 void AttemptUnreveal() { |
92 revealed_lock_.reset(); | 92 revealed_lock_.reset(); |
93 } | 93 } |
94 | 94 |
95 ImmersiveModeController* controller() { return controller_; } | 95 ImmersiveModeController* controller() { return controller_; } |
96 | 96 |
97 private: | 97 private: |
98 // Not owned. | 98 // Not owned. |
99 ImmersiveModeController* controller_; | 99 ImmersiveModeController* controller_; |
100 | 100 |
101 scoped_ptr<ImmersiveRevealedLock> revealed_lock_; | 101 std::unique_ptr<ImmersiveRevealedLock> revealed_lock_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest); | 103 DISALLOW_COPY_AND_ASSIGN(ImmersiveModeControllerAshTest); |
104 }; | 104 }; |
105 | 105 |
106 // Test the layout and visibility of the tabstrip, toolbar and TopContainerView | 106 // Test the layout and visibility of the tabstrip, toolbar and TopContainerView |
107 // in immersive fullscreen. | 107 // in immersive fullscreen. |
108 TEST_F(ImmersiveModeControllerAshTest, Layout) { | 108 TEST_F(ImmersiveModeControllerAshTest, Layout) { |
109 AddTab(browser(), GURL("about:blank")); | 109 AddTab(browser(), GURL("about:blank")); |
110 | 110 |
111 TabStrip* tabstrip = browser_view()->tabstrip(); | 111 TabStrip* tabstrip = browser_view()->tabstrip(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 // Exit immersive fullscreen. The web contents should be back below the window | 350 // Exit immersive fullscreen. The web contents should be back below the window |
351 // header. | 351 // header. |
352 ToggleFullscreen(); | 352 ToggleFullscreen(); |
353 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); | 353 EXPECT_FALSE(browser_view()->GetWidget()->IsFullscreen()); |
354 EXPECT_FALSE(controller()->IsEnabled()); | 354 EXPECT_FALSE(controller()->IsEnabled()); |
355 EXPECT_FALSE(tabstrip->visible()); | 355 EXPECT_FALSE(tabstrip->visible()); |
356 EXPECT_FALSE(toolbar->visible()); | 356 EXPECT_FALSE(toolbar->visible()); |
357 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y()); | 357 EXPECT_EQ(header_height, GetBoundsInWidget(contents_web_view).y()); |
358 } | 358 } |
OLD | NEW |