Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(760)

Side by Side Diff: chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc

Issue 16998006: Add handling for immersive fullscreen to the zoom bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ZoomBubbleBrowserTest.NonImmersiveFullscreen Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/location_bar/zoom_bubble_view.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
6
7 #include "chrome/browser/ui/browser_commands.h"
8 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
9 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
10 #include "chrome/browser/ui/immersive_fullscreen_configuration.h"
11 #include "chrome/browser/ui/views/frame/browser_view.h"
12 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
15
16 #if defined(OS_CHROMEOS)
17 #include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h"
18 #endif
19
20 class ZoomBubbleBrowserTest : public InProcessBrowserTest {
21 public:
22 ZoomBubbleBrowserTest() {}
23 virtual ~ZoomBubbleBrowserTest() {}
24
25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
26 ImmersiveFullscreenConfiguration::EnableImmersiveFullscreenForTest();
27 }
28
29 private:
30 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleBrowserTest);
31 };
32
33 // TODO(linux_aura) http://crbug.com/163931
34 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
35 #define MAYBE_NonImmersiveFullscreen DISABLED_NonImmersiveFullscreen
36 #else
37 #define MAYBE_NonImmersiveFullscreen NonImmersiveFullscreen
38 #endif
39 // Test whether the zoom bubble is anchored and whether it is visible when in
40 // non-immersive fullscreen.
41 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, MAYBE_NonImmersiveFullscreen) {
42 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
43 content::WebContents* web_contents = browser_view->GetActiveWebContents();
44
45 // The zoom bubble should be anchored when not in fullscreen.
46 ZoomBubbleView::ShowBubble(web_contents, false);
47 ASSERT_TRUE(ZoomBubbleView::IsShowing());
48 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest();
49 EXPECT_TRUE(zoom_bubble->anchor_view());
50
51 #if defined(OS_CHROMEOS)
52 // Switching to tab fullscreen while having the zoom bubble open triggers a
53 // DCHECK in WorkspaceManager::ReparentWindow() during the test but not in
54 // when running chrome.
55 // TODO(pkotwicz): Investigate DCHECK.
56 ZoomBubbleView::CloseBubble();
57 // The zoom bubble is deleted on a task.
58 content::RunAllPendingInMessageLoop();
59 #endif
60
61 // Entering fullscreen should close the bubble. (We enter into tab fullscreen
62 // here because tab fullscreen is non-immersive even when
63 // ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()) returns
64 // true.
65 {
66 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. Wait for the
67 // notification before testing the zoom bubble visibility.
68 scoped_ptr<FullscreenNotificationObserver> waiter(
69 new FullscreenNotificationObserver());
70 browser()->fullscreen_controller()->ToggleFullscreenModeForTab(
71 web_contents, true);
72 waiter->Wait();
73 }
74 ASSERT_FALSE(browser_view->immersive_mode_controller()->IsEnabled());
75 EXPECT_FALSE(ZoomBubbleView::IsShowing());
76
77 // The bubble should not be anchored when it is shown in non-immersive
78 // fullscreen.
79 ZoomBubbleView::ShowBubble(web_contents, false);
80 ASSERT_TRUE(ZoomBubbleView::IsShowing());
81 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest();
82 EXPECT_FALSE(zoom_bubble->anchor_view());
83
84 // Exit fullscreen before ending the test for the sake of sanity.
85 {
86 scoped_ptr<FullscreenNotificationObserver> waiter(
87 new FullscreenNotificationObserver());
88 chrome::ToggleFullscreenMode(browser());
89 waiter->Wait();
90 }
91 }
92
93 // Immersive fullscreen is CrOS only for now.
94 #if defined(OS_CHROMEOS)
95 // Test whether the zoom bubble is anchored and whether it is visible when in
96 // immersive fullscreen.
97 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, ImmersiveFullscreen) {
98 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
99 content::WebContents* web_contents = browser_view->GetActiveWebContents();
100
101 ASSERT_TRUE(ImmersiveFullscreenConfiguration::UseImmersiveFullscreen());
102 ImmersiveModeControllerAsh* immersive_controller =
103 static_cast<ImmersiveModeControllerAsh*>(
104 browser_view->immersive_mode_controller());
105 immersive_controller->DisableAnimationsForTest();
106
107 // Move the mouse out of the way.
108 immersive_controller->SetMouseHoveredForTest(false);
109
110 // Enter immersive fullscreen.
111 {
112 scoped_ptr<FullscreenNotificationObserver> waiter(
113 new FullscreenNotificationObserver());
114 chrome::ToggleFullscreenMode(browser());
115 waiter->Wait();
116 }
117 ASSERT_TRUE(immersive_controller->IsEnabled());
118 ASSERT_FALSE(immersive_controller->IsRevealed());
119
120 // The zoom bubble should not be anchored when it is shown in immersive
121 // fullscreen and the top-of-window views are not revealed.
122 ZoomBubbleView::ShowBubble(web_contents, false);
123 ASSERT_TRUE(ZoomBubbleView::IsShowing());
124 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest();
125 EXPECT_FALSE(zoom_bubble->anchor_view());
126
127 // An immersive reveal should hide the zoom bubble.
128 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock(
129 immersive_controller->GetRevealedLock(
130 ImmersiveModeController::ANIMATE_REVEAL_NO));
131 ASSERT_TRUE(immersive_controller->IsRevealed());
132 EXPECT_FALSE(ZoomBubbleView::IsShowing());
133
134 // The zoom bubble should be anchored when it is shown in immersive fullscreen
135 // and the top-of-window views are revealed.
136 ZoomBubbleView::ShowBubble(web_contents, false);
137 ASSERT_TRUE(ZoomBubbleView::IsShowing());
138 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest();
139 EXPECT_TRUE(zoom_bubble->anchor_view());
140
141 // The top-of-window views should not hide till the zoom bubble hides. (It
142 // would be weird if the view to which the zoom bubble is anchored hid while
143 // the zoom bubble was still visible.)
144 immersive_reveal_lock.reset();
145 EXPECT_TRUE(immersive_controller->IsRevealed());
146 ZoomBubbleView::CloseBubble();
147 // The zoom bubble is deleted on a task.
148 content::RunAllPendingInMessageLoop();
149 EXPECT_FALSE(immersive_controller->IsRevealed());
150
151 // Exit fullscreen before ending the test for the sake of sanity.
152 {
153 scoped_ptr<FullscreenNotificationObserver> waiter(
154 new FullscreenNotificationObserver());
155 chrome::ToggleFullscreenMode(browser());
156 waiter->Wait();
157 }
158 }
159 #endif // OS_CHROMEOS
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/zoom_bubble_view.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698