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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" | 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #else | 25 #else |
26 #define MAYBE_NonImmersiveFullscreen NonImmersiveFullscreen | 26 #define MAYBE_NonImmersiveFullscreen NonImmersiveFullscreen |
27 #endif | 27 #endif |
28 // Test whether the zoom bubble is anchored and whether it is visible when in | 28 // Test whether the zoom bubble is anchored and whether it is visible when in |
29 // non-immersive fullscreen. | 29 // non-immersive fullscreen. |
30 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, MAYBE_NonImmersiveFullscreen) { | 30 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, MAYBE_NonImmersiveFullscreen) { |
31 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); | 31 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); |
32 content::WebContents* web_contents = browser_view->GetActiveWebContents(); | 32 content::WebContents* web_contents = browser_view->GetActiveWebContents(); |
33 | 33 |
34 // The zoom bubble should be anchored when not in fullscreen. | 34 // The zoom bubble should be anchored when not in fullscreen. |
35 ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC); | 35 ZoomBubbleView::ShowBubble(web_contents, gfx::Point(), |
| 36 ZoomBubbleView::AUTOMATIC); |
36 ASSERT_TRUE(ZoomBubbleView::GetZoomBubble()); | 37 ASSERT_TRUE(ZoomBubbleView::GetZoomBubble()); |
37 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubble(); | 38 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubble(); |
38 EXPECT_TRUE(zoom_bubble->GetAnchorView()); | 39 EXPECT_TRUE(zoom_bubble->GetAnchorView()); |
39 | 40 |
40 // Entering fullscreen should close the bubble. (We enter into tab fullscreen | 41 // Entering fullscreen should close the bubble. (We enter into tab fullscreen |
41 // here because tab fullscreen is non-immersive even on Chrome OS.) | 42 // here because tab fullscreen is non-immersive even on Chrome OS.) |
42 { | 43 { |
43 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. Wait for the | 44 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. Wait for the |
44 // notification before testing the zoom bubble visibility. | 45 // notification before testing the zoom bubble visibility. |
45 std::unique_ptr<FullscreenNotificationObserver> waiter( | 46 std::unique_ptr<FullscreenNotificationObserver> waiter( |
46 new FullscreenNotificationObserver()); | 47 new FullscreenNotificationObserver()); |
47 browser() | 48 browser() |
48 ->exclusive_access_manager() | 49 ->exclusive_access_manager() |
49 ->fullscreen_controller() | 50 ->fullscreen_controller() |
50 ->EnterFullscreenModeForTab(web_contents, GURL()); | 51 ->EnterFullscreenModeForTab(web_contents, GURL()); |
51 waiter->Wait(); | 52 waiter->Wait(); |
52 } | 53 } |
53 ASSERT_FALSE(browser_view->immersive_mode_controller()->IsEnabled()); | 54 ASSERT_FALSE(browser_view->immersive_mode_controller()->IsEnabled()); |
54 EXPECT_FALSE(ZoomBubbleView::GetZoomBubble()); | 55 EXPECT_FALSE(ZoomBubbleView::GetZoomBubble()); |
55 | 56 |
56 // The bubble should not be anchored when it is shown in non-immersive | 57 // The bubble should not be anchored when it is shown in non-immersive |
57 // fullscreen. | 58 // fullscreen. |
58 ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC); | 59 ZoomBubbleView::ShowBubble(web_contents, gfx::Point(), |
| 60 ZoomBubbleView::AUTOMATIC); |
59 ASSERT_TRUE(ZoomBubbleView::GetZoomBubble()); | 61 ASSERT_TRUE(ZoomBubbleView::GetZoomBubble()); |
60 zoom_bubble = ZoomBubbleView::GetZoomBubble(); | 62 zoom_bubble = ZoomBubbleView::GetZoomBubble(); |
61 EXPECT_FALSE(zoom_bubble->GetAnchorView()); | 63 EXPECT_FALSE(zoom_bubble->GetAnchorView()); |
62 | 64 |
63 // Exit fullscreen before ending the test for the sake of sanity. | 65 // Exit fullscreen before ending the test for the sake of sanity. |
64 { | 66 { |
65 std::unique_ptr<FullscreenNotificationObserver> waiter( | 67 std::unique_ptr<FullscreenNotificationObserver> waiter( |
66 new FullscreenNotificationObserver()); | 68 new FullscreenNotificationObserver()); |
67 chrome::ToggleFullscreenMode(browser()); | 69 chrome::ToggleFullscreenMode(browser()); |
68 waiter->Wait(); | 70 waiter->Wait(); |
(...skipping 21 matching lines...) Expand all Loading... |
90 std::unique_ptr<FullscreenNotificationObserver> waiter( | 92 std::unique_ptr<FullscreenNotificationObserver> waiter( |
91 new FullscreenNotificationObserver()); | 93 new FullscreenNotificationObserver()); |
92 chrome::ToggleFullscreenMode(browser()); | 94 chrome::ToggleFullscreenMode(browser()); |
93 waiter->Wait(); | 95 waiter->Wait(); |
94 } | 96 } |
95 ASSERT_TRUE(immersive_controller->IsEnabled()); | 97 ASSERT_TRUE(immersive_controller->IsEnabled()); |
96 ASSERT_FALSE(immersive_controller->IsRevealed()); | 98 ASSERT_FALSE(immersive_controller->IsRevealed()); |
97 | 99 |
98 // The zoom bubble should not be anchored when it is shown in immersive | 100 // The zoom bubble should not be anchored when it is shown in immersive |
99 // fullscreen and the top-of-window views are not revealed. | 101 // fullscreen and the top-of-window views are not revealed. |
100 ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC); | 102 ZoomBubbleView::ShowBubble(web_contents, gfx::Point(), |
| 103 ZoomBubbleView::AUTOMATIC); |
101 ASSERT_TRUE(ZoomBubbleView::GetZoomBubble()); | 104 ASSERT_TRUE(ZoomBubbleView::GetZoomBubble()); |
102 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubble(); | 105 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubble(); |
103 EXPECT_FALSE(zoom_bubble->GetAnchorView()); | 106 EXPECT_FALSE(zoom_bubble->GetAnchorView()); |
104 | 107 |
105 // An immersive reveal should hide the zoom bubble. | 108 // An immersive reveal should hide the zoom bubble. |
106 std::unique_ptr<ImmersiveRevealedLock> immersive_reveal_lock( | 109 std::unique_ptr<ImmersiveRevealedLock> immersive_reveal_lock( |
107 immersive_controller->GetRevealedLock( | 110 immersive_controller->GetRevealedLock( |
108 ImmersiveModeController::ANIMATE_REVEAL_NO)); | 111 ImmersiveModeController::ANIMATE_REVEAL_NO)); |
109 ASSERT_TRUE(immersive_controller->IsRevealed()); | 112 ASSERT_TRUE(immersive_controller->IsRevealed()); |
110 EXPECT_EQ(NULL, ZoomBubbleView::zoom_bubble_); | 113 EXPECT_EQ(NULL, ZoomBubbleView::zoom_bubble_); |
111 | 114 |
112 // The zoom bubble should be anchored when it is shown in immersive fullscreen | 115 // The zoom bubble should be anchored when it is shown in immersive fullscreen |
113 // and the top-of-window views are revealed. | 116 // and the top-of-window views are revealed. |
114 ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC); | 117 ZoomBubbleView::ShowBubble(web_contents, gfx::Point(), |
| 118 ZoomBubbleView::AUTOMATIC); |
115 zoom_bubble = ZoomBubbleView::GetZoomBubble(); | 119 zoom_bubble = ZoomBubbleView::GetZoomBubble(); |
116 ASSERT_TRUE(zoom_bubble); | 120 ASSERT_TRUE(zoom_bubble); |
117 EXPECT_TRUE(zoom_bubble->GetAnchorView()); | 121 EXPECT_TRUE(zoom_bubble->GetAnchorView()); |
118 | 122 |
119 // The top-of-window views should not hide till the zoom bubble hides. (It | 123 // The top-of-window views should not hide till the zoom bubble hides. (It |
120 // would be weird if the view to which the zoom bubble is anchored hid while | 124 // would be weird if the view to which the zoom bubble is anchored hid while |
121 // the zoom bubble was still visible.) | 125 // the zoom bubble was still visible.) |
122 immersive_reveal_lock.reset(); | 126 immersive_reveal_lock.reset(); |
123 EXPECT_TRUE(immersive_controller->IsRevealed()); | 127 EXPECT_TRUE(immersive_controller->IsRevealed()); |
124 ZoomBubbleView::CloseCurrentBubble(); | 128 ZoomBubbleView::CloseCurrentBubble(); |
125 // The zoom bubble is deleted on a task. | 129 // The zoom bubble is deleted on a task. |
126 content::RunAllPendingInMessageLoop(); | 130 content::RunAllPendingInMessageLoop(); |
127 EXPECT_FALSE(immersive_controller->IsRevealed()); | 131 EXPECT_FALSE(immersive_controller->IsRevealed()); |
128 | 132 |
129 // Exit fullscreen before ending the test for the sake of sanity. | 133 // Exit fullscreen before ending the test for the sake of sanity. |
130 { | 134 { |
131 std::unique_ptr<FullscreenNotificationObserver> waiter( | 135 std::unique_ptr<FullscreenNotificationObserver> waiter( |
132 new FullscreenNotificationObserver()); | 136 new FullscreenNotificationObserver()); |
133 chrome::ToggleFullscreenMode(browser()); | 137 chrome::ToggleFullscreenMode(browser()); |
134 waiter->Wait(); | 138 waiter->Wait(); |
135 } | 139 } |
136 } | 140 } |
137 #endif // OS_CHROMEOS | 141 #endif // OS_CHROMEOS |
OLD | NEW |