| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/metrics/statistics_recorder.h" | 7 #include "base/metrics/statistics_recorder.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/test/launcher/unit_test_launcher.h" | 9 #include "base/test/launcher/unit_test_launcher.h" |
| 10 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "ui/gfx/android/gfx_jni_registrar.h" | 30 #include "ui/gfx/android/gfx_jni_registrar.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 class ComponentsTestSuite : public base::TestSuite { | 35 class ComponentsTestSuite : public base::TestSuite { |
| 36 public: | 36 public: |
| 37 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | 37 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 virtual void Initialize() OVERRIDE { | 40 virtual void Initialize() override { |
| 41 base::TestSuite::Initialize(); | 41 base::TestSuite::Initialize(); |
| 42 | 42 |
| 43 // Initialize the histograms subsystem, so that any histograms hit in tests | 43 // Initialize the histograms subsystem, so that any histograms hit in tests |
| 44 // are correctly registered with the statistics recorder and can be queried | 44 // are correctly registered with the statistics recorder and can be queried |
| 45 // by tests. | 45 // by tests. |
| 46 base::StatisticsRecorder::Initialize(); | 46 base::StatisticsRecorder::Initialize(); |
| 47 | 47 |
| 48 #if !defined(OS_IOS) | 48 #if !defined(OS_IOS) |
| 49 gfx::GLSurface::InitializeOneOffForTests(); | 49 gfx::GLSurface::InitializeOneOffForTests(); |
| 50 #endif | 50 #endif |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 url::AddStandardScheme("chrome"); | 93 url::AddStandardScheme("chrome"); |
| 94 url::AddStandardScheme("chrome-extension"); | 94 url::AddStandardScheme("chrome-extension"); |
| 95 url::AddStandardScheme("chrome-devtools"); | 95 url::AddStandardScheme("chrome-devtools"); |
| 96 url::AddStandardScheme("chrome-search"); | 96 url::AddStandardScheme("chrome-search"); |
| 97 | 97 |
| 98 // Not using kExtensionScheme to avoid the dependency to extensions. | 98 // Not using kExtensionScheme to avoid the dependency to extensions. |
| 99 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme( | 99 ContentSettingsPattern::SetNonWildcardDomainNonPortScheme( |
| 100 "chrome-extension"); | 100 "chrome-extension"); |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual void Shutdown() OVERRIDE { | 103 virtual void Shutdown() override { |
| 104 ui::ResourceBundle::CleanupSharedInstance(); | 104 ui::ResourceBundle::CleanupSharedInstance(); |
| 105 | 105 |
| 106 #if defined(OS_MACOSX) && !defined(OS_IOS) | 106 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 107 base::mac::SetOverrideFrameworkBundle(NULL); | 107 base::mac::SetOverrideFrameworkBundle(NULL); |
| 108 #endif | 108 #endif |
| 109 | 109 |
| 110 base::TestSuite::Shutdown(); | 110 base::TestSuite::Shutdown(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); | 113 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { | 116 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { |
| 117 public: | 117 public: |
| 118 ComponentsUnitTestEventListener() {} | 118 ComponentsUnitTestEventListener() {} |
| 119 virtual ~ComponentsUnitTestEventListener() {} | 119 virtual ~ComponentsUnitTestEventListener() {} |
| 120 | 120 |
| 121 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { | 121 virtual void OnTestStart(const testing::TestInfo& test_info) override { |
| 122 content_initializer_.reset(new content::TestContentClientInitializer()); | 122 content_initializer_.reset(new content::TestContentClientInitializer()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { | 125 virtual void OnTestEnd(const testing::TestInfo& test_info) override { |
| 126 content_initializer_.reset(); | 126 content_initializer_.reset(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 scoped_ptr<content::TestContentClientInitializer> content_initializer_; | 130 scoped_ptr<content::TestContentClientInitializer> content_initializer_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); | 132 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 int main(int argc, char** argv) { | 137 int main(int argc, char** argv) { |
| 138 ComponentsTestSuite test_suite(argc, argv); | 138 ComponentsTestSuite test_suite(argc, argv); |
| 139 | 139 |
| 140 // The listener will set up common test environment for all components unit | 140 // The listener will set up common test environment for all components unit |
| 141 // tests. | 141 // tests. |
| 142 testing::TestEventListeners& listeners = | 142 testing::TestEventListeners& listeners = |
| 143 testing::UnitTest::GetInstance()->listeners(); | 143 testing::UnitTest::GetInstance()->listeners(); |
| 144 listeners.Append(new ComponentsUnitTestEventListener()); | 144 listeners.Append(new ComponentsUnitTestEventListener()); |
| 145 | 145 |
| 146 return base::LaunchUnitTests( | 146 return base::LaunchUnitTests( |
| 147 argc, argv, base::Bind(&base::TestSuite::Run, | 147 argc, argv, base::Bind(&base::TestSuite::Run, |
| 148 base::Unretained(&test_suite))); | 148 base::Unretained(&test_suite))); |
| 149 } | 149 } |
| OLD | NEW |