| 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 <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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); | 240 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen); |
| 241 FullscreenNotificationObserver fullscreen_observer; | 241 FullscreenNotificationObserver fullscreen_observer; |
| 242 | 242 |
| 243 browser()->ToggleFullscreenMode(); | 243 browser()->ToggleFullscreenMode(); |
| 244 | 244 |
| 245 fullscreen_observer.Wait(); | 245 fullscreen_observer.Wait(); |
| 246 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | 246 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); |
| 247 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); | 247 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void RequestToLockMouse(content::WebContents* tab) { | 250 void RequestToLockMouse(content::WebContents* tab, bool user_gesture) { |
| 251 browser()->RequestToLockMouse(tab); | 251 browser()->RequestToLockMouse(tab, user_gesture); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void LostMouseLock() { | 254 void LostMouseLock() { |
| 255 browser()->LostMouseLock(); | 255 browser()->LostMouseLock(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool IsFullscreenForBrowser() { | 258 bool IsFullscreenForBrowser() { |
| 259 return browser()->fullscreen_controller_->IsFullscreenForBrowser(); | 259 return browser()->fullscreen_controller_->IsFullscreenForBrowser(); |
| 260 } | 260 } |
| 261 | 261 |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 1021 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), |
| 1022 content::PAGE_TRANSITION_TYPED); | 1022 content::PAGE_TRANSITION_TYPED); |
| 1023 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), | 1023 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), |
| 1024 content::PAGE_TRANSITION_TYPED); | 1024 content::PAGE_TRANSITION_TYPED); |
| 1025 | 1025 |
| 1026 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 1026 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); |
| 1027 | 1027 |
| 1028 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 1028 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 1029 | 1029 |
| 1030 // Request mouse lock and verify the bubble is waiting for user confirmation. | 1030 // Request mouse lock and verify the bubble is waiting for user confirmation. |
| 1031 RequestToLockMouse(fullscreen_tab); | 1031 RequestToLockMouse(fullscreen_tab, true); |
| 1032 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 1032 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 1033 | 1033 |
| 1034 // Accept mouse lock and verify bubble no longer shows confirmation buttons. | 1034 // Accept mouse lock and verify bubble no longer shows confirmation buttons. |
| 1035 AcceptCurrentFullscreenOrMouseLockRequest(); | 1035 AcceptCurrentFullscreenOrMouseLockRequest(); |
| 1036 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); | 1036 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 // Tests mouse lock fails before fullscreen is entered. | 1039 // Tests mouse lock fails before fullscreen is entered. |
| 1040 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { | 1040 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { |
| 1041 WebContents* tab = browser()->GetSelectedWebContents(); | 1041 WebContents* tab = browser()->GetSelectedWebContents(); |
| 1042 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | 1042 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
| 1043 | 1043 |
| 1044 RequestToLockMouse(tab); | 1044 RequestToLockMouse(tab, true); |
| 1045 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | 1045 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); |
| 1046 | 1046 |
| 1047 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 1047 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| 1048 ASSERT_TRUE(IsFullscreenPermissionRequested()); | 1048 ASSERT_TRUE(IsFullscreenPermissionRequested()); |
| 1049 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1049 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 // Helper method to be called by multiple tests. | 1052 // Helper method to be called by multiple tests. |
| 1053 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | 1053 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. |
| 1054 void BrowserTest::TestFullscreenMouseLockContentSettings() { | 1054 void BrowserTest::TestFullscreenMouseLockContentSettings() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1075 // Now, fullscreen should not prompt for permission. | 1075 // Now, fullscreen should not prompt for permission. |
| 1076 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 1076 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 1077 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 1077 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
| 1078 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 1078 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
| 1079 | 1079 |
| 1080 // Leaving tab in fullscreen, now test mouse lock ALLOW: | 1080 // Leaving tab in fullscreen, now test mouse lock ALLOW: |
| 1081 | 1081 |
| 1082 // Validate that mouse lock defaults to asking permision. | 1082 // Validate that mouse lock defaults to asking permision. |
| 1083 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1083 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1084 ASSERT_FALSE(IsMouseLockedOrPending()); | 1084 ASSERT_FALSE(IsMouseLockedOrPending()); |
| 1085 RequestToLockMouse(tab); | 1085 RequestToLockMouse(tab, true); |
| 1086 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 1086 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 1087 ASSERT_TRUE(IsMouseLockedOrPending()); | 1087 ASSERT_TRUE(IsMouseLockedOrPending()); |
| 1088 LostMouseLock(); | 1088 LostMouseLock(); |
| 1089 | 1089 |
| 1090 // Add content setting to ALLOW mouse lock. | 1090 // Add content setting to ALLOW mouse lock. |
| 1091 settings_map->SetContentSetting( | 1091 settings_map->SetContentSetting( |
| 1092 pattern, ContentSettingsPattern::Wildcard(), | 1092 pattern, ContentSettingsPattern::Wildcard(), |
| 1093 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | 1093 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), |
| 1094 CONTENT_SETTING_ALLOW); | 1094 CONTENT_SETTING_ALLOW); |
| 1095 | 1095 |
| 1096 // Now, mouse lock should not prompt for permission. | 1096 // Now, mouse lock should not prompt for permission. |
| 1097 ASSERT_FALSE(IsMouseLockedOrPending()); | 1097 ASSERT_FALSE(IsMouseLockedOrPending()); |
| 1098 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1098 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1099 RequestToLockMouse(tab); | 1099 RequestToLockMouse(tab, true); |
| 1100 ASSERT_TRUE(IsMouseLockedOrPending()); | 1100 ASSERT_TRUE(IsMouseLockedOrPending()); |
| 1101 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1101 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1102 LostMouseLock(); | 1102 LostMouseLock(); |
| 1103 | 1103 |
| 1104 // Leaving tab in fullscreen, now test mouse lock BLOCK: | 1104 // Leaving tab in fullscreen, now test mouse lock BLOCK: |
| 1105 | 1105 |
| 1106 // Add content setting to BLOCK mouse lock. | 1106 // Add content setting to BLOCK mouse lock. |
| 1107 settings_map->SetContentSetting( | 1107 settings_map->SetContentSetting( |
| 1108 pattern, ContentSettingsPattern::Wildcard(), | 1108 pattern, ContentSettingsPattern::Wildcard(), |
| 1109 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | 1109 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), |
| 1110 CONTENT_SETTING_BLOCK); | 1110 CONTENT_SETTING_BLOCK); |
| 1111 | 1111 |
| 1112 // Now, mouse lock should not be pending. | 1112 // Now, mouse lock should not be pending. |
| 1113 ASSERT_FALSE(IsMouseLockedOrPending()); | 1113 ASSERT_FALSE(IsMouseLockedOrPending()); |
| 1114 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1114 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1115 RequestToLockMouse(tab); | 1115 RequestToLockMouse(tab, true); |
| 1116 ASSERT_FALSE(IsMouseLockedOrPending()); | 1116 ASSERT_FALSE(IsMouseLockedOrPending()); |
| 1117 ASSERT_FALSE(IsMouseLockPermissionRequested()); | 1117 ASSERT_FALSE(IsMouseLockPermissionRequested()); |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | 1120 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. |
| 1121 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) { | 1121 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) { |
| 1122 TestFullscreenMouseLockContentSettings(); | 1122 TestFullscreenMouseLockContentSettings(); |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK, | 1125 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK, |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 | 1743 |
| 1744 // The normal browser should now have four. | 1744 // The normal browser should now have four. |
| 1745 EXPECT_EQ(4, browser()->tab_count()); | 1745 EXPECT_EQ(4, browser()->tab_count()); |
| 1746 | 1746 |
| 1747 // Close the additional browsers. | 1747 // Close the additional browsers. |
| 1748 popup_browser->CloseAllTabs(); | 1748 popup_browser->CloseAllTabs(); |
| 1749 app_browser->CloseAllTabs(); | 1749 app_browser->CloseAllTabs(); |
| 1750 app_popup_browser->CloseAllTabs(); | 1750 app_popup_browser->CloseAllTabs(); |
| 1751 } | 1751 } |
| 1752 #endif | 1752 #endif |
| OLD | NEW |