Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 10261011: Windowed mode mouse lock addded to fullscreen controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: yzshen feedback addressed. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #if defined(OS_MACOSX) 10 #if defined(OS_MACOSX)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/test/base/in_process_browser_test.h" 43 #include "chrome/test/base/in_process_browser_test.h"
44 #include "chrome/test/base/ui_test_utils.h" 44 #include "chrome/test/base/ui_test_utils.h"
45 #include "content/public/browser/favicon_status.h" 45 #include "content/public/browser/favicon_status.h"
46 #include "content/public/browser/interstitial_page.h" 46 #include "content/public/browser/interstitial_page.h"
47 #include "content/public/browser/interstitial_page_delegate.h" 47 #include "content/public/browser/interstitial_page_delegate.h"
48 #include "content/public/browser/navigation_entry.h" 48 #include "content/public/browser/navigation_entry.h"
49 #include "content/public/browser/notification_service.h" 49 #include "content/public/browser/notification_service.h"
50 #include "content/public/browser/notification_source.h" 50 #include "content/public/browser/notification_source.h"
51 #include "content/public/browser/render_process_host.h" 51 #include "content/public/browser/render_process_host.h"
52 #include "content/public/browser/render_view_host.h" 52 #include "content/public/browser/render_view_host.h"
53 #include "content/public/browser/render_widget_host_view.h"
53 #include "content/public/browser/web_contents.h" 54 #include "content/public/browser/web_contents.h"
54 #include "content/public/browser/web_contents_observer.h" 55 #include "content/public/browser/web_contents_observer.h"
55 #include "content/public/common/page_transition_types.h" 56 #include "content/public/common/page_transition_types.h"
56 #include "content/public/common/renderer_preferences.h" 57 #include "content/public/common/renderer_preferences.h"
57 #include "content/public/common/url_constants.h" 58 #include "content/public/common/url_constants.h"
58 #include "grit/chromium_strings.h" 59 #include "grit/chromium_strings.h"
59 #include "grit/generated_resources.h" 60 #include "grit/generated_resources.h"
60 #include "net/base/mock_host_resolver.h" 61 #include "net/base/mock_host_resolver.h"
61 #include "net/test/test_server.h" 62 #include "net/test/test_server.h"
62 #include "ui/base/l10n/l10n_util.h" 63 #include "ui/base/l10n/l10n_util.h"
(...skipping 23 matching lines...) Expand all
86 87
87 const FilePath::CharType* kBeforeUnloadFile = 88 const FilePath::CharType* kBeforeUnloadFile =
88 FILE_PATH_LITERAL("beforeunload.html"); 89 FILE_PATH_LITERAL("beforeunload.html");
89 90
90 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); 91 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
91 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); 92 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
92 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); 93 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html");
93 94
94 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); 95 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
95 96
97 const char* kFullscreenMouseLockHTML =
98 "files/fullscreen_mouselock/fullscreen_mouselock.html";
99
96 // Given a page title, returns the expected window caption string. 100 // Given a page title, returns the expected window caption string.
97 std::wstring WindowCaptionFromPageTitle(std::wstring page_title) { 101 std::wstring WindowCaptionFromPageTitle(std::wstring page_title) {
98 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 102 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
99 // On Mac or ChromeOS, we don't want to suffix the page title with 103 // On Mac or ChromeOS, we don't want to suffix the page title with
100 // the application name. 104 // the application name.
101 if (page_title.empty()) { 105 if (page_title.empty()) {
102 return UTF16ToWideHack( 106 return UTF16ToWideHack(
103 l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); 107 l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED));
104 } 108 }
105 return page_title; 109 return page_title;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 184
181 // Fullscreen transition notification observer simplifies test code. 185 // Fullscreen transition notification observer simplifies test code.
182 class FullscreenNotificationObserver 186 class FullscreenNotificationObserver
183 : public ui_test_utils::WindowedNotificationObserver { 187 : public ui_test_utils::WindowedNotificationObserver {
184 public: 188 public:
185 FullscreenNotificationObserver() : WindowedNotificationObserver( 189 FullscreenNotificationObserver() : WindowedNotificationObserver(
186 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 190 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
187 content::NotificationService::AllSources()) {} 191 content::NotificationService::AllSources()) {}
188 }; 192 };
189 193
194 // Fullscreen transition notification observer simplifies test code.
Nico 2012/05/01 14:57:21 s/Fullscreen/Mouse lock/ Or remove the comment (a
scheib 2012/05/18 23:07:53 Done.
scheib 2012/05/18 23:07:53 Done.
195 class MouseLockNotificationObserver
196 : public ui_test_utils::WindowedNotificationObserver {
197 public:
198 MouseLockNotificationObserver() : WindowedNotificationObserver(
199 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
200 content::NotificationService::AllSources()) {}
201 };
202
190 } // namespace 203 } // namespace
191 204
192 class BrowserTest : public ExtensionBrowserTest { 205 class BrowserTest : public ExtensionBrowserTest {
193 protected: 206 protected:
207 virtual void SetUpCommandLine(CommandLine* command_line) {
208 command_line->AppendSwitch(switches::kEnablePointerLock);
209 }
210
194 // In RTL locales wrap the page title with RTL embedding characters so that it 211 // In RTL locales wrap the page title with RTL embedding characters so that it
195 // matches the value returned by GetWindowTitle(). 212 // matches the value returned by GetWindowTitle().
196 std::wstring LocaleWindowCaptionFromPageTitle( 213 std::wstring LocaleWindowCaptionFromPageTitle(
197 const std::wstring& expected_title) { 214 const std::wstring& expected_title) {
198 std::wstring page_title = WindowCaptionFromPageTitle(expected_title); 215 std::wstring page_title = WindowCaptionFromPageTitle(expected_title);
199 #if defined(OS_WIN) 216 #if defined(OS_WIN)
200 std::string locale = g_browser_process->GetApplicationLocale(); 217 std::string locale = g_browser_process->GetApplicationLocale();
201 if (base::i18n::GetTextDirectionForLocale(locale.c_str()) == 218 if (base::i18n::GetTextDirectionForLocale(locale.c_str()) ==
202 base::i18n::RIGHT_TO_LEFT) { 219 base::i18n::RIGHT_TO_LEFT) {
203 base::i18n::WrapStringWithLTRFormatting(&page_title); 220 base::i18n::WrapStringWithLTRFormatting(&page_title);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 265 }
249 266
250 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) { 267 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) {
251 browser()->RequestToLockMouse(tab, user_gesture); 268 browser()->RequestToLockMouse(tab, user_gesture);
252 } 269 }
253 270
254 void LostMouseLock() { 271 void LostMouseLock() {
255 browser()->LostMouseLock(); 272 browser()->LostMouseLock();
256 } 273 }
257 274
275 bool SendEscapeToFullscreenController() {
276 return browser()->fullscreen_controller_->HandleUserPressedEscape();
277 }
278
258 bool IsFullscreenForBrowser() { 279 bool IsFullscreenForBrowser() {
259 return browser()->fullscreen_controller_->IsFullscreenForBrowser(); 280 return browser()->fullscreen_controller_->IsFullscreenForBrowser();
260 } 281 }
261 282
262 bool IsFullscreenForTabOrPending() { 283 bool IsFullscreenForTabOrPending() {
263 return browser()->IsFullscreenForTabOrPending(); 284 return browser()->IsFullscreenForTabOrPending();
264 } 285 }
265 286
266 bool IsMouseLocked() { 287 bool IsMouseLocked() {
288 // Verify that IsMouseLocked is consistent between the
289 // Fullscreen Controller and the Render View Host View.
290 EXPECT_TRUE(browser()->IsMouseLocked() ==
291 browser()->GetSelectedWebContents()->
292 GetRenderViewHost()->GetView()->IsMouseLocked());
267 return browser()->IsMouseLocked(); 293 return browser()->IsMouseLocked();
268 } 294 }
269 295
270 bool IsMouseLockPermissionRequested() { 296 bool IsMouseLockPermissionRequested() {
271 FullscreenExitBubbleType type = 297 FullscreenExitBubbleType type =
272 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 298 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
273 bool mouse_lock = false; 299 bool mouse_lock = false;
274 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); 300 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock);
275 return mouse_lock; 301 return mouse_lock;
276 } 302 }
277 303
278 bool IsFullscreenPermissionRequested() { 304 bool IsFullscreenPermissionRequested() {
279 FullscreenExitBubbleType type = 305 FullscreenExitBubbleType type =
280 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 306 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
281 bool fullscreen = false; 307 bool fullscreen = false;
282 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); 308 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL);
283 return fullscreen; 309 return fullscreen;
284 } 310 }
285 311
286 FullscreenExitBubbleType GetFullscreenExitBubbleType() { 312 FullscreenExitBubbleType GetFullscreenExitBubbleType() {
287 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 313 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
288 } 314 }
289 315
290 bool IsFullscreenBubbleDisplayed() { 316 bool IsFullscreenBubbleDisplayed() {
291 FullscreenExitBubbleType type = 317 FullscreenExitBubbleType type =
292 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 318 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
293 // TODO(scheib): Should be FEB_TYPE_NONE, crbug.com/107013 will include fix. 319 return type != FEB_TYPE_NONE;
294 return type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
295 } 320 }
296 321
297 bool IsFullscreenBubbleDisplayingButtons() { 322 bool IsFullscreenBubbleDisplayingButtons() {
298 FullscreenExitBubbleType type = 323 FullscreenExitBubbleType type =
299 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 324 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
300 return fullscreen_bubble::ShowButtonsForType(type); 325 return fullscreen_bubble::ShowButtonsForType(type);
301 } 326 }
302 327
303 void AcceptCurrentFullscreenOrMouseLockRequest() { 328 void AcceptCurrentFullscreenOrMouseLockRequest() {
304 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); 329 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
305 FullscreenExitBubbleType type = 330 FullscreenExitBubbleType type =
306 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 331 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
307 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); 332 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type);
308 } 333 }
309 334
335 void DenyCurrentFullscreenOrMouseLockRequest() {
336 FullscreenExitBubbleType type =
337 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
338 browser()->OnDenyFullscreenPermission(type);
339 }
340
310 // Helper method to be called by multiple tests. 341 // Helper method to be called by multiple tests.
311 void TestFullscreenMouseLockContentSettings(); 342 void TestFullscreenMouseLockContentSettings();
312 }; 343 };
313 344
314 // Launch the app on a page with no title, check that the app title was set 345 // Launch the app on a page with no title, check that the app title was set
315 // correctly. 346 // correctly.
316 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { 347 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) {
317 ui_test_utils::NavigateToURL(browser(), 348 ui_test_utils::NavigateToURL(browser(),
318 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 349 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
319 FilePath(kTitle1File))); 350 FilePath(kTitle1File)));
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1060
1030 // Request mouse lock and verify the bubble is waiting for user confirmation. 1061 // Request mouse lock and verify the bubble is waiting for user confirmation.
1031 RequestToLockMouse(fullscreen_tab, true); 1062 RequestToLockMouse(fullscreen_tab, true);
1032 ASSERT_TRUE(IsMouseLockPermissionRequested()); 1063 ASSERT_TRUE(IsMouseLockPermissionRequested());
1033 1064
1034 // Accept mouse lock and verify bubble no longer shows confirmation buttons. 1065 // Accept mouse lock and verify bubble no longer shows confirmation buttons.
1035 AcceptCurrentFullscreenOrMouseLockRequest(); 1066 AcceptCurrentFullscreenOrMouseLockRequest();
1036 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); 1067 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
1037 } 1068 }
1038 1069
1039 // Tests mouse lock fails before fullscreen is entered. 1070 // Tests mouse lock then fullscreen.
1040 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { 1071 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) {
1072 ASSERT_TRUE(test_server()->Start());
1073 ui_test_utils::NavigateToURL(browser(),
1074 test_server()->GetURL(kFullscreenMouseLockHTML));
1075
1041 WebContents* tab = browser()->GetSelectedWebContents(); 1076 WebContents* tab = browser()->GetSelectedWebContents();
1042 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); 1077
1043 1078 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1044 RequestToLockMouse(tab, true); 1079
1045 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); 1080 // Lock the mouse without a user gesture, expect no response.
1046 1081 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1082 browser(), ui::VKEY_D, false, false, false, false,
yzshen1 2012/05/18 01:00:45 wrong indent (and some other places). It should be
scheib 2012/05/18 23:07:53 Done.
1083 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1084 content::NotificationService::AllSources()));
1085 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1086 ASSERT_FALSE(IsMouseLocked());
1087
1088 // Lock the mouse with a user gesture.
1089 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1090 browser(), ui::VKEY_1, false, false, false, false,
1091 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1092 content::NotificationService::AllSources()));
1093 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
1094 ASSERT_FALSE(IsFullscreenPermissionRequested());
1095 ASSERT_TRUE(IsMouseLockPermissionRequested());
1096 ASSERT_FALSE(IsMouseLocked());
1097
1098 // Accept mouse lock.
1099 AcceptCurrentFullscreenOrMouseLockRequest();
1100 ASSERT_TRUE(IsMouseLocked());
1101 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
1102
1103 // Enter fullscreen mode, mouse lock should be dropped to present buttons.
1047 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); 1104 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
1048 ASSERT_TRUE(IsFullscreenPermissionRequested()); 1105 ASSERT_TRUE(IsFullscreenPermissionRequested());
1049 ASSERT_FALSE(IsMouseLockPermissionRequested()); 1106 ASSERT_FALSE(IsMouseLockPermissionRequested());
1107 ASSERT_FALSE(IsMouseLocked());
1108
1109 // Request mouse lock also, expect fullscreen and mouse lock buttons.
1110 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1111 browser(), ui::VKEY_1, false, false, false, false,
1112 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1113 content::NotificationService::AllSources()));
1114 ASSERT_TRUE(IsFullscreenPermissionRequested());
1115 ASSERT_TRUE(IsMouseLockPermissionRequested());
1116 ASSERT_FALSE(IsMouseLocked());
1117
1118 // Accept fullscreen and mouse lock.
1119 AcceptCurrentFullscreenOrMouseLockRequest();
1120 ASSERT_TRUE(IsMouseLocked());
1121 ASSERT_TRUE(IsFullscreenForTabOrPending());
1122 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
1123 }
1124
1125 // Tests mouse lock then fullscreen in same request.
1126 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockAndFullscreen) {
1127 ASSERT_TRUE(test_server()->Start());
1128 ui_test_utils::NavigateToURL(browser(),
1129 test_server()->GetURL(kFullscreenMouseLockHTML));
1130
1131 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1132
1133 // Request to lock the mouse and enter fullscreen.
1134 {
1135 FullscreenNotificationObserver fullscreen_observer;
1136 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1137 browser(), ui::VKEY_B, false, true, false, false,
1138 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1139 content::NotificationService::AllSources()));
1140 fullscreen_observer.Wait();
1141 }
1142 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
1143 ASSERT_TRUE(IsFullscreenPermissionRequested());
1144 ASSERT_TRUE(IsMouseLockPermissionRequested());
1145 ASSERT_FALSE(IsMouseLocked());
1146 ASSERT_TRUE(IsFullscreenForTabOrPending());
1147
1148 // Deny both first, to make sure we can.
1149 {
1150 FullscreenNotificationObserver fullscreen_observer;
1151 DenyCurrentFullscreenOrMouseLockRequest();
1152 fullscreen_observer.Wait();
1153 }
1154 ASSERT_FALSE(IsMouseLocked());
1155 ASSERT_FALSE(IsFullscreenForTabOrPending());
1156 ASSERT_FALSE(IsFullscreenPermissionRequested());
1157
1158 // Request to lock the mouse and enter fullscreen.
1159 {
1160 FullscreenNotificationObserver fullscreen_observer;
1161 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1162 browser(), ui::VKEY_B, false, true, false, false,
1163 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1164 content::NotificationService::AllSources()));
1165 fullscreen_observer.Wait();
1166 }
1167 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
1168 ASSERT_TRUE(IsFullscreenPermissionRequested());
1169 ASSERT_TRUE(IsMouseLockPermissionRequested());
1170 ASSERT_FALSE(IsMouseLocked());
1171 ASSERT_TRUE(IsFullscreenForTabOrPending());
1172
1173 // Accept both, confirm they are enabled and there is no prompt.
1174 AcceptCurrentFullscreenOrMouseLockRequest();
1175 ASSERT_TRUE(IsMouseLocked());
1176 ASSERT_TRUE(IsFullscreenForTabOrPending());
1177 ASSERT_FALSE(IsFullscreenPermissionRequested());
1178 }
1179
1180 // Tests mouse lock can be escaped with ESC key.
1181 IN_PROC_BROWSER_TEST_F(BrowserTest, EscapingMouseLock) {
1182 ASSERT_TRUE(test_server()->Start());
1183 ui_test_utils::NavigateToURL(browser(),
1184 test_server()->GetURL(kFullscreenMouseLockHTML));
1185
1186 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1187
1188 // Request to lock the mouse.
1189 {
1190 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1191 browser(), ui::VKEY_1, false, false, false, false,
1192 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1193 content::NotificationService::AllSources()));
1194 }
1195 ASSERT_FALSE(IsFullscreenPermissionRequested());
1196 ASSERT_TRUE(IsMouseLockPermissionRequested());
1197
1198 // Escape, no prompts should remain.
1199 SendEscapeToFullscreenController();
1200 ASSERT_FALSE(IsFullscreenPermissionRequested());
1201 ASSERT_FALSE(IsMouseLockPermissionRequested());
1202
1203 // Request to lock the mouse.
1204 {
1205 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1206 browser(), ui::VKEY_1, false, false, false, false,
1207 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1208 content::NotificationService::AllSources()));
1209 }
1210 ASSERT_FALSE(IsFullscreenPermissionRequested());
1211 ASSERT_TRUE(IsMouseLockPermissionRequested());
1212
1213 // Accept mouse lock, confirm it and that there is no prompt.
1214 AcceptCurrentFullscreenOrMouseLockRequest();
1215 ASSERT_TRUE(IsMouseLocked());
1216 ASSERT_FALSE(IsFullscreenForTabOrPending());
1217 ASSERT_FALSE(IsFullscreenPermissionRequested());
1218 ASSERT_FALSE(IsMouseLockPermissionRequested());
1219
1220 // Escape, confirm we are out of mouse lock with no prompts.
1221 SendEscapeToFullscreenController();
1222 ASSERT_FALSE(IsMouseLocked());
1223 ASSERT_FALSE(IsFullscreenForTabOrPending());
1224 ASSERT_FALSE(IsFullscreenPermissionRequested());
1225 ASSERT_FALSE(IsMouseLockPermissionRequested());
1226 }
1227
1228 // Tests mouse lock and fullscreen modes can be escaped with ESC key.
1229 IN_PROC_BROWSER_TEST_F(BrowserTest, EscapingMouseLockAndFullscreen) {
1230 ASSERT_TRUE(test_server()->Start());
1231 ui_test_utils::NavigateToURL(browser(),
1232 test_server()->GetURL(kFullscreenMouseLockHTML));
1233
1234 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1235
1236 // Request to lock the mouse and enter fullscreen.
1237 {
1238 FullscreenNotificationObserver fullscreen_observer;
1239 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1240 browser(), ui::VKEY_B, false, true, false, false,
1241 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1242 content::NotificationService::AllSources()));
1243 fullscreen_observer.Wait();
1244 }
1245 ASSERT_TRUE(IsFullscreenPermissionRequested());
1246 ASSERT_TRUE(IsMouseLockPermissionRequested());
1247
1248 // Escape, no prompts should remain.
1249 {
1250 FullscreenNotificationObserver fullscreen_observer;
1251 SendEscapeToFullscreenController();
1252 fullscreen_observer.Wait();
1253 }
1254 ASSERT_FALSE(IsFullscreenPermissionRequested());
1255 ASSERT_FALSE(IsMouseLockPermissionRequested());
1256
1257 // Request to lock the mouse and enter fullscreen.
1258 {
1259 FullscreenNotificationObserver fullscreen_observer;
1260 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1261 browser(), ui::VKEY_B, false, true, false, false,
1262 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1263 content::NotificationService::AllSources()));
1264 fullscreen_observer.Wait();
1265 }
1266 ASSERT_TRUE(IsFullscreenPermissionRequested());
1267 ASSERT_TRUE(IsMouseLockPermissionRequested());
1268
1269 // Accept both, confirm mouse lock and fullscreen and no prompts.
1270 AcceptCurrentFullscreenOrMouseLockRequest();
1271 ASSERT_TRUE(IsMouseLocked());
1272 ASSERT_TRUE(IsFullscreenForTabOrPending());
1273 ASSERT_FALSE(IsFullscreenPermissionRequested());
1274 ASSERT_FALSE(IsMouseLockPermissionRequested());
1275
1276 // Escape, confirm we are out of mouse lock and fullscreen with no prompts.
1277 {
1278 FullscreenNotificationObserver fullscreen_observer;
1279 SendEscapeToFullscreenController();
1280 fullscreen_observer.Wait();
1281 }
1282 ASSERT_FALSE(IsMouseLocked());
1283 ASSERT_FALSE(IsFullscreenForTabOrPending());
1284 ASSERT_FALSE(IsFullscreenPermissionRequested());
1285 ASSERT_FALSE(IsMouseLockPermissionRequested());
1050 } 1286 }
1051 1287
1052 // Helper method to be called by multiple tests. 1288 // Helper method to be called by multiple tests.
1053 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. 1289 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
1054 void BrowserTest::TestFullscreenMouseLockContentSettings() { 1290 void BrowserTest::TestFullscreenMouseLockContentSettings() {
1055 GURL url = test_server()->GetURL("simple.html"); 1291 GURL url = test_server()->GetURL("simple.html");
1056 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); 1292 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
1057 WebContents* tab = browser()->GetSelectedWebContents(); 1293 WebContents* tab = browser()->GetSelectedWebContents();
1058 1294
1059 // Validate that going fullscreen for a URL defaults to asking permision. 1295 // Validate that going fullscreen for a URL defaults to asking permision.
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 1974
1739 // The normal browser should now have four. 1975 // The normal browser should now have four.
1740 EXPECT_EQ(4, browser()->tab_count()); 1976 EXPECT_EQ(4, browser()->tab_count());
1741 1977
1742 // Close the additional browsers. 1978 // Close the additional browsers.
1743 popup_browser->CloseAllTabs(); 1979 popup_browser->CloseAllTabs();
1744 app_browser->CloseAllTabs(); 1980 app_browser->CloseAllTabs();
1745 app_popup_browser->CloseAllTabs(); 1981 app_popup_browser->CloseAllTabs();
1746 } 1982 }
1747 #endif 1983 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698