| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 namespace extensions { | 39 namespace extensions { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 class WebstoreInstallListener : public WebstoreInstaller::Delegate { | 43 class WebstoreInstallListener : public WebstoreInstaller::Delegate { |
| 44 public: | 44 public: |
| 45 WebstoreInstallListener() | 45 WebstoreInstallListener() |
| 46 : received_failure_(false), received_success_(false), waiting_(false) {} | 46 : received_failure_(false), received_success_(false), waiting_(false) {} |
| 47 | 47 |
| 48 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE { | 48 virtual void OnExtensionInstallSuccess(const std::string& id) override { |
| 49 received_success_ = true; | 49 received_success_ = true; |
| 50 id_ = id; | 50 id_ = id; |
| 51 | 51 |
| 52 if (waiting_) { | 52 if (waiting_) { |
| 53 waiting_ = false; | 53 waiting_ = false; |
| 54 base::MessageLoopForUI::current()->Quit(); | 54 base::MessageLoopForUI::current()->Quit(); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual void OnExtensionInstallFailure( | 58 virtual void OnExtensionInstallFailure( |
| 59 const std::string& id, | 59 const std::string& id, |
| 60 const std::string& error, | 60 const std::string& error, |
| 61 WebstoreInstaller::FailureReason reason) OVERRIDE { | 61 WebstoreInstaller::FailureReason reason) override { |
| 62 received_failure_ = true; | 62 received_failure_ = true; |
| 63 id_ = id; | 63 id_ = id; |
| 64 error_ = error; | 64 error_ = error; |
| 65 | 65 |
| 66 if (waiting_) { | 66 if (waiting_) { |
| 67 waiting_ = false; | 67 waiting_ = false; |
| 68 base::MessageLoopForUI::current()->Quit(); | 68 base::MessageLoopForUI::current()->Quit(); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // namespace | 90 } // namespace |
| 91 | 91 |
| 92 // A base class for tests below. | 92 // A base class for tests below. |
| 93 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { | 93 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { |
| 94 public: | 94 public: |
| 95 ExtensionWebstorePrivateApiTest() {} | 95 ExtensionWebstorePrivateApiTest() {} |
| 96 virtual ~ExtensionWebstorePrivateApiTest() {} | 96 virtual ~ExtensionWebstorePrivateApiTest() {} |
| 97 | 97 |
| 98 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 98 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 99 ExtensionApiTest::SetUpCommandLine(command_line); | 99 ExtensionApiTest::SetUpCommandLine(command_line); |
| 100 command_line->AppendSwitchASCII( | 100 command_line->AppendSwitchASCII( |
| 101 switches::kAppsGalleryURL, | 101 switches::kAppsGalleryURL, |
| 102 "http://www.example.com/files/extensions/api_test"); | 102 "http://www.example.com/files/extensions/api_test"); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 105 virtual void SetUpInProcessBrowserTestFixture() override { |
| 106 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 106 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 107 | 107 |
| 108 // Start up the test server and get us ready for calling the install | 108 // Start up the test server and get us ready for calling the install |
| 109 // API functions. | 109 // API functions. |
| 110 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 110 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 111 ASSERT_TRUE(StartSpawnedTestServer()); | 111 ASSERT_TRUE(StartSpawnedTestServer()); |
| 112 ExtensionInstallUI::set_disable_failure_ui_for_tests(); | 112 ExtensionInstallUI::set_disable_failure_ui_for_tests(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual void SetUpOnMainThread() OVERRIDE { | 115 virtual void SetUpOnMainThread() override { |
| 116 ExtensionApiTest::SetUpOnMainThread(); | 116 ExtensionApiTest::SetUpOnMainThread(); |
| 117 | 117 |
| 118 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 118 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
| 119 ExtensionInstallPrompt::ACCEPT; | 119 ExtensionInstallPrompt::ACCEPT; |
| 120 | 120 |
| 121 ASSERT_TRUE(webstore_install_dir_.CreateUniqueTempDir()); | 121 ASSERT_TRUE(webstore_install_dir_.CreateUniqueTempDir()); |
| 122 webstore_install_dir_copy_ = webstore_install_dir_.path(); | 122 webstore_install_dir_copy_ = webstore_install_dir_.path(); |
| 123 WebstoreInstaller::SetDownloadDirectoryForTests( | 123 WebstoreInstaller::SetDownloadDirectoryForTests( |
| 124 &webstore_install_dir_copy_); | 124 &webstore_install_dir_copy_); |
| 125 } | 125 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 EXPECT_TRUE(content::GpuDataManager::GetInstance()->IsFeatureBlacklisted( | 391 EXPECT_TRUE(content::GpuDataManager::GetInstance()->IsFeatureBlacklisted( |
| 392 gpu::GPU_FEATURE_TYPE_WEBGL)); | 392 gpu::GPU_FEATURE_TYPE_WEBGL)); |
| 393 | 393 |
| 394 bool webgl_allowed = false; | 394 bool webgl_allowed = false; |
| 395 RunTest(webgl_allowed); | 395 RunTest(webgl_allowed); |
| 396 } | 396 } |
| 397 | 397 |
| 398 class EphemeralAppWebstorePrivateApiTest | 398 class EphemeralAppWebstorePrivateApiTest |
| 399 : public ExtensionWebstorePrivateApiTest { | 399 : public ExtensionWebstorePrivateApiTest { |
| 400 public: | 400 public: |
| 401 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 401 virtual void SetUpInProcessBrowserTestFixture() override { |
| 402 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture(); | 402 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture(); |
| 403 | 403 |
| 404 net::HostPortPair host_port = test_server()->host_port_pair(); | 404 net::HostPortPair host_port = test_server()->host_port_pair(); |
| 405 std::string test_gallery_url = base::StringPrintf( | 405 std::string test_gallery_url = base::StringPrintf( |
| 406 "http://www.example.com:%d/files/extensions/platform_apps/" | 406 "http://www.example.com:%d/files/extensions/platform_apps/" |
| 407 "ephemeral_launcher", | 407 "ephemeral_launcher", |
| 408 host_port.port()); | 408 host_port.port()); |
| 409 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 409 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 410 switches::kAppsGalleryURL, test_gallery_url); | 410 switches::kAppsGalleryURL, test_gallery_url); |
| 411 } | 411 } |
| 412 | 412 |
| 413 virtual GURL GetTestServerURL(const std::string& path) OVERRIDE { | 413 virtual GURL GetTestServerURL(const std::string& path) override { |
| 414 return DoGetTestServerURL( | 414 return DoGetTestServerURL( |
| 415 std::string("files/extensions/platform_apps/ephemeral_launcher/") + | 415 std::string("files/extensions/platform_apps/ephemeral_launcher/") + |
| 416 path); | 416 path); |
| 417 } | 417 } |
| 418 }; | 418 }; |
| 419 | 419 |
| 420 // Run tests when the --enable-ephemeral-apps switch is not enabled. | 420 // Run tests when the --enable-ephemeral-apps switch is not enabled. |
| 421 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, | 421 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, |
| 422 EphemeralAppsFeatureDisabled) { | 422 EphemeralAppsFeatureDisabled) { |
| 423 ASSERT_TRUE(RunInstallTest("webstore_launch_disabled.html", "app.crx")); | 423 ASSERT_TRUE(RunInstallTest("webstore_launch_disabled.html", "app.crx")); |
| 424 } | 424 } |
| 425 | 425 |
| 426 // Run tests when the --enable-ephemeral-apps switch is enabled. | 426 // Run tests when the --enable-ephemeral-apps switch is enabled. |
| 427 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, LaunchEphemeralApp) { | 427 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, LaunchEphemeralApp) { |
| 428 CommandLine::ForCurrentProcess()->AppendSwitch( | 428 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 429 switches::kEnableEphemeralApps); | 429 switches::kEnableEphemeralApps); |
| 430 ASSERT_TRUE(RunInstallTest("webstore_launch_app.html", "app.crx")); | 430 ASSERT_TRUE(RunInstallTest("webstore_launch_app.html", "app.crx")); |
| 431 } | 431 } |
| 432 | 432 |
| 433 } // namespace extensions | 433 } // namespace extensions |
| OLD | NEW |