Chromium Code Reviews| 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/metrics/statistics_recorder.h" | 8 #include "base/metrics/statistics_recorder.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/test/launcher/unit_test_launcher.h" | 10 #include "base/test/launcher/unit_test_launcher.h" |
| 11 #include "base/test/test_suite.h" | 11 #include "base/test/test_suite.h" |
| 12 #include "components/content_settings/core/common/content_settings_pattern.h" | 12 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 13 #include "content/public/test/test_content_client_initializer.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/base/ui_base_paths.h" | 15 #include "ui/base/ui_base_paths.h" |
| 17 #include "url/url_util.h" | 16 #include "url/url_util.h" |
| 18 | 17 |
| 19 #if !defined(OS_IOS) | 18 #if !defined(OS_IOS) |
| 19 #include "content/public/test/test_content_client_initializer.h" | |
| 20 #include "ui/gl/test/gl_surface_test_support.h" | 20 #include "ui/gl/test/gl_surface_test_support.h" |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
| 24 #include "base/android/jni_android.h" | 24 #include "base/android/jni_android.h" |
| 25 #include "components/invalidation/impl/android/component_jni_registrar.h" | 25 #include "components/invalidation/impl/android/component_jni_registrar.h" |
| 26 #include "components/policy/core/browser/android/component_jni_registrar.h" | 26 #include "components/policy/core/browser/android/component_jni_registrar.h" |
| 27 #include "components/safe_json/android/component_jni_registrar.h" | 27 #include "components/safe_json/android/component_jni_registrar.h" |
| 28 #include "components/signin/core/browser/android/component_jni_registrar.h" | 28 #include "components/signin/core/browser/android/component_jni_registrar.h" |
| 29 #include "ui/base/android/ui_base_jni_registrar.h" | 29 #include "ui/base/android/ui_base_jni_registrar.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 | 90 |
| 91 void Shutdown() override { | 91 void Shutdown() override { |
| 92 ui::ResourceBundle::CleanupSharedInstance(); | 92 ui::ResourceBundle::CleanupSharedInstance(); |
| 93 | 93 |
| 94 base::TestSuite::Shutdown(); | 94 base::TestSuite::Shutdown(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); | 97 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 #if !defined(OS_IOS) | |
| 100 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { | 101 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { |
| 101 public: | 102 public: |
| 102 ComponentsUnitTestEventListener() {} | 103 ComponentsUnitTestEventListener() {} |
| 103 ~ComponentsUnitTestEventListener() override {} | 104 ~ComponentsUnitTestEventListener() override {} |
| 104 | 105 |
| 105 void OnTestStart(const testing::TestInfo& test_info) override { | 106 void OnTestStart(const testing::TestInfo& test_info) override { |
| 106 content_initializer_.reset(new content::TestContentClientInitializer()); | 107 content_initializer_.reset(new content::TestContentClientInitializer()); |
|
blundell
2015/09/04 09:18:40
nit: maybe it's better to ifdef out only the refer
sdefresne
2015/09/04 16:18:37
Done.
| |
| 107 } | 108 } |
| 108 | 109 |
| 109 void OnTestEnd(const testing::TestInfo& test_info) override { | 110 void OnTestEnd(const testing::TestInfo& test_info) override { |
| 110 content_initializer_.reset(); | 111 content_initializer_.reset(); |
| 111 } | 112 } |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 scoped_ptr<content::TestContentClientInitializer> content_initializer_; | 115 scoped_ptr<content::TestContentClientInitializer> content_initializer_; |
| 115 | 116 |
| 116 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); | 117 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); |
| 117 }; | 118 }; |
| 119 #endif // !defined(OS_IOS) | |
| 118 | 120 |
| 119 } // namespace | 121 } // namespace |
| 120 | 122 |
| 121 int main(int argc, char** argv) { | 123 int main(int argc, char** argv) { |
| 122 ComponentsTestSuite test_suite(argc, argv); | 124 ComponentsTestSuite test_suite(argc, argv); |
| 123 | 125 |
| 126 #if !defined(OS_IOS) | |
| 124 // The listener will set up common test environment for all components unit | 127 // The listener will set up common test environment for all components unit |
| 125 // tests. | 128 // tests. |
| 126 testing::TestEventListeners& listeners = | 129 testing::TestEventListeners& listeners = |
| 127 testing::UnitTest::GetInstance()->listeners(); | 130 testing::UnitTest::GetInstance()->listeners(); |
| 128 listeners.Append(new ComponentsUnitTestEventListener()); | 131 listeners.Append(new ComponentsUnitTestEventListener()); |
| 132 #endif // !defined(OS_IOS) | |
| 129 | 133 |
| 130 return base::LaunchUnitTests( | 134 return base::LaunchUnitTests( |
| 131 argc, argv, base::Bind(&base::TestSuite::Run, | 135 argc, argv, base::Bind(&base::TestSuite::Run, |
| 132 base::Unretained(&test_suite))); | 136 base::Unretained(&test_suite))); |
| 133 } | 137 } |
| OLD | NEW |