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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); | 97 DISALLOW_COPY_AND_ASSIGN(ComponentsTestSuite); |
98 }; | 98 }; |
99 | 99 |
100 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { | 100 class ComponentsUnitTestEventListener : public testing::EmptyTestEventListener { |
101 public: | 101 public: |
102 ComponentsUnitTestEventListener() {} | 102 ComponentsUnitTestEventListener() {} |
103 ~ComponentsUnitTestEventListener() override {} | 103 ~ComponentsUnitTestEventListener() override {} |
104 | 104 |
105 void OnTestStart(const testing::TestInfo& test_info) override { | 105 void OnTestStart(const testing::TestInfo& test_info) override { |
| 106 #if !defined(OS_IOS) |
106 content_initializer_.reset(new content::TestContentClientInitializer()); | 107 content_initializer_.reset(new content::TestContentClientInitializer()); |
| 108 #endif |
107 } | 109 } |
108 | 110 |
109 void OnTestEnd(const testing::TestInfo& test_info) override { | 111 void OnTestEnd(const testing::TestInfo& test_info) override { |
| 112 #if !defined(OS_IOS) |
110 content_initializer_.reset(); | 113 content_initializer_.reset(); |
| 114 #endif |
111 } | 115 } |
112 | 116 |
113 private: | 117 private: |
| 118 #if !defined(OS_IOS) |
114 scoped_ptr<content::TestContentClientInitializer> content_initializer_; | 119 scoped_ptr<content::TestContentClientInitializer> content_initializer_; |
| 120 #endif |
115 | 121 |
116 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); | 122 DISALLOW_COPY_AND_ASSIGN(ComponentsUnitTestEventListener); |
117 }; | 123 }; |
118 | 124 |
119 } // namespace | 125 } // namespace |
120 | 126 |
121 int main(int argc, char** argv) { | 127 int main(int argc, char** argv) { |
122 ComponentsTestSuite test_suite(argc, argv); | 128 ComponentsTestSuite test_suite(argc, argv); |
123 | 129 |
124 // The listener will set up common test environment for all components unit | 130 // The listener will set up common test environment for all components unit |
125 // tests. | 131 // tests. |
126 testing::TestEventListeners& listeners = | 132 testing::TestEventListeners& listeners = |
127 testing::UnitTest::GetInstance()->listeners(); | 133 testing::UnitTest::GetInstance()->listeners(); |
128 listeners.Append(new ComponentsUnitTestEventListener()); | 134 listeners.Append(new ComponentsUnitTestEventListener()); |
129 | 135 |
130 return base::LaunchUnitTests( | 136 return base::LaunchUnitTests( |
131 argc, argv, base::Bind(&base::TestSuite::Run, | 137 argc, argv, base::Bind(&base::TestSuite::Run, |
132 base::Unretained(&test_suite))); | 138 base::Unretained(&test_suite))); |
133 } | 139 } |
OLD | NEW |