Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc |
| diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9b77f8971424be5e79847cc94777a68ee378fdb8 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc |
| @@ -0,0 +1,126 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| + |
| +#include "chrome/browser/ui/browser_commands.h" |
| +#include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| +#include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" |
| +#include "chrome/browser/ui/immersive_fullscreen_configuration.h" |
| +#include "chrome/browser/ui/views/frame/browser_view.h" |
| +#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "chrome/test/base/ui_test_utils.h" |
| + |
| +#if defined(OS_CHROMEOS) |
| +#include "chrome/browser/ui/views/frame/immersive_mode_controller_ash.h" |
| +#endif |
| + |
| +class ZoomBubbleBrowserTest : public InProcessBrowserTest { |
| + public: |
| + ZoomBubbleBrowserTest() { |
| + } |
|
James Cook
2013/06/18 17:03:39
optional nit: These could go on one line.
|
| + virtual ~ZoomBubbleBrowserTest() { |
| + } |
| + |
| + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| + 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
|
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ZoomBubbleBrowserTest); |
| +}; |
| + |
| +// Test whether the zoom bubble is anchored and whether it is visible when in |
| +// non-immersive fullscreen. |
| +IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, NonImmersiveFullscreen) { |
| + BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); |
| + content::WebContents* web_contents = browser_view->GetActiveWebContents(); |
| + |
| + // The zoom bubble should be anchored when not in fullscreen. |
| + ZoomBubbleView::ShowBubble(web_contents, false); |
| + ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
| + const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
| + EXPECT_TRUE(zoom_bubble->anchor_view()); |
| + |
| + // NOTIFICATION_FULLSCREEN_CHANGED is sent asynchronously. Wait for the |
| + // notification before testing the zoom bubble visibility. |
| + scoped_ptr<FullscreenNotificationObserver> waiter( |
| + new FullscreenNotificationObserver()); |
| + |
| + // Entering fullscreen should close the bubble. (We enter into tab fullscreen |
| + // here because tab fullscreen is non-immersive even when |
| + // ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()) returns |
| + // true. |
| + browser()->fullscreen_controller()->ToggleFullscreenModeForTab( |
| + web_contents, true); |
| + waiter->Wait(); |
| + ASSERT_FALSE(browser_view->immersive_mode_controller()->IsEnabled()); |
| + EXPECT_FALSE(ZoomBubbleView::IsShowing()); |
| + |
| + // The bubble should not be anchored when it is shown in non-immersive |
| + // fullscreen. |
| + ZoomBubbleView::ShowBubble(web_contents, false); |
| + ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
| + zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
| + EXPECT_FALSE(zoom_bubble->anchor_view()); |
| +} |
| + |
| +// Immersive fullscreen is CrOS only for now. |
| +#if defined(OS_CHROMEOS) |
| +// Test whether the zoom bubble is anchored and whether it is visible when in |
| +// immersive fullscreen. |
| +IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, ImmersiveFullscreen) { |
| + BrowserView* browser_view = static_cast<BrowserView*>(browser()->window()); |
| + content::WebContents* web_contents = browser_view->GetActiveWebContents(); |
| + |
| + ASSERT_TRUE(ImmersiveFullscreenConfiguration::UseImmersiveFullscreen()); |
| + ImmersiveModeControllerAsh* immersive_controller = |
| + static_cast<ImmersiveModeControllerAsh*>( |
| + browser_view->immersive_mode_controller()); |
| + immersive_controller->DisableAnimationsForTest(); |
| + |
| + // Move the mouse out of the way. |
| + immersive_controller->SetMouseHoveredForTest(false); |
| + |
| + // Enter immersive fullscreen. |
| + scoped_ptr<FullscreenNotificationObserver> waiter( |
| + new FullscreenNotificationObserver()); |
| + chrome::ToggleFullscreenMode(browser()); |
| + waiter->Wait(); |
| + ASSERT_TRUE(immersive_controller->IsEnabled()); |
| + ASSERT_FALSE(immersive_controller->IsRevealed()); |
| + |
| + // The zoom bubble should not be anchored when it is shown in immersive |
| + // fullscreen and the top-of-window views are not revealed. |
| + ZoomBubbleView::ShowBubble(web_contents, false); |
| + ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
| + const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
| + EXPECT_FALSE(zoom_bubble->anchor_view()); |
| + |
| + // An immersive reveal should hide the zoom bubble. |
| + scoped_ptr<ImmersiveRevealedLock> immersive_reveal_lock( |
| + immersive_controller->GetRevealedLock( |
| + ImmersiveModeController::ANIMATE_REVEAL_NO)); |
| + ASSERT_TRUE(immersive_controller->IsRevealed()); |
| + EXPECT_FALSE(ZoomBubbleView::IsShowing()); |
| + |
| + // The zoom bubble should be anchored when it is shown in immersive fullscreen |
| + // and the top-of-window views are revealed. |
| + ZoomBubbleView::ShowBubble(web_contents, false); |
| + ASSERT_TRUE(ZoomBubbleView::IsShowing()); |
| + zoom_bubble = ZoomBubbleView::GetZoomBubbleForTest(); |
| + EXPECT_TRUE(zoom_bubble->anchor_view()); |
| + |
| + // The top-of-window views should not hide till the zoom bubble hides. (It |
| + // would be weird if the view to which the zoom bubble is anchored hid while |
| + // the zoom bubble was still visible.) |
| + immersive_reveal_lock.reset(); |
| + EXPECT_TRUE(immersive_controller->IsRevealed()); |
| + ZoomBubbleView::CloseBubble(); |
| + // The zoom bubble is deleted on a task. |
| + content::RunAllPendingInMessageLoop(); |
| + EXPECT_FALSE(immersive_controller->IsRevealed()); |
| +} |
|
James Cook
2013/06/18 17:03:39
Nice tests.
|
| +#endif // OS_CHROMEOS |