| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "chrome/browser/apps/app_browsertest_util.h" | 7 #include "chrome/browser/apps/app_browsertest_util.h" |
| 8 #include "chrome/browser/lifetime/application_lifetime.h" | 8 #include "chrome/browser/lifetime/application_lifetime.h" |
| 9 #include "chrome/browser/lifetime/keep_alive_registry.h" | 9 #include "chrome/browser/lifetime/keep_alive_registry.h" |
| 10 #include "chrome/browser/lifetime/keep_alive_types.h" | 10 #include "chrome/browser/lifetime/keep_alive_types.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z)); | 87 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z)); |
| 88 content::RunAllPendingInMessageLoop(); | 88 content::RunAllPendingInMessageLoop(); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 // This test is a method so that we can test with each frame type. | 92 // This test is a method so that we can test with each frame type. |
| 93 void TestOuterBoundsHelper(const std::string& frame_type); | 93 void TestOuterBoundsHelper(const std::string& frame_type); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) { | 96 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) { |
| 97 // This test is flaky on MacOS 10.6. | |
| 98 #if defined(OS_MACOSX) | 97 #if defined(OS_MACOSX) |
| 99 if (base::mac::IsOSSnowLeopard()) | |
| 100 return; | |
| 101 | |
| 102 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; | 98 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; |
| 103 #endif | 99 #endif |
| 104 | 100 |
| 105 ExtensionTestMessageListener launched_listener("Launched", true); | 101 ExtensionTestMessageListener launched_listener("Launched", true); |
| 106 LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener); | 102 LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener); |
| 107 | 103 |
| 108 // We start by making sure the window is actually focused. | 104 // We start by making sure the window is actually focused. |
| 109 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( | 105 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 110 GetFirstAppWindow()->GetNativeWindow())); | 106 GetFirstAppWindow()->GetNativeWindow())); |
| 111 | 107 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 132 { | 128 { |
| 133 FullscreenChangeWaiter fs_changed(GetFirstAppWindow()->GetBaseWindow()); | 129 FullscreenChangeWaiter fs_changed(GetFirstAppWindow()->GetBaseWindow()); |
| 134 | 130 |
| 135 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); | 131 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); |
| 136 | 132 |
| 137 fs_changed.Wait(); | 133 fs_changed.Wait(); |
| 138 } | 134 } |
| 139 } | 135 } |
| 140 | 136 |
| 141 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) { | 137 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenDOM) { |
| 142 // This test is flaky on MacOS 10.6. | |
| 143 #if defined(OS_MACOSX) | 138 #if defined(OS_MACOSX) |
| 144 if (base::mac::IsOSSnowLeopard()) | |
| 145 return; | |
| 146 | |
| 147 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; | 139 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; |
| 148 #endif | 140 #endif |
| 149 | 141 |
| 150 ExtensionTestMessageListener launched_listener("Launched", true); | 142 ExtensionTestMessageListener launched_listener("Launched", true); |
| 151 LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener); | 143 LoadAndLaunchPlatformApp("leave_fullscreen", &launched_listener); |
| 152 | 144 |
| 153 // We start by making sure the window is actually focused. | 145 // We start by making sure the window is actually focused. |
| 154 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( | 146 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 155 GetFirstAppWindow()->GetNativeWindow())); | 147 GetFirstAppWindow()->GetNativeWindow())); |
| 156 | 148 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 185 FullscreenChangeWaiter fs_changed(GetFirstAppWindow()->GetBaseWindow()); | 177 FullscreenChangeWaiter fs_changed(GetFirstAppWindow()->GetBaseWindow()); |
| 186 | 178 |
| 187 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); | 179 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_ESCAPE)); |
| 188 | 180 |
| 189 fs_changed.Wait(); | 181 fs_changed.Wait(); |
| 190 } | 182 } |
| 191 } | 183 } |
| 192 | 184 |
| 193 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, | 185 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, |
| 194 ESCDoesNotLeaveFullscreenWindow) { | 186 ESCDoesNotLeaveFullscreenWindow) { |
| 195 // This test is flaky on MacOS 10.6. | |
| 196 #if defined(OS_MACOSX) | 187 #if defined(OS_MACOSX) |
| 197 if (base::mac::IsOSSnowLeopard()) | |
| 198 return; | |
| 199 | |
| 200 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; | 188 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; |
| 201 #endif | 189 #endif |
| 202 | 190 |
| 203 ExtensionTestMessageListener launched_listener("Launched", true); | 191 ExtensionTestMessageListener launched_listener("Launched", true); |
| 204 LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener); | 192 LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener); |
| 205 | 193 |
| 206 // We start by making sure the window is actually focused. | 194 // We start by making sure the window is actually focused. |
| 207 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( | 195 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 208 GetFirstAppWindow()->GetNativeWindow())); | 196 GetFirstAppWindow()->GetNativeWindow())); |
| 209 | 197 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 235 | 223 |
| 236 // We assume that at that point, if we had to leave fullscreen, we should be. | 224 // We assume that at that point, if we had to leave fullscreen, we should be. |
| 237 // However, by nature, we can not guarantee that and given that we do test | 225 // However, by nature, we can not guarantee that and given that we do test |
| 238 // that nothing happens, we might end up with random-success when the feature | 226 // that nothing happens, we might end up with random-success when the feature |
| 239 // is broken. | 227 // is broken. |
| 240 EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen()); | 228 EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen()); |
| 241 } | 229 } |
| 242 | 230 |
| 243 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, | 231 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, |
| 244 ESCDoesNotLeaveFullscreenDOM) { | 232 ESCDoesNotLeaveFullscreenDOM) { |
| 245 // This test is flaky on MacOS 10.6. | |
| 246 #if defined(OS_MACOSX) | 233 #if defined(OS_MACOSX) |
| 247 if (base::mac::IsOSSnowLeopard()) | |
| 248 return; | |
| 249 | |
| 250 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; | 234 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; |
| 251 #endif | 235 #endif |
| 252 | 236 |
| 253 ExtensionTestMessageListener launched_listener("Launched", true); | 237 ExtensionTestMessageListener launched_listener("Launched", true); |
| 254 LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener); | 238 LoadAndLaunchPlatformApp("prevent_leave_fullscreen", &launched_listener); |
| 255 | 239 |
| 256 // We start by making sure the window is actually focused. | 240 // We start by making sure the window is actually focused. |
| 257 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( | 241 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 258 GetFirstAppWindow()->GetNativeWindow())); | 242 GetFirstAppWindow()->GetNativeWindow())); |
| 259 | 243 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // that nothing happens, we might end up with random-success when the feature | 279 // that nothing happens, we might end up with random-success when the feature |
| 296 // is broken. | 280 // is broken. |
| 297 EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen()); | 281 EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen()); |
| 298 } | 282 } |
| 299 | 283 |
| 300 // This test is duplicated from ESCDoesNotLeaveFullscreenWindow. | 284 // This test is duplicated from ESCDoesNotLeaveFullscreenWindow. |
| 301 // It runs the same test, but uses the old permission names: 'fullscreen' | 285 // It runs the same test, but uses the old permission names: 'fullscreen' |
| 302 // and 'overrideEscFullscreen'. | 286 // and 'overrideEscFullscreen'. |
| 303 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, | 287 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, |
| 304 ESCDoesNotLeaveFullscreenOldPermission) { | 288 ESCDoesNotLeaveFullscreenOldPermission) { |
| 305 // This test is flaky on MacOS 10.6. | |
| 306 #if defined(OS_MACOSX) | 289 #if defined(OS_MACOSX) |
| 307 if (base::mac::IsOSSnowLeopard()) | |
| 308 return; | |
| 309 | |
| 310 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; | 290 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; |
| 311 #endif | 291 #endif |
| 312 | 292 |
| 313 ExtensionTestMessageListener launched_listener("Launched", true); | 293 ExtensionTestMessageListener launched_listener("Launched", true); |
| 314 LoadAndLaunchPlatformApp("prevent_leave_fullscreen_old", &launched_listener); | 294 LoadAndLaunchPlatformApp("prevent_leave_fullscreen_old", &launched_listener); |
| 315 | 295 |
| 316 // We start by making sure the window is actually focused. | 296 // We start by making sure the window is actually focused. |
| 317 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( | 297 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow( |
| 318 GetFirstAppWindow()->GetNativeWindow())); | 298 GetFirstAppWindow()->GetNativeWindow())); |
| 319 | 299 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 ExtensionTestMessageListener shown_listener("Shown", false); | 561 ExtensionTestMessageListener shown_listener("Shown", false); |
| 582 launched_listener.Reply(""); | 562 launched_listener.Reply(""); |
| 583 EXPECT_TRUE(shown_listener.WaitUntilSatisfied()); | 563 EXPECT_TRUE(shown_listener.WaitUntilSatisfied()); |
| 584 EXPECT_FALSE(app_window->is_hidden()); | 564 EXPECT_FALSE(app_window->is_hidden()); |
| 585 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( | 565 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( |
| 586 KeepAliveOrigin::CHROME_APP_DELEGATE)); | 566 KeepAliveOrigin::CHROME_APP_DELEGATE)); |
| 587 app_window->GetBaseWindow()->Close(); | 567 app_window->GetBaseWindow()->Close(); |
| 588 } | 568 } |
| 589 | 569 |
| 590 #endif | 570 #endif |
| OLD | NEW |