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

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: indent 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "chrome/test/base/in_process_browser_test.h" 46 #include "chrome/test/base/in_process_browser_test.h"
47 #include "chrome/test/base/ui_test_utils.h" 47 #include "chrome/test/base/ui_test_utils.h"
48 #include "content/public/browser/favicon_status.h" 48 #include "content/public/browser/favicon_status.h"
49 #include "content/public/browser/interstitial_page.h" 49 #include "content/public/browser/interstitial_page.h"
50 #include "content/public/browser/interstitial_page_delegate.h" 50 #include "content/public/browser/interstitial_page_delegate.h"
51 #include "content/public/browser/navigation_entry.h" 51 #include "content/public/browser/navigation_entry.h"
52 #include "content/public/browser/notification_service.h" 52 #include "content/public/browser/notification_service.h"
53 #include "content/public/browser/notification_source.h" 53 #include "content/public/browser/notification_source.h"
54 #include "content/public/browser/render_process_host.h" 54 #include "content/public/browser/render_process_host.h"
55 #include "content/public/browser/render_view_host.h" 55 #include "content/public/browser/render_view_host.h"
56 #include "content/public/browser/render_widget_host_view.h"
56 #include "content/public/browser/web_contents.h" 57 #include "content/public/browser/web_contents.h"
57 #include "content/public/browser/web_contents_observer.h" 58 #include "content/public/browser/web_contents_observer.h"
58 #include "content/public/common/page_transition_types.h" 59 #include "content/public/common/page_transition_types.h"
59 #include "content/public/common/renderer_preferences.h" 60 #include "content/public/common/renderer_preferences.h"
60 #include "content/public/common/url_constants.h" 61 #include "content/public/common/url_constants.h"
61 #include "grit/chromium_strings.h" 62 #include "grit/chromium_strings.h"
62 #include "grit/generated_resources.h" 63 #include "grit/generated_resources.h"
63 #include "net/base/mock_host_resolver.h" 64 #include "net/base/mock_host_resolver.h"
64 #include "net/test/test_server.h" 65 #include "net/test/test_server.h"
65 #include "ui/base/l10n/l10n_util.h" 66 #include "ui/base/l10n/l10n_util.h"
(...skipping 24 matching lines...) Expand all
90 91
91 const FilePath::CharType* kBeforeUnloadFile = 92 const FilePath::CharType* kBeforeUnloadFile =
92 FILE_PATH_LITERAL("beforeunload.html"); 93 FILE_PATH_LITERAL("beforeunload.html");
93 94
94 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); 95 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
95 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); 96 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
96 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); 97 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html");
97 98
98 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); 99 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
99 100
101 const char* kFullscreenMouseLockHTML =
102 "files/fullscreen_mouselock/fullscreen_mouselock.html";
103
100 // Given a page title, returns the expected window caption string. 104 // Given a page title, returns the expected window caption string.
101 string16 WindowCaptionFromPageTitle(const string16& page_title) { 105 string16 WindowCaptionFromPageTitle(const string16& page_title) {
102 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 106 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
103 // On Mac or ChromeOS, we don't want to suffix the page title with 107 // On Mac or ChromeOS, we don't want to suffix the page title with
104 // the application name. 108 // the application name.
105 if (page_title.empty()) 109 if (page_title.empty())
106 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); 110 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED);
107 return page_title; 111 return page_title;
108 #else 112 #else
109 if (page_title.empty()) 113 if (page_title.empty())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 176 }
173 177
174 virtual std::string GetHTMLContents() OVERRIDE { 178 virtual std::string GetHTMLContents() OVERRIDE {
175 return "<h1>INTERSTITIAL</h1>"; 179 return "<h1>INTERSTITIAL</h1>";
176 } 180 }
177 181
178 private: 182 private:
179 InterstitialPage* interstitial_page_; // Owns us. 183 InterstitialPage* interstitial_page_; // Owns us.
180 }; 184 };
181 185
182 // Fullscreen transition notification observer simplifies test code.
183 class FullscreenNotificationObserver 186 class FullscreenNotificationObserver
184 : public ui_test_utils::WindowedNotificationObserver { 187 : public ui_test_utils::WindowedNotificationObserver {
185 public: 188 public:
186 FullscreenNotificationObserver() : WindowedNotificationObserver( 189 FullscreenNotificationObserver() : WindowedNotificationObserver(
187 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 190 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
188 content::NotificationService::AllSources()) {} 191 content::NotificationService::AllSources()) {}
189 }; 192 };
190 193
194 class MouseLockNotificationObserver
195 : public ui_test_utils::WindowedNotificationObserver {
196 public:
197 MouseLockNotificationObserver() : WindowedNotificationObserver(
198 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
199 content::NotificationService::AllSources()) {}
200 };
201
191 } // namespace 202 } // namespace
192 203
193 class BrowserTest : public ExtensionBrowserTest { 204 class BrowserTest : public ExtensionBrowserTest {
194 protected: 205 protected:
206 virtual void SetUpCommandLine(CommandLine* command_line) {
207 ExtensionBrowserTest::SetUpCommandLine(command_line);
208 command_line->AppendSwitch(switches::kEnablePointerLock);
209 }
210
195 // 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
196 // matches the value returned by GetWindowTitle(). 212 // matches the value returned by GetWindowTitle().
197 string16 LocaleWindowCaptionFromPageTitle(const string16& expected_title) { 213 string16 LocaleWindowCaptionFromPageTitle(const string16& expected_title) {
198 string16 page_title = WindowCaptionFromPageTitle(expected_title); 214 string16 page_title = WindowCaptionFromPageTitle(expected_title);
199 #if defined(OS_WIN) 215 #if defined(OS_WIN)
200 std::string locale = g_browser_process->GetApplicationLocale(); 216 std::string locale = g_browser_process->GetApplicationLocale();
201 if (base::i18n::GetTextDirectionForLocale(locale.c_str()) == 217 if (base::i18n::GetTextDirectionForLocale(locale.c_str()) ==
202 base::i18n::RIGHT_TO_LEFT) { 218 base::i18n::RIGHT_TO_LEFT) {
203 base::i18n::WrapStringWithLTRFormatting(&page_title); 219 base::i18n::WrapStringWithLTRFormatting(&page_title);
204 } 220 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 264 }
249 265
250 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) { 266 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) {
251 browser()->RequestToLockMouse(tab, user_gesture); 267 browser()->RequestToLockMouse(tab, user_gesture);
252 } 268 }
253 269
254 void LostMouseLock() { 270 void LostMouseLock() {
255 browser()->LostMouseLock(); 271 browser()->LostMouseLock();
256 } 272 }
257 273
274 bool SendEscapeToFullscreenController() {
275 return browser()->fullscreen_controller_->HandleUserPressedEscape();
276 }
277
258 bool IsFullscreenForBrowser() { 278 bool IsFullscreenForBrowser() {
259 return browser()->fullscreen_controller_->IsFullscreenForBrowser(); 279 return browser()->fullscreen_controller_->IsFullscreenForBrowser();
260 } 280 }
261 281
262 bool IsFullscreenForTabOrPending() { 282 bool IsFullscreenForTabOrPending() {
263 return browser()->IsFullscreenForTabOrPending(); 283 return browser()->IsFullscreenForTabOrPending();
264 } 284 }
265 285
266 bool IsMouseLocked() { 286 bool IsMouseLocked() {
287 // Verify that IsMouseLocked is consistent between the
288 // Fullscreen Controller and the Render View Host View.
289 EXPECT_TRUE(browser()->IsMouseLocked() ==
290 browser()->GetSelectedWebContents()->
291 GetRenderViewHost()->GetView()->IsMouseLocked());
267 return browser()->IsMouseLocked(); 292 return browser()->IsMouseLocked();
268 } 293 }
269 294
270 bool IsMouseLockPermissionRequested() { 295 bool IsMouseLockPermissionRequested() {
271 FullscreenExitBubbleType type = 296 FullscreenExitBubbleType type =
272 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 297 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
273 bool mouse_lock = false; 298 bool mouse_lock = false;
274 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); 299 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock);
275 return mouse_lock; 300 return mouse_lock;
276 } 301 }
277 302
278 bool IsFullscreenPermissionRequested() { 303 bool IsFullscreenPermissionRequested() {
279 FullscreenExitBubbleType type = 304 FullscreenExitBubbleType type =
280 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 305 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
281 bool fullscreen = false; 306 bool fullscreen = false;
282 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); 307 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL);
283 return fullscreen; 308 return fullscreen;
284 } 309 }
285 310
286 FullscreenExitBubbleType GetFullscreenExitBubbleType() { 311 FullscreenExitBubbleType GetFullscreenExitBubbleType() {
287 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 312 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
288 } 313 }
289 314
290 bool IsFullscreenBubbleDisplayed() { 315 bool IsFullscreenBubbleDisplayed() {
291 FullscreenExitBubbleType type = 316 FullscreenExitBubbleType type =
292 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 317 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
293 // TODO(scheib): Should be FEB_TYPE_NONE, crbug.com/107013 will include fix. 318 return type != FEB_TYPE_NONE;
294 return type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
295 } 319 }
296 320
297 bool IsFullscreenBubbleDisplayingButtons() { 321 bool IsFullscreenBubbleDisplayingButtons() {
298 FullscreenExitBubbleType type = 322 FullscreenExitBubbleType type =
299 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 323 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
300 return fullscreen_bubble::ShowButtonsForType(type); 324 return fullscreen_bubble::ShowButtonsForType(type);
301 } 325 }
302 326
303 void AcceptCurrentFullscreenOrMouseLockRequest() { 327 void AcceptCurrentFullscreenOrMouseLockRequest() {
304 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); 328 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
305 FullscreenExitBubbleType type = 329 FullscreenExitBubbleType type =
306 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 330 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
307 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); 331 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type);
308 } 332 }
309 333
334 void DenyCurrentFullscreenOrMouseLockRequest() {
335 FullscreenExitBubbleType type =
336 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
337 browser()->OnDenyFullscreenPermission(type);
338 }
339
310 // Helper method to be called by multiple tests. 340 // Helper method to be called by multiple tests.
311 void TestFullscreenMouseLockContentSettings(); 341 void TestFullscreenMouseLockContentSettings();
312 }; 342 };
313 343
314 // Launch the app on a page with no title, check that the app title was set 344 // Launch the app on a page with no title, check that the app title was set
315 // correctly. 345 // correctly.
316 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { 346 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) {
317 ui_test_utils::NavigateToURL(browser(), 347 ui_test_utils::NavigateToURL(browser(),
318 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 348 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
319 FilePath(kTitle1File))); 349 FilePath(kTitle1File)));
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1060
1031 // 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.
1032 RequestToLockMouse(fullscreen_tab, true); 1062 RequestToLockMouse(fullscreen_tab, true);
1033 ASSERT_TRUE(IsMouseLockPermissionRequested()); 1063 ASSERT_TRUE(IsMouseLockPermissionRequested());
1034 1064
1035 // Accept mouse lock and verify bubble no longer shows confirmation buttons. 1065 // Accept mouse lock and verify bubble no longer shows confirmation buttons.
1036 AcceptCurrentFullscreenOrMouseLockRequest(); 1066 AcceptCurrentFullscreenOrMouseLockRequest();
1037 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); 1067 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
1038 } 1068 }
1039 1069
1040 // Tests mouse lock fails before fullscreen is entered. 1070 // Tests mouse lock then fullscreen.
1041 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
1042 WebContents* tab = browser()->GetSelectedWebContents(); 1076 WebContents* tab = browser()->GetSelectedWebContents();
1043 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); 1077
1044 1078 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1045 RequestToLockMouse(tab, true); 1079
1046 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); 1080 // Lock the mouse without a user gesture, expect no response.
1047 1081 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1082 browser(), ui::VKEY_D, false, false, false, false,
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.
1048 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); 1104 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
1049 ASSERT_TRUE(IsFullscreenPermissionRequested()); 1105 ASSERT_TRUE(IsFullscreenPermissionRequested());
1050 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());
1051 } 1286 }
1052 1287
1053 // Helper method to be called by multiple tests. 1288 // Helper method to be called by multiple tests.
1054 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. 1289 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
1055 void BrowserTest::TestFullscreenMouseLockContentSettings() { 1290 void BrowserTest::TestFullscreenMouseLockContentSettings() {
1056 GURL url = test_server()->GetURL("simple.html"); 1291 GURL url = test_server()->GetURL("simple.html");
1057 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); 1292 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
1058 WebContents* tab = browser()->GetSelectedWebContents(); 1293 WebContents* tab = browser()->GetSelectedWebContents();
1059 1294
1060 // Validate that going fullscreen for a URL defaults to asking permision. 1295 // Validate that going fullscreen for a URL defaults to asking permision.
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 command_line->AppendSwitchASCII(switches::kApp, url.spec()); 2138 command_line->AppendSwitchASCII(switches::kApp, url.spec());
1904 } 2139 }
1905 }; 2140 };
1906 2141
1907 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { 2142 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) {
1908 // Test that an application browser window loads correctly. 2143 // Test that an application browser window loads correctly.
1909 2144
1910 // Verify the browser is in application mode. 2145 // Verify the browser is in application mode.
1911 EXPECT_TRUE(browser()->IsApplication()); 2146 EXPECT_TRUE(browser()->IsApplication());
1912 } 2147 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698