diff options
| author | scheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 17:30:26 +0000 |
|---|---|---|
| committer | scheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-04 17:30:26 +0000 |
| commit | 47ea3b4c7b3779b96bfed645227b7ba8d0a66a02 (patch) | |
| tree | a129ae0f4e7a857e9a1a8b5cfeb012c513b00692 /chrome/browser/ui/fullscreen_controller_test.cc | |
| parent | c248129a848d2595bba2b685af104b7d185e71de (diff) | |
| download | chromium_src-47ea3b4c7b3779b96bfed645227b7ba8d0a66a02.zip chromium_src-47ea3b4c7b3779b96bfed645227b7ba8d0a66a02.tar.gz chromium_src-47ea3b4c7b3779b96bfed645227b7ba8d0a66a02.tar.bz2 | |
Some Mouse Lock tests require the browser to have focus, they must be run from interactive_ui_tests.
To reduce code duplication, the mouse lock and fullscreen convenience methods of the browser_browsertest have been moved to a reusable fixture in fullscreen_controller_test.
BUG=130358
Review URL: https://chromiumcodereview.appspot.com/10459063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/fullscreen_controller_test.cc')
| -rw-r--r-- | chrome/browser/ui/fullscreen_controller_test.cc | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/chrome/browser/ui/fullscreen_controller_test.cc b/chrome/browser/ui/fullscreen_controller_test.cc new file mode 100644 index 0000000..d4a67c8 --- /dev/null +++ b/chrome/browser/ui/fullscreen_controller_test.cc @@ -0,0 +1,116 @@ +// Copyright (c) 2012 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/fullscreen_controller_test.h" + +#include "base/command_line.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/fullscreen_controller.h" +#include "chrome/common/chrome_switches.h" +#include "content/public/browser/web_contents.h" + +using content::WebContents; + +const char FullscreenControllerTest::kFullscreenMouseLockHTML[] = + "files/fullscreen_mouselock/fullscreen_mouselock.html"; + +void FullscreenControllerTest::SetUpCommandLine(CommandLine* command_line) { + InProcessBrowserTest::SetUpCommandLine(command_line); + command_line->AppendSwitch(switches::kEnablePointerLock); +} + +void FullscreenControllerTest::ToggleTabFullscreen(WebContents* tab, + bool enter_fullscreen) { + if (IsFullscreenForBrowser()) { + // Changing tab fullscreen state will not actually change the window + // when browser fullscreen is in effect. + browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); + } else { // Not in browser fullscreen, expect window to actually change. + FullscreenNotificationObserver fullscreen_observer; + browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); + fullscreen_observer.Wait(); + ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); + } +} + +void FullscreenControllerTest::ToggleBrowserFullscreen(bool enter_fullscreen) { + ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); + FullscreenNotificationObserver fullscreen_observer; + + browser()->ToggleFullscreenMode(); + + fullscreen_observer.Wait(); + ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); + ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); +} + +void FullscreenControllerTest::RequestToLockMouse(WebContents* tab, + bool user_gesture, + bool last_unlocked_by_target) { + browser()->RequestToLockMouse(tab, user_gesture, + last_unlocked_by_target); +} + +void FullscreenControllerTest::LostMouseLock() { + browser()->LostMouseLock(); +} + +bool FullscreenControllerTest::SendEscapeToFullscreenController() { + return browser()->fullscreen_controller_->HandleUserPressedEscape(); +} + +bool FullscreenControllerTest::IsFullscreenForBrowser() { + return browser()->fullscreen_controller_->IsFullscreenForBrowser(); +} + +bool FullscreenControllerTest::IsFullscreenForTabOrPending() { + return browser()->IsFullscreenForTabOrPending(); +} + +bool FullscreenControllerTest::IsMouseLockPermissionRequested() { + FullscreenExitBubbleType type = + browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + bool mouse_lock = false; + fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); + return mouse_lock; +} + +bool FullscreenControllerTest::IsFullscreenPermissionRequested() { + FullscreenExitBubbleType type = + browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + bool fullscreen = false; + fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); + return fullscreen; +} + +FullscreenExitBubbleType + FullscreenControllerTest::GetFullscreenExitBubbleType() { + return browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); +} + +bool FullscreenControllerTest::IsFullscreenBubbleDisplayed() { + FullscreenExitBubbleType type = + browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + return type != FEB_TYPE_NONE; +} + +bool FullscreenControllerTest::IsFullscreenBubbleDisplayingButtons() { + FullscreenExitBubbleType type = + browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + return fullscreen_bubble::ShowButtonsForType(type); +} + +void FullscreenControllerTest::AcceptCurrentFullscreenOrMouseLockRequest() { + WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); + FullscreenExitBubbleType type = + browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); +} + +void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() { + FullscreenExitBubbleType type = + browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); + browser()->OnDenyFullscreenPermission(type); +} |
