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/location_bar/zoom_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser_commands.h" | 7 #include "chrome/browser/ui/browser_commands.h" |
8 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 8 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
9 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" | 9 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" |
10 #include "chrome/browser/ui/immersive_fullscreen_configuration.h" | 10 #include "chrome/browser/ui/immersive_fullscreen_configuration.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Test whether the zoom bubble is anchored and whether it is visible when in | 39 // Test whether the zoom bubble is anchored and whether it is visible when in |
40 // non-immersive fullscreen. | 40 // non-immersive fullscreen. |
41 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, MAYBE_NonImmersiveFullscreen) { | 41 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, MAYBE_NonImmersiveFullscreen) { |
42 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); | 42 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); |
43 content::WebContents* web_contents = browser_view->GetActiveWebContents(); | 43 content::WebContents* web_contents = browser_view->GetActiveWebContents(); |
44 | 44 |
45 // The zoom bubble should be anchored when not in fullscreen. | 45 // The zoom bubble should be anchored when not in fullscreen. |
46 ZoomBubbleView::ShowBubble(web_contents, true); | 46 ZoomBubbleView::ShowBubble(web_contents, true); |
47 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | 47 ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
48 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | 48 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
49 EXPECT_TRUE(zoom_bubble->anchor_view()); | 49 EXPECT_TRUE(zoom_bubble->GetAnchorView()); |
50 | 50 |
51 // Entering fullscreen should close the bubble. (We enter into tab fullscreen | 51 // Entering fullscreen should close the bubble. (We enter into tab fullscreen |
52 // here because tab fullscreen is non-immersive even when | 52 // here because tab fullscreen is non-immersive even when |
53 // ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()) returns | 53 // ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()) returns |
54 // true. | 54 // true. |
55 { | 55 { |
56 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. Wait for the | 56 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. Wait for the |
57 // notification before testing the zoom bubble visibility. | 57 // notification before testing the zoom bubble visibility. |
58 scoped_ptr<FullscreenNotificationObserver> waiter( | 58 scoped_ptr<FullscreenNotificationObserver> waiter( |
59 new FullscreenNotificationObserver()); | 59 new FullscreenNotificationObserver()); |
60 browser()->fullscreen_controller()->ToggleFullscreenModeForTab( | 60 browser()->fullscreen_controller()->ToggleFullscreenModeForTab( |
61 web_contents, true); | 61 web_contents, true); |
62 waiter->Wait(); | 62 waiter->Wait(); |
63 } | 63 } |
64 ASSERT_FALSE(browser_view->immersive_mode_controller()->IsEnabled()); | 64 ASSERT_FALSE(browser_view->immersive_mode_controller()->IsEnabled()); |
65 EXPECT_FALSE(ZoomBubbleView::IsShowing()); | 65 EXPECT_FALSE(ZoomBubbleView::IsShowing()); |
66 | 66 |
67 // The bubble should not be anchored when it is shown in non-immersive | 67 // The bubble should not be anchored when it is shown in non-immersive |
68 // fullscreen. | 68 // fullscreen. |
69 ZoomBubbleView::ShowBubble(web_contents, true); | 69 ZoomBubbleView::ShowBubble(web_contents, true); |
70 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | 70 ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
71 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | 71 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
72 EXPECT_FALSE(zoom_bubble->anchor_view()); | 72 EXPECT_FALSE(zoom_bubble->GetAnchorView()); |
73 | 73 |
74 // Exit fullscreen before ending the test for the sake of sanity. | 74 // Exit fullscreen before ending the test for the sake of sanity. |
75 { | 75 { |
76 scoped_ptr<FullscreenNotificationObserver> waiter( | 76 scoped_ptr<FullscreenNotificationObserver> waiter( |
77 new FullscreenNotificationObserver()); | 77 new FullscreenNotificationObserver()); |
78 chrome::ToggleFullscreenMode(browser()); | 78 chrome::ToggleFullscreenMode(browser()); |
79 waiter->Wait(); | 79 waiter->Wait(); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
(...skipping 22 matching lines...) Expand all Loading... |
105 waiter->Wait(); | 105 waiter->Wait(); |
106 } | 106 } |
107 ASSERT_TRUE(immersive_controller->IsEnabled()); | 107 ASSERT_TRUE(immersive_controller->IsEnabled()); |
108 ASSERT_FALSE(immersive_controller->IsRevealed()); | 108 ASSERT_FALSE(immersive_controller->IsRevealed()); |
109 | 109 |
110 // The zoom bubble should not be anchored when it is shown in immersive | 110 // The zoom bubble should not be anchored when it is shown in immersive |
111 // fullscreen and the top-of-window views are not revealed. | 111 // fullscreen and the top-of-window views are not revealed. |
112 ZoomBubbleView::ShowBubble(web_contents, true); | 112 ZoomBubbleView::ShowBubble(web_contents, true); |
113 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | 113 ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
114 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | 114 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
115 EXPECT_FALSE(zoom_bubble->anchor_view()); | 115 EXPECT_FALSE(zoom_bubble->GetAnchorView()); |
116 | 116 |
117 // An immersive reveal should hide the zoom bubble. | 117 // An immersive reveal should hide the zoom bubble. |
118 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock( | 118 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock( |
119 immersive_controller->GetRevealedLock( | 119 immersive_controller->GetRevealedLock( |
120 ImmersiveModeController::ANIMATE_REVEAL_NO)); | 120 ImmersiveModeController::ANIMATE_REVEAL_NO)); |
121 ASSERT_TRUE(immersive_controller->IsRevealed()); | 121 ASSERT_TRUE(immersive_controller->IsRevealed()); |
122 EXPECT_FALSE(ZoomBubbleView::IsShowing()); | 122 EXPECT_FALSE(ZoomBubbleView::IsShowing()); |
123 | 123 |
124 // The zoom bubble should be anchored when it is shown in immersive fullscreen | 124 // The zoom bubble should be anchored when it is shown in immersive fullscreen |
125 // and the top-of-window views are revealed. | 125 // and the top-of-window views are revealed. |
126 ZoomBubbleView::ShowBubble(web_contents, true); | 126 ZoomBubbleView::ShowBubble(web_contents, true); |
127 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | 127 ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
128 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | 128 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
129 EXPECT_TRUE(zoom_bubble->anchor_view()); | 129 EXPECT_TRUE(zoom_bubble->GetAnchorView()); |
130 | 130 |
131 // The top-of-window views should not hide till the zoom bubble hides. (It | 131 // The top-of-window views should not hide till the zoom bubble hides. (It |
132 // would be weird if the view to which the zoom bubble is anchored hid while | 132 // would be weird if the view to which the zoom bubble is anchored hid while |
133 // the zoom bubble was still visible.) | 133 // the zoom bubble was still visible.) |
134 immersive_reveal_lock.reset(); | 134 immersive_reveal_lock.reset(); |
135 EXPECT_TRUE(immersive_controller->IsRevealed()); | 135 EXPECT_TRUE(immersive_controller->IsRevealed()); |
136 ZoomBubbleView::CloseBubble(); | 136 ZoomBubbleView::CloseBubble(); |
137 // The zoom bubble is deleted on a task. | 137 // The zoom bubble is deleted on a task. |
138 content::RunAllPendingInMessageLoop(); | 138 content::RunAllPendingInMessageLoop(); |
139 EXPECT_FALSE(immersive_controller->IsRevealed()); | 139 EXPECT_FALSE(immersive_controller->IsRevealed()); |
140 | 140 |
141 // Exit fullscreen before ending the test for the sake of sanity. | 141 // Exit fullscreen before ending the test for the sake of sanity. |
142 { | 142 { |
143 scoped_ptr<FullscreenNotificationObserver> waiter( | 143 scoped_ptr<FullscreenNotificationObserver> waiter( |
144 new FullscreenNotificationObserver()); | 144 new FullscreenNotificationObserver()); |
145 chrome::ToggleFullscreenMode(browser()); | 145 chrome::ToggleFullscreenMode(browser()); |
146 waiter->Wait(); | 146 waiter->Wait(); |
147 } | 147 } |
148 } | 148 } |
149 #endif // OS_CHROMEOS | 149 #endif // OS_CHROMEOS |
OLD | NEW |