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::IsFullscreenForTabOrPending() { 43 return browser()->fullscreen_controller()->IsFullscreenForTabOrPending(); 44 } 45 46 bool FullscreenControllerTest::IsMouseLockPermissionRequested() { 47 FullscreenExitBubbleType type = 48 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 49 bool mouse_lock = false; 50 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); 51 return mouse_lock; 52 } 53 54 bool FullscreenControllerTest::IsFullscreenPermissionRequested() { 55 FullscreenExitBubbleType type = 56 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 57 bool fullscreen = false; 58 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); 59 return fullscreen; 60 } 61 62 FullscreenExitBubbleType 63 FullscreenControllerTest::GetFullscreenExitBubbleType() { 64 return browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 65 } 66 67 bool FullscreenControllerTest::IsFullscreenBubbleDisplayed() { 68 FullscreenExitBubbleType type = 69 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 70 return type != FEB_TYPE_NONE; 71 } 72 73 bool FullscreenControllerTest::IsFullscreenBubbleDisplayingButtons() { 74 FullscreenExitBubbleType type = 75 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); 76 return fullscreen_bubble::ShowButtonsForType(type); 77 } 78 79 void FullscreenControllerTest::AcceptCurrentFullscreenOrMouseLockRequest() { 80 browser()->fullscreen_controller()->OnAcceptFullscreenPermission(); 81 } 82 83 void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() { 84 browser()->fullscreen_controller()->OnDenyFullscreenPermission(); 85 } 86 87 void FullscreenControllerTest::GoBack() { 88 content::TestNavigationObserver observer( 89 browser()->tab_strip_model()->GetActiveWebContents(), 1); 90 chrome::GoBack(browser(), CURRENT_TAB); 91 observer.Wait(); 92 } 93 94 void FullscreenControllerTest::Reload() { 95 content::TestNavigationObserver observer( 96 browser()->tab_strip_model()->GetActiveWebContents(), 1); 97 chrome::Reload(browser(), CURRENT_TAB); 98 observer.Wait(); 99 } 100 101