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

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: Fix Mac build bot errors 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 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 23 matching lines...) Expand all
89 90
90 const FilePath::CharType* kBeforeUnloadFile = 91 const FilePath::CharType* kBeforeUnloadFile =
91 FILE_PATH_LITERAL("beforeunload.html"); 92 FILE_PATH_LITERAL("beforeunload.html");
92 93
93 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); 94 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
94 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); 95 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
95 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); 96 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html");
96 97
97 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); 98 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
98 99
100 const char* kFullscreenMouseLockHTML =
101 "files/fullscreen_mouselock/fullscreen_mouselock.html";
102
99 // Given a page title, returns the expected window caption string. 103 // Given a page title, returns the expected window caption string.
100 string16 WindowCaptionFromPageTitle(const string16& page_title) { 104 string16 WindowCaptionFromPageTitle(const string16& page_title) {
101 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 105 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
102 // On Mac or ChromeOS, we don't want to suffix the page title with 106 // On Mac or ChromeOS, we don't want to suffix the page title with
103 // the application name. 107 // the application name.
104 if (page_title.empty()) 108 if (page_title.empty())
105 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); 109 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED);
106 return page_title; 110 return page_title;
107 #else 111 #else
108 if (page_title.empty()) 112 if (page_title.empty())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 175 }
172 176
173 virtual std::string GetHTMLContents() OVERRIDE { 177 virtual std::string GetHTMLContents() OVERRIDE {
174 return "<h1>INTERSTITIAL</h1>"; 178 return "<h1>INTERSTITIAL</h1>";
175 } 179 }
176 180
177 private: 181 private:
178 InterstitialPage* interstitial_page_; // Owns us. 182 InterstitialPage* interstitial_page_; // Owns us.
179 }; 183 };
180 184
181 // Fullscreen transition notification observer simplifies test code.
182 class FullscreenNotificationObserver 185 class FullscreenNotificationObserver
183 : public ui_test_utils::WindowedNotificationObserver { 186 : public ui_test_utils::WindowedNotificationObserver {
184 public: 187 public:
185 FullscreenNotificationObserver() : WindowedNotificationObserver( 188 FullscreenNotificationObserver() : WindowedNotificationObserver(
186 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 189 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
187 content::NotificationService::AllSources()) {} 190 content::NotificationService::AllSources()) {}
188 }; 191 };
189 192
193 class MouseLockNotificationObserver
194 : public ui_test_utils::WindowedNotificationObserver {
195 public:
196 MouseLockNotificationObserver() : WindowedNotificationObserver(
197 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
198 content::NotificationService::AllSources()) {}
199 };
200
190 } // namespace 201 } // namespace
191 202
192 class BrowserTest : public ExtensionBrowserTest { 203 class BrowserTest : public ExtensionBrowserTest {
193 protected: 204 protected:
205 virtual void SetUpCommandLine(CommandLine* command_line) {
206 ExtensionBrowserTest::SetUpCommandLine(command_line);
207 command_line->AppendSwitch(switches::kEnablePointerLock);
208 }
209
194 // In RTL locales wrap the page title with RTL embedding characters so that it 210 // In RTL locales wrap the page title with RTL embedding characters so that it
195 // matches the value returned by GetWindowTitle(). 211 // matches the value returned by GetWindowTitle().
196 string16 LocaleWindowCaptionFromPageTitle(const string16& expected_title) { 212 string16 LocaleWindowCaptionFromPageTitle(const string16& expected_title) {
197 string16 page_title = WindowCaptionFromPageTitle(expected_title); 213 string16 page_title = WindowCaptionFromPageTitle(expected_title);
198 #if defined(OS_WIN) 214 #if defined(OS_WIN)
199 std::string locale = g_browser_process->GetApplicationLocale(); 215 std::string locale = g_browser_process->GetApplicationLocale();
200 if (base::i18n::GetTextDirectionForLocale(locale.c_str()) == 216 if (base::i18n::GetTextDirectionForLocale(locale.c_str()) ==
201 base::i18n::RIGHT_TO_LEFT) { 217 base::i18n::RIGHT_TO_LEFT) {
202 base::i18n::WrapStringWithLTRFormatting(&page_title); 218 base::i18n::WrapStringWithLTRFormatting(&page_title);
203 } 219 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 263 }
248 264
249 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) { 265 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) {
250 browser()->RequestToLockMouse(tab, user_gesture); 266 browser()->RequestToLockMouse(tab, user_gesture);
251 } 267 }
252 268
253 void LostMouseLock() { 269 void LostMouseLock() {
254 browser()->LostMouseLock(); 270 browser()->LostMouseLock();
255 } 271 }
256 272
273 bool SendEscapeToFullscreenController() {
274 return browser()->fullscreen_controller_->HandleUserPressedEscape();
275 }
276
257 bool IsFullscreenForBrowser() { 277 bool IsFullscreenForBrowser() {
258 return browser()->fullscreen_controller_->IsFullscreenForBrowser(); 278 return browser()->fullscreen_controller_->IsFullscreenForBrowser();
259 } 279 }
260 280
261 bool IsFullscreenForTabOrPending() { 281 bool IsFullscreenForTabOrPending() {
262 return browser()->IsFullscreenForTabOrPending(); 282 return browser()->IsFullscreenForTabOrPending();
263 } 283 }
264 284
265 bool IsMouseLocked() { 285 bool IsMouseLocked() {
286 // Verify that IsMouseLocked is consistent between the
287 // Fullscreen Controller and the Render View Host View.
288 EXPECT_TRUE(browser()->IsMouseLocked() ==
289 browser()->GetSelectedWebContents()->
290 GetRenderViewHost()->GetView()->IsMouseLocked());
266 return browser()->IsMouseLocked(); 291 return browser()->IsMouseLocked();
267 } 292 }
268 293
269 bool IsMouseLockPermissionRequested() { 294 bool IsMouseLockPermissionRequested() {
270 FullscreenExitBubbleType type = 295 FullscreenExitBubbleType type =
271 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 296 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
272 bool mouse_lock = false; 297 bool mouse_lock = false;
273 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); 298 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock);
274 return mouse_lock; 299 return mouse_lock;
275 } 300 }
276 301
277 bool IsFullscreenPermissionRequested() { 302 bool IsFullscreenPermissionRequested() {
278 FullscreenExitBubbleType type = 303 FullscreenExitBubbleType type =
279 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 304 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
280 bool fullscreen = false; 305 bool fullscreen = false;
281 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); 306 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL);
282 return fullscreen; 307 return fullscreen;
283 } 308 }
284 309
285 FullscreenExitBubbleType GetFullscreenExitBubbleType() { 310 FullscreenExitBubbleType GetFullscreenExitBubbleType() {
286 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 311 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
287 } 312 }
288 313
289 bool IsFullscreenBubbleDisplayed() { 314 bool IsFullscreenBubbleDisplayed() {
290 FullscreenExitBubbleType type = 315 FullscreenExitBubbleType type =
291 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 316 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
292 // TODO(scheib): Should be FEB_TYPE_NONE, crbug.com/107013 will include fix. 317 return type != FEB_TYPE_NONE;
293 return type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
294 } 318 }
295 319
296 bool IsFullscreenBubbleDisplayingButtons() { 320 bool IsFullscreenBubbleDisplayingButtons() {
297 FullscreenExitBubbleType type = 321 FullscreenExitBubbleType type =
298 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 322 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
299 return fullscreen_bubble::ShowButtonsForType(type); 323 return fullscreen_bubble::ShowButtonsForType(type);
300 } 324 }
301 325
302 void AcceptCurrentFullscreenOrMouseLockRequest() { 326 void AcceptCurrentFullscreenOrMouseLockRequest() {
303 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); 327 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
304 FullscreenExitBubbleType type = 328 FullscreenExitBubbleType type =
305 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); 329 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
306 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); 330 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type);
307 } 331 }
308 332
333 void DenyCurrentFullscreenOrMouseLockRequest() {
334 FullscreenExitBubbleType type =
335 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
336 browser()->OnDenyFullscreenPermission(type);
337 }
338
309 // Helper method to be called by multiple tests. 339 // Helper method to be called by multiple tests.
310 void TestFullscreenMouseLockContentSettings(); 340 void TestFullscreenMouseLockContentSettings();
311 }; 341 };
312 342
313 // Launch the app on a page with no title, check that the app title was set 343 // Launch the app on a page with no title, check that the app title was set
314 // correctly. 344 // correctly.
315 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { 345 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) {
316 ui_test_utils::NavigateToURL(browser(), 346 ui_test_utils::NavigateToURL(browser(),
317 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 347 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
318 FilePath(kTitle1File))); 348 FilePath(kTitle1File)));
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1059
1030 // Request mouse lock and verify the bubble is waiting for user confirmation. 1060 // Request mouse lock and verify the bubble is waiting for user confirmation.
1031 RequestToLockMouse(fullscreen_tab, true); 1061 RequestToLockMouse(fullscreen_tab, true);
1032 ASSERT_TRUE(IsMouseLockPermissionRequested()); 1062 ASSERT_TRUE(IsMouseLockPermissionRequested());
1033 1063
1034 // Accept mouse lock and verify bubble no longer shows confirmation buttons. 1064 // Accept mouse lock and verify bubble no longer shows confirmation buttons.
1035 AcceptCurrentFullscreenOrMouseLockRequest(); 1065 AcceptCurrentFullscreenOrMouseLockRequest();
1036 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); 1066 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
1037 } 1067 }
1038 1068
1039 // Tests mouse lock fails before fullscreen is entered. 1069 // Tests mouse lock then fullscreen.
1040 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { 1070 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) {
1071 ASSERT_TRUE(test_server()->Start());
1072 ui_test_utils::NavigateToURL(browser(),
1073 test_server()->GetURL(kFullscreenMouseLockHTML));
1074
1041 WebContents* tab = browser()->GetSelectedWebContents(); 1075 WebContents* tab = browser()->GetSelectedWebContents();
1042 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); 1076
1043 1077 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1044 RequestToLockMouse(tab, true); 1078
1045 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); 1079 // Lock the mouse without a user gesture, expect no response.
1046 1080 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1081 browser(), ui::VKEY_D, false, false, false, false,
1082 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1083 content::NotificationService::AllSources()));
1084 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1085 ASSERT_FALSE(IsMouseLocked());
1086
1087 // Lock the mouse with a user gesture.
1088 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1089 browser(), ui::VKEY_1, false, false, false, false,
1090 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1091 content::NotificationService::AllSources()));
1092 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
1093 ASSERT_FALSE(IsFullscreenPermissionRequested());
1094 ASSERT_TRUE(IsMouseLockPermissionRequested());
1095 ASSERT_FALSE(IsMouseLocked());
1096
1097 // Accept mouse lock.
1098 AcceptCurrentFullscreenOrMouseLockRequest();
1099 ASSERT_TRUE(IsMouseLocked());
1100 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
1101
1102 // Enter fullscreen mode, mouse lock should be dropped to present buttons.
1047 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); 1103 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
1048 ASSERT_TRUE(IsFullscreenPermissionRequested()); 1104 ASSERT_TRUE(IsFullscreenPermissionRequested());
1049 ASSERT_FALSE(IsMouseLockPermissionRequested()); 1105 ASSERT_FALSE(IsMouseLockPermissionRequested());
1106 ASSERT_FALSE(IsMouseLocked());
1107
1108 // Request mouse lock also, expect fullscreen and mouse lock buttons.
1109 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1110 browser(), ui::VKEY_1, false, false, false, false,
1111 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1112 content::NotificationService::AllSources()));
1113 ASSERT_TRUE(IsFullscreenPermissionRequested());
1114 ASSERT_TRUE(IsMouseLockPermissionRequested());
1115 ASSERT_FALSE(IsMouseLocked());
1116
1117 // Accept fullscreen and mouse lock.
1118 AcceptCurrentFullscreenOrMouseLockRequest();
1119 ASSERT_TRUE(IsMouseLocked());
1120 ASSERT_TRUE(IsFullscreenForTabOrPending());
1121 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
1122 }
1123
1124 // Tests mouse lock then fullscreen in same request.
1125 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockAndFullscreen) {
1126 ASSERT_TRUE(test_server()->Start());
1127 ui_test_utils::NavigateToURL(browser(),
1128 test_server()->GetURL(kFullscreenMouseLockHTML));
1129
1130 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1131
1132 // Request to lock the mouse and enter fullscreen.
1133 {
1134 FullscreenNotificationObserver fullscreen_observer;
1135 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1136 browser(), ui::VKEY_B, false, true, false, false,
1137 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1138 content::NotificationService::AllSources()));
1139 fullscreen_observer.Wait();
1140 }
1141 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
1142 ASSERT_TRUE(IsFullscreenPermissionRequested());
1143 ASSERT_TRUE(IsMouseLockPermissionRequested());
1144 ASSERT_FALSE(IsMouseLocked());
1145 ASSERT_TRUE(IsFullscreenForTabOrPending());
1146
1147 // Deny both first, to make sure we can.
1148 {
1149 FullscreenNotificationObserver fullscreen_observer;
1150 DenyCurrentFullscreenOrMouseLockRequest();
1151 fullscreen_observer.Wait();
1152 }
1153 ASSERT_FALSE(IsMouseLocked());
1154 ASSERT_FALSE(IsFullscreenForTabOrPending());
1155 ASSERT_FALSE(IsFullscreenPermissionRequested());
1156
1157 // Request to lock the mouse and enter fullscreen.
1158 {
1159 FullscreenNotificationObserver fullscreen_observer;
1160 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1161 browser(), ui::VKEY_B, false, true, false, false,
1162 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1163 content::NotificationService::AllSources()));
1164 fullscreen_observer.Wait();
1165 }
1166 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
1167 ASSERT_TRUE(IsFullscreenPermissionRequested());
1168 ASSERT_TRUE(IsMouseLockPermissionRequested());
1169 ASSERT_FALSE(IsMouseLocked());
1170 ASSERT_TRUE(IsFullscreenForTabOrPending());
1171
1172 // Accept both, confirm they are enabled and there is no prompt.
1173 AcceptCurrentFullscreenOrMouseLockRequest();
1174 ASSERT_TRUE(IsMouseLocked());
1175 ASSERT_TRUE(IsFullscreenForTabOrPending());
1176 ASSERT_FALSE(IsFullscreenPermissionRequested());
1177 }
1178
1179 // Tests mouse lock can be escaped with ESC key.
1180 IN_PROC_BROWSER_TEST_F(BrowserTest, EscapingMouseLock) {
1181 ASSERT_TRUE(test_server()->Start());
1182 ui_test_utils::NavigateToURL(browser(),
1183 test_server()->GetURL(kFullscreenMouseLockHTML));
1184
1185 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1186
1187 // Request to lock the mouse.
1188 {
1189 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1190 browser(), ui::VKEY_1, false, false, false, false,
1191 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1192 content::NotificationService::AllSources()));
1193 }
1194 ASSERT_FALSE(IsFullscreenPermissionRequested());
1195 ASSERT_TRUE(IsMouseLockPermissionRequested());
1196
1197 // Escape, no prompts should remain.
1198 SendEscapeToFullscreenController();
1199 ASSERT_FALSE(IsFullscreenPermissionRequested());
1200 ASSERT_FALSE(IsMouseLockPermissionRequested());
1201
1202 // Request to lock the mouse.
1203 {
1204 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1205 browser(), ui::VKEY_1, false, false, false, false,
1206 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1207 content::NotificationService::AllSources()));
1208 }
1209 ASSERT_FALSE(IsFullscreenPermissionRequested());
1210 ASSERT_TRUE(IsMouseLockPermissionRequested());
1211
1212 // Accept mouse lock, confirm it and that there is no prompt.
1213 AcceptCurrentFullscreenOrMouseLockRequest();
1214 ASSERT_TRUE(IsMouseLocked());
1215 ASSERT_FALSE(IsFullscreenForTabOrPending());
1216 ASSERT_FALSE(IsFullscreenPermissionRequested());
1217 ASSERT_FALSE(IsMouseLockPermissionRequested());
1218
1219 // Escape, confirm we are out of mouse lock with no prompts.
1220 SendEscapeToFullscreenController();
1221 ASSERT_FALSE(IsMouseLocked());
1222 ASSERT_FALSE(IsFullscreenForTabOrPending());
1223 ASSERT_FALSE(IsFullscreenPermissionRequested());
1224 ASSERT_FALSE(IsMouseLockPermissionRequested());
1225 }
1226
1227 // Tests mouse lock and fullscreen modes can be escaped with ESC key.
1228 IN_PROC_BROWSER_TEST_F(BrowserTest, EscapingMouseLockAndFullscreen) {
1229 ASSERT_TRUE(test_server()->Start());
1230 ui_test_utils::NavigateToURL(browser(),
1231 test_server()->GetURL(kFullscreenMouseLockHTML));
1232
1233 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1234
1235 // Request to lock the mouse and enter fullscreen.
1236 {
1237 FullscreenNotificationObserver fullscreen_observer;
1238 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1239 browser(), ui::VKEY_B, false, true, false, false,
1240 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1241 content::NotificationService::AllSources()));
1242 fullscreen_observer.Wait();
1243 }
1244 ASSERT_TRUE(IsFullscreenPermissionRequested());
1245 ASSERT_TRUE(IsMouseLockPermissionRequested());
1246
1247 // Escape, no prompts should remain.
1248 {
1249 FullscreenNotificationObserver fullscreen_observer;
1250 SendEscapeToFullscreenController();
1251 fullscreen_observer.Wait();
1252 }
1253 ASSERT_FALSE(IsFullscreenPermissionRequested());
1254 ASSERT_FALSE(IsMouseLockPermissionRequested());
1255
1256 // Request to lock the mouse and enter fullscreen.
1257 {
1258 FullscreenNotificationObserver fullscreen_observer;
1259 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
1260 browser(), ui::VKEY_B, false, true, false, false,
1261 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
1262 content::NotificationService::AllSources()));
1263 fullscreen_observer.Wait();
1264 }
1265 ASSERT_TRUE(IsFullscreenPermissionRequested());
1266 ASSERT_TRUE(IsMouseLockPermissionRequested());
1267
1268 // Accept both, confirm mouse lock and fullscreen and no prompts.
1269 AcceptCurrentFullscreenOrMouseLockRequest();
1270 ASSERT_TRUE(IsMouseLocked());
1271 ASSERT_TRUE(IsFullscreenForTabOrPending());
1272 ASSERT_FALSE(IsFullscreenPermissionRequested());
1273 ASSERT_FALSE(IsMouseLockPermissionRequested());
1274
1275 // Escape, confirm we are out of mouse lock and fullscreen with no prompts.
1276 {
1277 FullscreenNotificationObserver fullscreen_observer;
1278 SendEscapeToFullscreenController();
1279 fullscreen_observer.Wait();
1280 }
1281 ASSERT_FALSE(IsMouseLocked());
1282 ASSERT_FALSE(IsFullscreenForTabOrPending());
1283 ASSERT_FALSE(IsFullscreenPermissionRequested());
1284 ASSERT_FALSE(IsMouseLockPermissionRequested());
1050 } 1285 }
1051 1286
1052 // Helper method to be called by multiple tests. 1287 // Helper method to be called by multiple tests.
1053 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. 1288 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
1054 void BrowserTest::TestFullscreenMouseLockContentSettings() { 1289 void BrowserTest::TestFullscreenMouseLockContentSettings() {
1055 GURL url = test_server()->GetURL("simple.html"); 1290 GURL url = test_server()->GetURL("simple.html");
1056 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); 1291 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
1057 WebContents* tab = browser()->GetSelectedWebContents(); 1292 WebContents* tab = browser()->GetSelectedWebContents();
1058 1293
1059 // Validate that going fullscreen for a URL defaults to asking permision. 1294 // Validate that going fullscreen for a URL defaults to asking permision.
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 command_line->AppendSwitchASCII(switches::kApp, url.spec()); 2137 command_line->AppendSwitchASCII(switches::kApp, url.spec());
1903 } 2138 }
1904 }; 2139 };
1905 2140
1906 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { 2141 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) {
1907 // Test that an application browser window loads correctly. 2142 // Test that an application browser window loads correctly.
1908 2143
1909 // Verify the browser is in application mode. 2144 // Verify the browser is in application mode.
1910 EXPECT_TRUE(browser()->IsApplication()); 2145 EXPECT_TRUE(browser()->IsApplication());
1911 } 2146 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | chrome/browser/ui/fullscreen_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698