| 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" | 13 #include "content/public/test/test_content_client_initializer.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/base/ui_base_paths.h" | 16 #include "ui/base/ui_base_paths.h" |
| 17 #include "url/url_util.h" | 17 #include "url/url_util.h" |
| 18 | 18 |
| 19 #if !defined(OS_IOS) | 19 #if !defined(OS_IOS) |
| 20 #include "ui/gl/gl_surface.h" | 20 #include "ui/gl/gl_surface.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/safe_json/android/component_jni_registrar.h" |
| 26 #include "ui/base/android/ui_base_jni_registrar.h" | 27 #include "ui/base/android/ui_base_jni_registrar.h" |
| 27 #include "ui/gfx/android/gfx_jni_registrar.h" | 28 #include "ui/gfx/android/gfx_jni_registrar.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 class ComponentsTestSuite : public base::TestSuite { | 33 class ComponentsTestSuite : public base::TestSuite { |
| 33 public: | 34 public: |
| 34 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | 35 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 void Initialize() override { | 38 void Initialize() override { |
| 38 base::TestSuite::Initialize(); | 39 base::TestSuite::Initialize(); |
| 39 | 40 |
| 40 // Initialize the histograms subsystem, so that any histograms hit in tests | 41 // Initialize the histograms subsystem, so that any histograms hit in tests |
| 41 // are correctly registered with the statistics recorder and can be queried | 42 // are correctly registered with the statistics recorder and can be queried |
| 42 // by tests. | 43 // by tests. |
| 43 base::StatisticsRecorder::Initialize(); | 44 base::StatisticsRecorder::Initialize(); |
| 44 | 45 |
| 45 #if !defined(OS_IOS) | 46 #if !defined(OS_IOS) |
| 46 gfx::GLSurface::InitializeOneOffForTests(); | 47 gfx::GLSurface::InitializeOneOffForTests(); |
| 47 #endif | 48 #endif |
| 48 #if defined(OS_ANDROID) | 49 #if defined(OS_ANDROID) |
| 49 // Register JNI bindings for android. | 50 // Register JNI bindings for android. |
| 50 JNIEnv* env = base::android::AttachCurrentThread(); | 51 JNIEnv* env = base::android::AttachCurrentThread(); |
| 51 gfx::android::RegisterJni(env); | 52 ASSERT_TRUE(gfx::android::RegisterJni(env)); |
| 52 ui::android::RegisterJni(env); | 53 ASSERT_TRUE(ui::android::RegisterJni(env)); |
| 53 invalidation::android::RegisterInvalidationJni(env); | 54 ASSERT_TRUE(invalidation::android::RegisterInvalidationJni(env)); |
| 55 ASSERT_TRUE(safe_json::android::RegisterSafeJsonJni(env)); |
| 54 #endif | 56 #endif |
| 55 | 57 |
| 56 ui::RegisterPathProvider(); | 58 ui::RegisterPathProvider(); |
| 57 | 59 |
| 58 base::FilePath pak_path; | 60 base::FilePath pak_path; |
| 59 #if defined(OS_ANDROID) | 61 #if defined(OS_ANDROID) |
| 60 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); | 62 PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &pak_path); |
| 61 #else | 63 #else |
| 62 PathService::Get(base::DIR_MODULE, &pak_path); | 64 PathService::Get(base::DIR_MODULE, &pak_path); |
| 63 #endif | 65 #endif |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // The listener will set up common test environment for all components unit | 120 // The listener will set up common test environment for all components unit |
| 119 // tests. | 121 // tests. |
| 120 testing::TestEventListeners& listeners = | 122 testing::TestEventListeners& listeners = |
| 121 testing::UnitTest::GetInstance()->listeners(); | 123 testing::UnitTest::GetInstance()->listeners(); |
| 122 listeners.Append(new ComponentsUnitTestEventListener()); | 124 listeners.Append(new ComponentsUnitTestEventListener()); |
| 123 | 125 |
| 124 return base::LaunchUnitTests( | 126 return base::LaunchUnitTests( |
| 125 argc, argv, base::Bind(&base::TestSuite::Run, | 127 argc, argv, base::Bind(&base::TestSuite::Run, |
| 126 base::Unretained(&test_suite))); | 128 base::Unretained(&test_suite))); |
| 127 } | 129 } |
| OLD | NEW |