| 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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
| 6 #include "chrome/browser/extensions/extension_test_message_listener.h" | 6 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 7 #include "chrome/browser/ui/extensions/application_launch.h" | 7 #include "chrome/browser/ui/extensions/application_launch.h" |
| 8 #include "chrome/test/base/interactive_test_utils.h" | 8 #include "chrome/test/base/interactive_test_utils.h" |
| 9 | 9 |
| 10 class ExtensionPointerLockTest : public extensions::PlatformAppBrowserTest { | 10 class ExtensionPointerLockTest : public extensions::PlatformAppBrowserTest { |
| 11 public: | 11 public: |
| 12 bool RunExtensionPointerLockTest(const char* app_path) { | 12 bool RunExtensionPointerLockTest(const char* app_path) { |
| 13 ExtensionTestMessageListener launched_listener("Launched", true); | 13 ExtensionTestMessageListener launched_listener("Launched", true); |
| 14 LoadAndLaunchPlatformApp(app_path); | 14 LoadAndLaunchPlatformApp(app_path); |
| 15 if (!launched_listener.WaitUntilSatisfied()) { | 15 if (!launched_listener.WaitUntilSatisfied()) { |
| 16 message_ = "Did not get the 'Launched' message."; | 16 message_ = "Did not get the 'Launched' message."; |
| 17 return false; | 17 return false; |
| 18 } | 18 } |
| 19 | 19 |
| 20 ResultCatcher catcher; | 20 ResultCatcher catcher; |
| 21 | 21 |
| 22 if (!ui_test_utils::ShowAndFocusNativeWindow( | 22 if (!ui_test_utils::ShowAndFocusNativeWindow( |
| 23 GetFirstShellWindow()->GetNativeWindow())) { | 23 GetFirstAppWindow()->GetNativeWindow())) { |
| 24 message_ = "Can't focus window"; | 24 message_ = "Can't focus window"; |
| 25 return false; | 25 return false; |
| 26 } | 26 } |
| 27 | 27 |
| 28 launched_listener.Reply(""); | 28 launched_listener.Reply(""); |
| 29 | 29 |
| 30 if (!catcher.GetNextResult()) { | 30 if (!catcher.GetNextResult()) { |
| 31 message_ = catcher.message(); | 31 message_ = catcher.message(); |
| 32 return false; | 32 return false; |
| 33 } | 33 } |
| 34 | 34 |
| 35 return true; | 35 return true; |
| 36 } | 36 } |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 IN_PROC_BROWSER_TEST_F(ExtensionPointerLockTest, | 39 IN_PROC_BROWSER_TEST_F(ExtensionPointerLockTest, |
| 40 ExtensionPointerLockAccessFail) { | 40 ExtensionPointerLockAccessFail) { |
| 41 // Test that pointer lock cannot be accessed from an extension without | 41 // Test that pointer lock cannot be accessed from an extension without |
| 42 // permission. | 42 // permission. |
| 43 ASSERT_TRUE(RunExtensionPointerLockTest("pointer_lock/no_permission")) | 43 ASSERT_TRUE(RunExtensionPointerLockTest("pointer_lock/no_permission")) |
| 44 << message_; | 44 << message_; |
| 45 } | 45 } |
| 46 | 46 |
| 47 IN_PROC_BROWSER_TEST_F(ExtensionPointerLockTest, | 47 IN_PROC_BROWSER_TEST_F(ExtensionPointerLockTest, |
| 48 ExtensionPointerLockAccessPass) { | 48 ExtensionPointerLockAccessPass) { |
| 49 // Test that pointer lock can be accessed from an extension with permission. | 49 // Test that pointer lock can be accessed from an extension with permission. |
| 50 ASSERT_TRUE(RunExtensionPointerLockTest("pointer_lock/has_permission")) | 50 ASSERT_TRUE(RunExtensionPointerLockTest("pointer_lock/has_permission")) |
| 51 << message_; | 51 << message_; |
| 52 } | 52 } |
| OLD | NEW |