OLD | NEW |
---|---|
(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 } | |
James Cook
2013/06/18 17:03:39
optional nit: These could go on one line.
| |
24 virtual ~ZoomBubbleBrowserTest() { | |
25 } | |
26 | |
27 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
28 ImmersiveFullscreenConfiguration::EnableImmersiveFullscreenForTest(); | |
James Cook
2013/06/18 17:03:39
It might be clearer to call this at the beginning
pkotwicz
2013/06/18 23:25:46
We would need to call for ImmersiveFullscreenConfi
| |
29 } | |
30 | |
31 private: | |
32 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleBrowserTest); | |
33 }; | |
34 | |
35 // Test whether the zoom bubble is anchored and whether it is visible when in | |
36 // non-immersive fullscreen. | |
37 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, NonImmersiveFullscreen) { | |
38 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); | |
39 content::WebContents* web_contents = browser_view->GetActiveWebContents(); | |
40 | |
41 // The zoom bubble should be anchored when not in fullscreen. | |
42 ZoomBubbleView::ShowBubble(web_contents, false); | |
43 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | |
44 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | |
45 EXPECT_TRUE(zoom_bubble->anchor_view()); | |
46 | |
47 // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. Wait for the | |
48 // notification before testing the zoom bubble visibility. | |
49 scoped_ptr<FullscreenNotificationObserver> waiter( | |
50 new FullscreenNotificationObserver()); | |
51 | |
52 // Entering fullscreen should close the bubble. (We enter into tab fullscreen | |
53 // here because tab fullscreen is non-immersive even when | |
54 // ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()) returns | |
55 // true. | |
56 browser()->fullscreen_controller()->ToggleFullscreenModeForTab( | |
57 web_contents, true); | |
58 waiter->Wait(); | |
59 ASSERT_FALSE(browser_view->immersive_mode_controller()->IsEnabled()); | |
60 EXPECT_FALSE(ZoomBubbleView::IsShowing()); | |
61 | |
62 // The bubble should not be anchored when it is shown in non-immersive | |
63 // fullscreen. | |
64 ZoomBubbleView::ShowBubble(web_contents, false); | |
65 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | |
66 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | |
67 EXPECT_FALSE(zoom_bubble->anchor_view()); | |
68 } | |
69 | |
70 // Immersive fullscreen is CrOS only for now. | |
71 #if defined(OS_CHROMEOS) | |
72 // Test whether the zoom bubble is anchored and whether it is visible when in | |
73 // immersive fullscreen. | |
74 IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, ImmersiveFullscreen) { | |
75 BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); | |
76 content::WebContents* web_contents = browser_view->GetActiveWebContents(); | |
77 | |
78 ASSERT_TRUE(ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()); | |
79 ImmersiveModeControllerAsh* immersive_controller = | |
80 static_cast<ImmersiveModeControllerAsh*>( | |
81 browser_view->immersive_mode_controller()); | |
82 immersive_controller->DisableAnimationsForTest(); | |
83 | |
84 // Move the mouse out of the way. | |
85 immersive_controller->SetMouseHoveredForTest(false); | |
86 | |
87 // Enter immersive fullscreen. | |
88 scoped_ptr<FullscreenNotificationObserver> waiter( | |
89 new FullscreenNotificationObserver()); | |
90 chrome::ToggleFullscreenMode(browser()); | |
91 waiter->Wait(); | |
92 ASSERT_TRUE(immersive_controller->IsEnabled()); | |
93 ASSERT_FALSE(immersive_controller->IsRevealed()); | |
94 | |
95 // The zoom bubble should not be anchored when it is shown in immersive | |
96 // fullscreen and the top-of-window views are not revealed. | |
97 ZoomBubbleView::ShowBubble(web_contents, false); | |
98 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | |
99 const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | |
100 EXPECT_FALSE(zoom_bubble->anchor_view()); | |
101 | |
102 // An immersive reveal should hide the zoom bubble. | |
103 scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock( | |
104 immersive_controller->GetRevealedLock( | |
105 ImmersiveModeController::ANIMATE_REVEAL_NO)); | |
106 ASSERT_TRUE(immersive_controller->IsRevealed()); | |
107 EXPECT_FALSE(ZoomBubbleView::IsShowing()); | |
108 | |
109 // The zoom bubble should be anchored when it is shown in immersive fullscreen | |
110 // and the top-of-window views are revealed. | |
111 ZoomBubbleView::ShowBubble(web_contents, false); | |
112 ASSERT_TRUE(ZoomBubbleView::IsShowing()); | |
113 zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); | |
114 EXPECT_TRUE(zoom_bubble->anchor_view()); | |
115 | |
116 // The top-of-window views should not hide till the zoom bubble hides. (It | |
117 // would be weird if the view to which the zoom bubble is anchored hid while | |
118 // the zoom bubble was still visible.) | |
119 immersive_reveal_lock.reset(); | |
120 EXPECT_TRUE(immersive_controller->IsRevealed()); | |
121 ZoomBubbleView::CloseBubble(); | |
122 // The zoom bubble is deleted on a task. | |
123 content::RunAllPendingInMessageLoop(); | |
124 EXPECT_FALSE(immersive_controller->IsRevealed()); | |
125 } | |
James Cook
2013/06/18 17:03:39
Nice tests.
| |
126 #endif // OS_CHROMEOS | |
OLD | NEW |