| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/test/components_test_suite.h" | 5 #include "components/test/components_test_suite.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/test/launcher/unit_test_launcher.h" | 16 #include "base/test/launcher/unit_test_launcher.h" |
| 17 #include "base/test/test_suite.h" | 17 #include "base/test/test_suite.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "components/content_settings/core/common/content_settings_pattern.h" | 19 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/base/ui_base_paths.h" | 22 #include "ui/base/ui_base_paths.h" |
| 23 #include "url/url_util.h" | 23 #include "url/url_util.h" |
| 24 | 24 |
| 25 #if !defined(OS_IOS) | 25 #if !defined(OS_IOS) |
| 26 #include "content/public/common/content_client.h" |
| 27 #include "content/public/test/content_test_suite_base.h" |
| 26 #include "content/public/test/test_content_client_initializer.h" | 28 #include "content/public/test/test_content_client_initializer.h" |
| 27 #include "content/public/test/unittest_test_suite.h" | 29 #include "content/public/test/unittest_test_suite.h" |
| 28 #include "ui/gl/test/gl_surface_test_support.h" | 30 #include "ui/gl/test/gl_surface_test_support.h" |
| 29 #endif | 31 #endif |
| 30 | 32 |
| 31 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 32 #include "base/android/jni_android.h" | 34 #include "base/android/jni_android.h" |
| 33 #include "components/gcm_driver/instance_id/android/component_jni_registrar.h" | 35 #include "components/gcm_driver/instance_id/android/component_jni_registrar.h" |
| 34 #include "components/invalidation/impl/android/component_jni_registrar.h" | 36 #include "components/invalidation/impl/android/component_jni_registrar.h" |
| 35 #include "components/policy/core/browser/android/component_jni_registrar.h" | 37 #include "components/policy/core/browser/android/component_jni_registrar.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 51 void Initialize() override { | 53 void Initialize() override { |
| 52 base::TestSuite::Initialize(); | 54 base::TestSuite::Initialize(); |
| 53 | 55 |
| 54 // Initialize the histograms subsystem, so that any histograms hit in tests | 56 // Initialize the histograms subsystem, so that any histograms hit in tests |
| 55 // are correctly registered with the statistics recorder and can be queried | 57 // are correctly registered with the statistics recorder and can be queried |
| 56 // by tests. | 58 // by tests. |
| 57 base::StatisticsRecorder::Initialize(); | 59 base::StatisticsRecorder::Initialize(); |
| 58 | 60 |
| 59 #if !defined(OS_IOS) | 61 #if !defined(OS_IOS) |
| 60 gl::GLSurfaceTestSupport::InitializeOneOff(); | 62 gl::GLSurfaceTestSupport::InitializeOneOff(); |
| 63 |
| 64 // Setup content scheme statics. |
| 65 { |
| 66 content::ContentClient content_client; |
| 67 content::ContentTestSuiteBase::RegisterContentSchemes(&content_client); |
| 68 } |
| 61 #endif | 69 #endif |
| 62 #if defined(OS_ANDROID) | 70 #if defined(OS_ANDROID) |
| 63 // Register JNI bindings for android. | 71 // Register JNI bindings for android. |
| 64 JNIEnv* env = base::android::AttachCurrentThread(); | 72 JNIEnv* env = base::android::AttachCurrentThread(); |
| 65 ASSERT_TRUE(content::RegisterJniForTesting(env)); | 73 ASSERT_TRUE(content::RegisterJniForTesting(env)); |
| 66 ASSERT_TRUE(gfx::android::RegisterJni(env)); | 74 ASSERT_TRUE(gfx::android::RegisterJni(env)); |
| 67 ASSERT_TRUE(instance_id::android::RegisterInstanceIDJni(env)); | 75 ASSERT_TRUE(instance_id::android::RegisterInstanceIDJni(env)); |
| 68 ASSERT_TRUE(invalidation::android::RegisterInvalidationJni(env)); | 76 ASSERT_TRUE(invalidation::android::RegisterInvalidationJni(env)); |
| 69 ASSERT_TRUE(policy::android::RegisterPolicy(env)); | 77 ASSERT_TRUE(policy::android::RegisterPolicy(env)); |
| 70 ASSERT_TRUE(safe_json::android::RegisterSafeJsonJni(env)); | 78 ASSERT_TRUE(safe_json::android::RegisterSafeJsonJni(env)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 testing::TestEventListeners& listeners = | 159 testing::TestEventListeners& listeners = |
| 152 testing::UnitTest::GetInstance()->listeners(); | 160 testing::UnitTest::GetInstance()->listeners(); |
| 153 listeners.Append(new ComponentsUnitTestEventListener()); | 161 listeners.Append(new ComponentsUnitTestEventListener()); |
| 154 | 162 |
| 155 #if !defined(OS_IOS) | 163 #if !defined(OS_IOS) |
| 156 return base::Bind(&content::UnitTestTestSuite::Run, std::move(test_suite)); | 164 return base::Bind(&content::UnitTestTestSuite::Run, std::move(test_suite)); |
| 157 #else | 165 #else |
| 158 return base::Bind(&base::TestSuite::Run, std::move(test_suite)); | 166 return base::Bind(&base::TestSuite::Run, std::move(test_suite)); |
| 159 #endif | 167 #endif |
| 160 } | 168 } |
| OLD | NEW |