| 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" |
| 11 #include "components/content_settings/core/common/content_settings_pattern.h" | 11 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 12 #include "content/public/test/test_content_client_initializer.h" | 12 #include "content/public/test/test_content_client_initializer.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/base/ui_base_paths.h" | 15 #include "ui/base/ui_base_paths.h" |
| 16 #include "url/url_util.h" | 16 #include "url/url_util.h" |
| 17 | 17 |
| 18 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
| 19 #include "base/mac/bundle_locations.h" | 19 #include "base/mac/bundle_locations.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #if !defined(OS_IOS) | 22 #if !defined(OS_IOS) |
| 23 #include "ui/gl/gl_surface.h" | 23 #include "ui/gl/gl_surface.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #if defined(OS_ANDROID) | 26 #if defined(OS_ANDROID) |
| 27 #include "base/android/jni_android.h" | 27 #include "base/android/jni_android.h" |
| 28 #include "components/invalidation/android/component_jni_registrar.h" |
| 28 #include "ui/base/android/ui_base_jni_registrar.h" | 29 #include "ui/base/android/ui_base_jni_registrar.h" |
| 29 #include "ui/gfx/android/gfx_jni_registrar.h" | 30 #include "ui/gfx/android/gfx_jni_registrar.h" |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 class ComponentsTestSuite : public base::TestSuite { | 35 class ComponentsTestSuite : public base::TestSuite { |
| 35 public: | 36 public: |
| 36 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | 37 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 virtual void Initialize() OVERRIDE { | 40 virtual void Initialize() OVERRIDE { |
| 40 base::TestSuite::Initialize(); | 41 base::TestSuite::Initialize(); |
| 41 | 42 |
| 42 // Initialize the histograms subsystem, so that any histograms hit in tests | 43 // Initialize the histograms subsystem, so that any histograms hit in tests |
| 43 // are correctly registered with the statistics recorder and can be queried | 44 // are correctly registered with the statistics recorder and can be queried |
| 44 // by tests. | 45 // by tests. |
| 45 base::StatisticsRecorder::Initialize(); | 46 base::StatisticsRecorder::Initialize(); |
| 46 | 47 |
| 47 #if !defined(OS_IOS) | 48 #if !defined(OS_IOS) |
| 48 gfx::GLSurface::InitializeOneOffForTests(); | 49 gfx::GLSurface::InitializeOneOffForTests(); |
| 49 #endif | 50 #endif |
| 50 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
| 51 // Register JNI bindings for android. | 52 // Register JNI bindings for android. |
| 52 JNIEnv* env = base::android::AttachCurrentThread(); | 53 JNIEnv* env = base::android::AttachCurrentThread(); |
| 53 gfx::android::RegisterJni(env); | 54 gfx::android::RegisterJni(env); |
| 54 ui::android::RegisterJni(env); | 55 ui::android::RegisterJni(env); |
| 56 invalidation::android::RegisterInvalidationJni(env); |
| 55 #endif | 57 #endif |
| 56 | 58 |
| 57 #if defined(OS_MACOSX) && !defined(OS_IOS) | 59 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 58 // Look in the framework bundle for resources. | 60 // Look in the framework bundle for resources. |
| 59 base::FilePath path; | 61 base::FilePath path; |
| 60 PathService::Get(base::DIR_EXE, &path); | 62 PathService::Get(base::DIR_EXE, &path); |
| 61 | 63 |
| 62 // TODO(tfarina): This is temporary. The right fix is to write a | 64 // TODO(tfarina): This is temporary. The right fix is to write a |
| 63 // framework-Info.plist and integrate that into the build. | 65 // framework-Info.plist and integrate that into the build. |
| 64 // Hardcode the framework name here to avoid having to depend on chrome's | 66 // Hardcode the framework name here to avoid having to depend on chrome's |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // 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 |
| 139 // tests. | 141 // tests. |
| 140 testing::TestEventListeners& listeners = | 142 testing::TestEventListeners& listeners = |
| 141 testing::UnitTest::GetInstance()->listeners(); | 143 testing::UnitTest::GetInstance()->listeners(); |
| 142 listeners.Append(new ComponentsUnitTestEventListener()); | 144 listeners.Append(new ComponentsUnitTestEventListener()); |
| 143 | 145 |
| 144 return base::LaunchUnitTests( | 146 return base::LaunchUnitTests( |
| 145 argc, argv, base::Bind(&base::TestSuite::Run, | 147 argc, argv, base::Bind(&base::TestSuite::Run, |
| 146 base::Unretained(&test_suite))); | 148 base::Unretained(&test_suite))); |
| 147 } | 149 } |
| OLD | NEW |