Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/test/launcher/unit_test_launcher.h" | 11 #include "base/test/launcher/unit_test_launcher.h" |
| 12 #include "base/test/test_io_thread.h" | 12 #include "base/test/test_io_thread.h" |
| 13 #include "content/public/common/content_client.h" | 13 #include "content/public/common/content_client.h" |
| 14 #include "content/public/test/content_test_suite_base.h" | 14 #include "content/public/test/content_test_suite_base.h" |
| 15 #include "content/public/test/unittest_test_suite.h" | 15 #include "content/public/test/unittest_test_suite.h" |
| 16 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
| 17 #include "extensions/common/extension_paths.h" | 17 #include "extensions/common/extension_paths.h" |
| 18 #include "extensions/test/test_extensions_client.h" | 18 #include "extensions/test/test_extensions_client.h" |
| 19 #include "mojo/edk/test/scoped_ipc_support.h" | 19 #include "mojo/edk/test/scoped_ipc_support.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gl/test/gl_surface_test_support.h" | 21 #include "ui/gl/test/gl_surface_test_support.h" |
| 22 #include "url/url_util.h" | 22 #include "url/url_util.h" |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const int kNumExtensionStandardURLSchemes = 2; | 26 const url::SchemeWithType kExtensionStandardURLSchemes[] = { |
|
James Cook
2016/12/14 20:41:50
ditto
ncarter (slow)
2016/12/14 22:26:42
Done.
| |
| 27 const url::SchemeWithType kExtensionStandardURLSchemes[ | 27 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, |
| 28 kNumExtensionStandardURLSchemes] = { | |
| 29 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, | |
| 30 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, | |
| 31 }; | 28 }; |
| 32 | 29 |
| 33 // Content client that exists only to register chrome-extension:// scheme with | 30 // Content client that exists only to register chrome-extension:// scheme with |
| 34 // the url module. | 31 // the url module. |
| 35 // TODO(jamescook): Should this be merged with ShellContentClient? Should this | 32 // TODO(jamescook): Should this be merged with ShellContentClient? Should this |
| 36 // be a persistent object available to tests? | 33 // be a persistent object available to tests? |
| 37 class ExtensionsContentClient : public content::ContentClient { | 34 class ExtensionsContentClient : public content::ContentClient { |
| 38 public: | 35 public: |
| 39 ExtensionsContentClient() {} | 36 ExtensionsContentClient() {} |
| 40 ~ExtensionsContentClient() override {} | 37 ~ExtensionsContentClient() override {} |
| 41 | 38 |
| 42 // content::ContentClient overrides: | 39 // content::ContentClient overrides: |
| 43 void AddAdditionalSchemes( | 40 void AddAdditionalSchemes( |
| 44 std::vector<url::SchemeWithType>* standard_schemes, | 41 std::vector<url::SchemeWithType>* standard_schemes, |
| 45 std::vector<url::SchemeWithType>* referrer_schemes, | 42 std::vector<url::SchemeWithType>* referrer_schemes, |
| 46 std::vector<std::string>* savable_schemes) override { | 43 std::vector<std::string>* savable_schemes) override { |
| 47 for (int i = 0; i < kNumExtensionStandardURLSchemes; i++) | 44 for (const url::SchemeWithType& scheme : kExtensionStandardURLSchemes) |
| 48 standard_schemes->push_back(kExtensionStandardURLSchemes[i]); | 45 standard_schemes->push_back(scheme); |
| 49 | |
| 50 savable_schemes->push_back(extensions::kExtensionScheme); | 46 savable_schemes->push_back(extensions::kExtensionScheme); |
| 51 savable_schemes->push_back(extensions::kExtensionResourceScheme); | |
| 52 } | 47 } |
| 53 | 48 |
| 54 private: | 49 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(ExtensionsContentClient); | 50 DISALLOW_COPY_AND_ASSIGN(ExtensionsContentClient); |
| 56 }; | 51 }; |
| 57 | 52 |
| 58 // The test suite for extensions_unittests. | 53 // The test suite for extensions_unittests. |
| 59 class ExtensionsTestSuite : public content::ContentTestSuiteBase { | 54 class ExtensionsTestSuite : public content::ContentTestSuiteBase { |
| 60 public: | 55 public: |
| 61 ExtensionsTestSuite(int argc, char** argv); | 56 ExtensionsTestSuite(int argc, char** argv); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 content::UnitTestTestSuite test_suite(new ExtensionsTestSuite(argc, argv)); | 110 content::UnitTestTestSuite test_suite(new ExtensionsTestSuite(argc, argv)); |
| 116 | 111 |
| 117 base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart); | 112 base::TestIOThread test_io_thread(base::TestIOThread::kAutoStart); |
| 118 mojo::edk::test::ScopedIPCSupport ipc_support(test_io_thread.task_runner()); | 113 mojo::edk::test::ScopedIPCSupport ipc_support(test_io_thread.task_runner()); |
| 119 | 114 |
| 120 return base::LaunchUnitTests(argc, | 115 return base::LaunchUnitTests(argc, |
| 121 argv, | 116 argv, |
| 122 base::Bind(&content::UnitTestTestSuite::Run, | 117 base::Bind(&content::UnitTestTestSuite::Run, |
| 123 base::Unretained(&test_suite))); | 118 base::Unretained(&test_suite))); |
| 124 } | 119 } |
| OLD | NEW |