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/path_service.h" | 8 #include "base/path_service.h" |
8 #include "base/test/launcher/unit_test_launcher.h" | 9 #include "base/test/launcher/unit_test_launcher.h" |
9 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
10 #include "content/public/test/test_content_client_initializer.h" | 11 #include "content/public/test/test_content_client_initializer.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/base/ui_base_paths.h" | 14 #include "ui/base/ui_base_paths.h" |
14 | 15 |
15 #if defined(OS_MACOSX) | 16 #if defined(OS_MACOSX) |
16 #include "base/mac/bundle_locations.h" | 17 #include "base/mac/bundle_locations.h" |
(...skipping 11 matching lines...) Expand all Loading... |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 class ComponentsTestSuite : public base::TestSuite { | 32 class ComponentsTestSuite : public base::TestSuite { |
32 public: | 33 public: |
33 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} | 34 ComponentsTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} |
34 | 35 |
35 private: | 36 private: |
36 virtual void Initialize() OVERRIDE { | 37 virtual void Initialize() OVERRIDE { |
37 base::TestSuite::Initialize(); | 38 base::TestSuite::Initialize(); |
| 39 |
| 40 // Initialize the histograms subsystem, so that any histograms hit in tests |
| 41 // are correctly registered with the statistics recorder and can be queried |
| 42 // by tests. |
| 43 base::StatisticsRecorder::Initialize(); |
| 44 |
38 #if !defined(OS_IOS) | 45 #if !defined(OS_IOS) |
39 gfx::GLSurface::InitializeOneOffForTests(); | 46 gfx::GLSurface::InitializeOneOffForTests(); |
40 #endif | 47 #endif |
41 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
42 // Register JNI bindings for android. | 49 // Register JNI bindings for android. |
43 JNIEnv* env = base::android::AttachCurrentThread(); | 50 JNIEnv* env = base::android::AttachCurrentThread(); |
44 gfx::android::RegisterJni(env); | 51 gfx::android::RegisterJni(env); |
45 ui::android::RegisterJni(env); | 52 ui::android::RegisterJni(env); |
46 #endif | 53 #endif |
47 | 54 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // The listener will set up common test environment for all components unit | 124 // The listener will set up common test environment for all components unit |
118 // tests. | 125 // tests. |
119 testing::TestEventListeners& listeners = | 126 testing::TestEventListeners& listeners = |
120 testing::UnitTest::GetInstance()->listeners(); | 127 testing::UnitTest::GetInstance()->listeners(); |
121 listeners.Append(new ComponentsUnitTestEventListener()); | 128 listeners.Append(new ComponentsUnitTestEventListener()); |
122 | 129 |
123 return base::LaunchUnitTests( | 130 return base::LaunchUnitTests( |
124 argc, argv, base::Bind(&base::TestSuite::Run, | 131 argc, argv, base::Bind(&base::TestSuite::Run, |
125 base::Unretained(&test_suite))); | 132 base::Unretained(&test_suite))); |
126 } | 133 } |
OLD | NEW |