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 "components/invalidation/android/component_jni_registrar.h" |
| 29 #include "ui/android/ui_android_jni_registrar.h" |
29 #include "ui/base/android/ui_base_jni_registrar.h" | 30 #include "ui/base/android/ui_base_jni_registrar.h" |
30 #include "ui/gfx/android/gfx_jni_registrar.h" | 31 #include "ui/gfx/android/gfx_jni_registrar.h" |
31 #endif | 32 #endif |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 class ComponentsTestSuite : public base::TestSuite { | 36 class ComponentsTestSuite : public base::TestSuite { |
36 public: | 37 public: |
37 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | 38 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
38 | 39 |
39 private: | 40 private: |
40 void Initialize() override { | 41 void Initialize() override { |
41 base::TestSuite::Initialize(); | 42 base::TestSuite::Initialize(); |
42 | 43 |
43 // Initialize the histograms subsystem, so that any histograms hit in tests | 44 // Initialize the histograms subsystem, so that any histograms hit in tests |
44 // are correctly registered with the statistics recorder and can be queried | 45 // are correctly registered with the statistics recorder and can be queried |
45 // by tests. | 46 // by tests. |
46 base::StatisticsRecorder::Initialize(); | 47 base::StatisticsRecorder::Initialize(); |
47 | 48 |
48 #if !defined(OS_IOS) | 49 #if !defined(OS_IOS) |
49 gfx::GLSurface::InitializeOneOffForTests(); | 50 gfx::GLSurface::InitializeOneOffForTests(); |
50 #endif | 51 #endif |
51 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
52 // Register JNI bindings for android. | 53 // Register JNI bindings for android. |
53 JNIEnv* env = base::android::AttachCurrentThread(); | 54 JNIEnv* env = base::android::AttachCurrentThread(); |
54 gfx::android::RegisterJni(env); | 55 gfx::android::RegisterJni(env); |
55 ui::android::RegisterJni(env); | 56 ui::android::RegisterJni(env); |
| 57 ui::android::RegisterUIAndroidJni(env); |
56 invalidation::android::RegisterInvalidationJni(env); | 58 invalidation::android::RegisterInvalidationJni(env); |
57 #endif | 59 #endif |
58 | 60 |
59 #if defined(OS_MACOSX) && !defined(OS_IOS) | 61 #if defined(OS_MACOSX) && !defined(OS_IOS) |
60 // Look in the framework bundle for resources. | 62 // Look in the framework bundle for resources. |
61 base::FilePath path; | 63 base::FilePath path; |
62 PathService::Get(base::DIR_EXE, &path); | 64 PathService::Get(base::DIR_EXE, &path); |
63 | 65 |
64 // TODO(tfarina): This is temporary. The right fix is to write a | 66 // TODO(tfarina): This is temporary. The right fix is to write a |
65 // framework-Info.plist and integrate that into the build. | 67 // framework-Info.plist and integrate that into the build. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // The listener will set up common test environment for all components unit | 142 // The listener will set up common test environment for all components unit |
141 // tests. | 143 // tests. |
142 testing::TestEventListeners& listeners = | 144 testing::TestEventListeners& listeners = |
143 testing::UnitTest::GetInstance()->listeners(); | 145 testing::UnitTest::GetInstance()->listeners(); |
144 listeners.Append(new ComponentsUnitTestEventListener()); | 146 listeners.Append(new ComponentsUnitTestEventListener()); |
145 | 147 |
146 return base::LaunchUnitTests( | 148 return base::LaunchUnitTests( |
147 argc, argv, base::Bind(&base::TestSuite::Run, | 149 argc, argv, base::Bind(&base::TestSuite::Run, |
148 base::Unretained(&test_suite))); | 150 base::Unretained(&test_suite))); |
149 } | 151 } |
OLD | NEW |