| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" | 5 #include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // that when running serially there is no flakiness in the transition. | 38 // that when running serially there is no flakiness in the transition. |
| 39 void FullscreenControllerTest::ToggleTabFullscreenNoRetries( | 39 void FullscreenControllerTest::ToggleTabFullscreenNoRetries( |
| 40 bool enter_fullscreen) { | 40 bool enter_fullscreen) { |
| 41 ToggleTabFullscreen_Internal(enter_fullscreen, false); | 41 ToggleTabFullscreen_Internal(enter_fullscreen, false); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void FullscreenControllerTest::ToggleBrowserFullscreen(bool enter_fullscreen) { | 44 void FullscreenControllerTest::ToggleBrowserFullscreen(bool enter_fullscreen) { |
| 45 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); | 45 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); |
| 46 FullscreenNotificationObserver fullscreen_observer; | 46 FullscreenNotificationObserver fullscreen_observer; |
| 47 | 47 |
| 48 browser()->ToggleFullscreenMode(); | 48 chrome::ToggleFullscreenMode(browser()); |
| 49 | 49 |
| 50 fullscreen_observer.Wait(); | 50 fullscreen_observer.Wait(); |
| 51 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | 51 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); |
| 52 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); | 52 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void FullscreenControllerTest::RequestToLockMouse( | 55 void FullscreenControllerTest::RequestToLockMouse( |
| 56 bool user_gesture, | 56 bool user_gesture, |
| 57 bool last_unlocked_by_target) { | 57 bool last_unlocked_by_target) { |
| 58 WebContents* tab = chrome::GetActiveWebContents(browser()); | 58 WebContents* tab = chrome::GetActiveWebContents(browser()); |
| 59 browser()->RequestToLockMouse(tab, user_gesture, | 59 browser()->RequestToLockMouse(tab, user_gesture, |
| 60 last_unlocked_by_target); | 60 last_unlocked_by_target); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void FullscreenControllerTest::LostMouseLock() { | 63 void FullscreenControllerTest::LostMouseLock() { |
| 64 browser()->LostMouseLock(); | 64 browser()->LostMouseLock(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool FullscreenControllerTest::SendEscapeToFullscreenController() { | 67 bool FullscreenControllerTest::SendEscapeToFullscreenController() { |
| 68 return browser()->fullscreen_controller_->HandleUserPressedEscape(); | 68 return browser()->fullscreen_controller()->HandleUserPressedEscape(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool FullscreenControllerTest::IsFullscreenForBrowser() { | 71 bool FullscreenControllerTest::IsFullscreenForBrowser() { |
| 72 return browser()->fullscreen_controller_->IsFullscreenForBrowser(); | 72 return browser()->fullscreen_controller()->IsFullscreenForBrowser(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool FullscreenControllerTest::IsFullscreenForTabOrPending() { | 75 bool FullscreenControllerTest::IsFullscreenForTabOrPending() { |
| 76 return browser()->IsFullscreenForTabOrPending(); | 76 return browser()->fullscreen_controller()->IsFullscreenForTabOrPending(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool FullscreenControllerTest::IsMouseLockPermissionRequested() { | 79 bool FullscreenControllerTest::IsMouseLockPermissionRequested() { |
| 80 FullscreenExitBubbleType type = | 80 FullscreenExitBubbleType type = |
| 81 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 81 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 82 bool mouse_lock = false; | 82 bool mouse_lock = false; |
| 83 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); | 83 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); |
| 84 return mouse_lock; | 84 return mouse_lock; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool FullscreenControllerTest::IsFullscreenPermissionRequested() { | 87 bool FullscreenControllerTest::IsFullscreenPermissionRequested() { |
| 88 FullscreenExitBubbleType type = | 88 FullscreenExitBubbleType type = |
| 89 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 89 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 90 bool fullscreen = false; | 90 bool fullscreen = false; |
| 91 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); | 91 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); |
| 92 return fullscreen; | 92 return fullscreen; |
| 93 } | 93 } |
| 94 | 94 |
| 95 FullscreenExitBubbleType | 95 FullscreenExitBubbleType |
| 96 FullscreenControllerTest::GetFullscreenExitBubbleType() { | 96 FullscreenControllerTest::GetFullscreenExitBubbleType() { |
| 97 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 97 return browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool FullscreenControllerTest::IsFullscreenBubbleDisplayed() { | 100 bool FullscreenControllerTest::IsFullscreenBubbleDisplayed() { |
| 101 FullscreenExitBubbleType type = | 101 FullscreenExitBubbleType type = |
| 102 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 102 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 103 return type != FEB_TYPE_NONE; | 103 return type != FEB_TYPE_NONE; |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool FullscreenControllerTest::IsFullscreenBubbleDisplayingButtons() { | 106 bool FullscreenControllerTest::IsFullscreenBubbleDisplayingButtons() { |
| 107 FullscreenExitBubbleType type = | 107 FullscreenExitBubbleType type = |
| 108 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 108 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 109 return fullscreen_bubble::ShowButtonsForType(type); | 109 return fullscreen_bubble::ShowButtonsForType(type); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void FullscreenControllerTest::AcceptCurrentFullscreenOrMouseLockRequest() { | 112 void FullscreenControllerTest::AcceptCurrentFullscreenOrMouseLockRequest() { |
| 113 WebContents* fullscreen_tab = chrome::GetActiveWebContents(browser()); | 113 WebContents* fullscreen_tab = chrome::GetActiveWebContents(browser()); |
| 114 FullscreenExitBubbleType type = | 114 FullscreenExitBubbleType type = |
| 115 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 115 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 116 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); | 116 browser()->fullscreen_controller()->OnAcceptFullscreenPermission( |
| 117 fullscreen_tab->GetURL(), type); |
| 117 } | 118 } |
| 118 | 119 |
| 119 void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() { | 120 void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() { |
| 120 FullscreenExitBubbleType type = | 121 FullscreenExitBubbleType type = |
| 121 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 122 browser()->fullscreen_controller()->GetFullscreenExitBubbleType(); |
| 122 browser()->OnDenyFullscreenPermission(type); | 123 browser()->fullscreen_controller()->OnDenyFullscreenPermission(type); |
| 123 } | 124 } |
| 124 | 125 |
| 125 void FullscreenControllerTest::AddTabAtIndexAndWait(int index, const GURL& url, | 126 void FullscreenControllerTest::AddTabAtIndexAndWait(int index, const GURL& url, |
| 126 content::PageTransition transition) { | 127 content::PageTransition transition) { |
| 127 content::TestNavigationObserver observer( | 128 content::TestNavigationObserver observer( |
| 128 content::NotificationService::AllSources(), NULL, 1); | 129 content::NotificationService::AllSources(), NULL, 1); |
| 129 | 130 |
| 130 AddTabAtIndex(index, url, transition); | 131 AddTabAtIndex(index, url, transition); |
| 131 | 132 |
| 132 observer.Wait(); | 133 observer.Wait(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); | 165 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); |
| 165 fullscreen_observer.Wait(); | 166 fullscreen_observer.Wait(); |
| 166 // Repeat ToggleFullscreenModeForTab until the correct state is entered. | 167 // Repeat ToggleFullscreenModeForTab until the correct state is entered. |
| 167 // This addresses flakiness on test bots running many fullscreen | 168 // This addresses flakiness on test bots running many fullscreen |
| 168 // tests in parallel. | 169 // tests in parallel. |
| 169 } while (retry_until_success && | 170 } while (retry_until_success && |
| 170 browser()->window()->IsFullscreen() != enter_fullscreen); | 171 browser()->window()->IsFullscreen() != enter_fullscreen); |
| 171 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | 172 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); |
| 172 } | 173 } |
| 173 } | 174 } |
| OLD | NEW |