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_controller_test.h" | 5 #include "chrome/browser/ui/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_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/fullscreen_controller.h" | 12 #include "chrome/browser/ui/fullscreen_controller.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 #include "content/public/test/test_navigation_observer.h" | 15 #include "content/public/test/test_navigation_observer.h" |
15 | 16 |
16 using content::WebContents; | 17 using content::WebContents; |
17 | 18 |
18 const char FullscreenControllerTest::kFullscreenMouseLockHTML[] = | 19 const char FullscreenControllerTest::kFullscreenMouseLockHTML[] = |
19 "files/fullscreen_mouselock/fullscreen_mouselock.html"; | 20 "files/fullscreen_mouselock/fullscreen_mouselock.html"; |
(...skipping 27 matching lines...) Expand all Loading... |
47 browser()->ToggleFullscreenMode(); | 48 browser()->ToggleFullscreenMode(); |
48 | 49 |
49 fullscreen_observer.Wait(); | 50 fullscreen_observer.Wait(); |
50 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | 51 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); |
51 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); | 52 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); |
52 } | 53 } |
53 | 54 |
54 void FullscreenControllerTest::RequestToLockMouse( | 55 void FullscreenControllerTest::RequestToLockMouse( |
55 bool user_gesture, | 56 bool user_gesture, |
56 bool last_unlocked_by_target) { | 57 bool last_unlocked_by_target) { |
57 WebContents* tab = browser()->GetActiveWebContents(); | 58 WebContents* tab = chrome::GetActiveWebContents(browser()); |
58 browser()->RequestToLockMouse(tab, user_gesture, | 59 browser()->RequestToLockMouse(tab, user_gesture, |
59 last_unlocked_by_target); | 60 last_unlocked_by_target); |
60 } | 61 } |
61 | 62 |
62 void FullscreenControllerTest::LostMouseLock() { | 63 void FullscreenControllerTest::LostMouseLock() { |
63 browser()->LostMouseLock(); | 64 browser()->LostMouseLock(); |
64 } | 65 } |
65 | 66 |
66 bool FullscreenControllerTest::SendEscapeToFullscreenController() { | 67 bool FullscreenControllerTest::SendEscapeToFullscreenController() { |
67 return browser()->fullscreen_controller_->HandleUserPressedEscape(); | 68 return browser()->fullscreen_controller_->HandleUserPressedEscape(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return type != FEB_TYPE_NONE; | 103 return type != FEB_TYPE_NONE; |
103 } | 104 } |
104 | 105 |
105 bool FullscreenControllerTest::IsFullscreenBubbleDisplayingButtons() { | 106 bool FullscreenControllerTest::IsFullscreenBubbleDisplayingButtons() { |
106 FullscreenExitBubbleType type = | 107 FullscreenExitBubbleType type = |
107 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 108 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); |
108 return fullscreen_bubble::ShowButtonsForType(type); | 109 return fullscreen_bubble::ShowButtonsForType(type); |
109 } | 110 } |
110 | 111 |
111 void FullscreenControllerTest::AcceptCurrentFullscreenOrMouseLockRequest() { | 112 void FullscreenControllerTest::AcceptCurrentFullscreenOrMouseLockRequest() { |
112 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 113 WebContents* fullscreen_tab = chrome::GetActiveWebContents(browser()); |
113 FullscreenExitBubbleType type = | 114 FullscreenExitBubbleType type = |
114 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 115 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); |
115 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); | 116 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); |
116 } | 117 } |
117 | 118 |
118 void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() { | 119 void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() { |
119 FullscreenExitBubbleType type = | 120 FullscreenExitBubbleType type = |
120 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 121 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); |
121 browser()->OnDenyFullscreenPermission(type); | 122 browser()->OnDenyFullscreenPermission(type); |
122 } | 123 } |
(...skipping 21 matching lines...) Expand all Loading... |
144 content::TestNavigationObserver observer( | 145 content::TestNavigationObserver observer( |
145 content::NotificationService::AllSources(), NULL, 1); | 146 content::NotificationService::AllSources(), NULL, 1); |
146 | 147 |
147 chrome::Reload(browser(), CURRENT_TAB); | 148 chrome::Reload(browser(), CURRENT_TAB); |
148 | 149 |
149 observer.Wait(); | 150 observer.Wait(); |
150 } | 151 } |
151 | 152 |
152 void FullscreenControllerTest::ToggleTabFullscreen_Internal( | 153 void FullscreenControllerTest::ToggleTabFullscreen_Internal( |
153 bool enter_fullscreen, bool retry_until_success) { | 154 bool enter_fullscreen, bool retry_until_success) { |
154 WebContents* tab = browser()->GetActiveWebContents(); | 155 WebContents* tab = chrome::GetActiveWebContents(browser()); |
155 if (IsFullscreenForBrowser()) { | 156 if (IsFullscreenForBrowser()) { |
156 // Changing tab fullscreen state will not actually change the window | 157 // Changing tab fullscreen state will not actually change the window |
157 // when browser fullscreen is in effect. | 158 // when browser fullscreen is in effect. |
158 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); | 159 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); |
159 } else { // Not in browser fullscreen, expect window to actually change. | 160 } else { // Not in browser fullscreen, expect window to actually change. |
160 ASSERT_NE(browser()->window()->IsFullscreen(), enter_fullscreen); | 161 ASSERT_NE(browser()->window()->IsFullscreen(), enter_fullscreen); |
161 do { | 162 do { |
162 FullscreenNotificationObserver fullscreen_observer; | 163 FullscreenNotificationObserver fullscreen_observer; |
163 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); | 164 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); |
164 fullscreen_observer.Wait(); | 165 fullscreen_observer.Wait(); |
165 // Repeat ToggleFullscreenModeForTab until the correct state is entered. | 166 // Repeat ToggleFullscreenModeForTab until the correct state is entered. |
166 // This addresses flakiness on test bots running many fullscreen | 167 // This addresses flakiness on test bots running many fullscreen |
167 // tests in parallel. | 168 // tests in parallel. |
168 } while (retry_until_success && | 169 } while (retry_until_success && |
169 browser()->window()->IsFullscreen() != enter_fullscreen); | 170 browser()->window()->IsFullscreen() != enter_fullscreen); |
170 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | 171 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); |
171 } | 172 } |
172 } | 173 } |
OLD | NEW |