1 // Copyright (c) 2012 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/fullscreen/fullscreen_controller_test.h" 6 7 #include "base/command_line.h" 8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/common/chrome_switches.h" 14 #include "content/public/browser/web_contents.h" 15 #include "content/public/test/test_navigation_observer.h" 16 17 using content::WebContents; 18 19 const char FullscreenControllerTest::kFullscreenMouseLockHTML[] = 20 "files/fullscreen_mouselock/fullscreen_mouselock.html"; 21 22 void FullscreenControllerTest::RequestToLockMouse( 23 bool user_gesture, 24 bool last_unlocked_by_target) { 25 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 26 browser()->RequestToLockMouse(tab, user_gesture, 27 last_unlocked_by_target); 28 } 29 30 void FullscreenControllerTest::LostMouseLock() { 31 browser()->LostMouseLock(); 32 } 33 34 bool FullscreenControllerTest::SendEscapeToFullscreenController() { 35 return browser()->fullscreen_controller()->HandleUserPressedEscape(); 36 } 37 38 bool FullscreenControllerTest::IsFullscreenForBrowser() { 39 return browser()->fullscreen_controller()->IsFullscreenForBrowser(); 40 } 41 42 bool FullscreenControllerTest::IsWindowFullscreenForTabOrPending() { 43 return browser()->fullscreen_controller()-> 44 IsWindowFullscreenForTabOrPending(); 45 } 46 47 bool FullscreenControllerTest::IsMouseLockPermissionRequested() { 48 FullscreenExitBubbleType type = 49 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 50 bool mouse_lock = false; 51 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); 52 return mouse_lock; 53 } 54 55 bool FullscreenControllerTest::IsFullscreenPermissionRequested() { 56 FullscreenExitBubbleType type = 57 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 58 bool fullscreen = false; 59 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); 60 return fullscreen; 61 } 62 63 FullscreenExitBubbleType 64 FullscreenControllerTest::GetFullscreenExitBubbleType() { 65 return browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 66 } 67 68 bool FullscreenControllerTest::IsFullscreenBubbleDisplayed() { 69 FullscreenExitBubbleType type = 70 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 71 return type != FEB_TYPE_NONE; 72 } 73 74 bool FullscreenControllerTest::IsFullscreenBubbleDisplayingButtons() { 75 FullscreenExitBubbleType type = 76 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 77 return fullscreen_bubble::ShowButtonsForType(type); 78 } 79 80 void FullscreenControllerTest::AcceptCurrentFullscreenOrMouseLockRequest() { 81 browser()->fullscreen_controller()->OnAcceptFullscreenPermission(); 82 } 83 84 void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() { 85 browser()->fullscreen_controller()->OnDenyFullscreenPermission(); 86 } 87 88 void FullscreenControllerTest::GoBack() { 89 content::TestNavigationObserver observer( 90 browser()->tab_strip_model()->GetActiveWebContents(), 1); 91 chrome::GoBack(browser(), CURRENT_TAB); 92 observer.Wait(); 93 } 94 95 void FullscreenControllerTest::Reload() { 96 content::TestNavigationObserver observer( 97 browser()->tab_strip_model()->GetActiveWebContents(), 1); 98 chrome::Reload(browser(), CURRENT_TAB); 99 observer.Wait(); 100 } 101 102 void FullscreenControllerTest::SetPrivilegedFullscreen(bool is_privileged) { 103 browser()->fullscreen_controller()-> 104 SetPrivilegedFullscreenForTesting(is_privileged); 105 } 106