OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/test_suite.h" | 5 #include "base/test/test_suite.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/debug_on_start_win.h" | 11 #include "base/debug/debug_on_start_win.h" |
12 #include "base/debug/debugger.h" | 12 #include "base/debug/debugger.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/i18n/icu_util.h" | 14 #include "base/i18n/icu_util.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/mac/scoped_nsautorelease_pool.h" | |
17 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
18 #include "base/path_service.h" | 17 #include "base/path_service.h" |
19 #include "base/process_util.h" | 18 #include "base/process_util.h" |
20 #include "base/test/multiprocess_test.h" | 19 #include "base/test/multiprocess_test.h" |
21 #include "base/test/test_timeouts.h" | 20 #include "base/test/test_timeouts.h" |
22 #include "base/time.h" | 21 #include "base/time.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "testing/multiprocess_func_list.h" | 23 #include "testing/multiprocess_func_list.h" |
25 | 24 |
26 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
| 26 #include "base/mac/scoped_nsautorelease_pool.h" |
27 #include "base/test/mock_chrome_application_mac.h" | 27 #include "base/test/mock_chrome_application_mac.h" |
28 #endif | 28 #endif |
29 | 29 |
30 #if defined(OS_ANDROID) | 30 #if defined(OS_ANDROID) |
31 #include "base/test/test_stub_android.h" | 31 #include "base/test/test_stub_android.h" |
32 #endif | 32 #endif |
33 | 33 |
34 #if defined(TOOLKIT_USES_GTK) | 34 #if defined(TOOLKIT_USES_GTK) |
35 #include <gtk/gtk.h> | 35 #include <gtk/gtk.h> |
36 #endif | 36 #endif |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 void TestSuite::CatchMaybeTests() { | 117 void TestSuite::CatchMaybeTests() { |
118 testing::TestEventListeners& listeners = | 118 testing::TestEventListeners& listeners = |
119 testing::UnitTest::GetInstance()->listeners(); | 119 testing::UnitTest::GetInstance()->listeners(); |
120 listeners.Append(new MaybeTestDisabler); | 120 listeners.Append(new MaybeTestDisabler); |
121 } | 121 } |
122 | 122 |
123 // Don't add additional code to this method. Instead add it to | 123 // Don't add additional code to this method. Instead add it to |
124 // Initialize(). See bug 6436. | 124 // Initialize(). See bug 6436. |
125 int TestSuite::Run() { | 125 int TestSuite::Run() { |
| 126 #if defined(OS_MACOSX) |
126 base::mac::ScopedNSAutoreleasePool scoped_pool; | 127 base::mac::ScopedNSAutoreleasePool scoped_pool; |
| 128 #endif |
127 | 129 |
128 Initialize(); | 130 Initialize(); |
129 std::string client_func = | 131 std::string client_func = |
130 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 132 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
131 switches::kTestChildProcess); | 133 switches::kTestChildProcess); |
132 // Check to see if we are being run as a client process. | 134 // Check to see if we are being run as a client process. |
133 if (!client_func.empty()) | 135 if (!client_func.empty()) |
134 return multi_process_function_list::InvokeChildProcessTest(client_func); | 136 return multi_process_function_list::InvokeChildProcessTest(client_func); |
135 int result = RUN_ALL_TESTS(); | 137 int result = RUN_ALL_TESTS(); |
136 | 138 |
137 // If there are failed tests, see if we should ignore the failures. | 139 // If there are failed tests, see if we should ignore the failures. |
138 if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0) | 140 if (result != 0 && GetTestCount(&TestSuite::NonIgnoredFailures) == 0) |
139 result = 0; | 141 result = 0; |
140 | 142 |
141 // Display the number of flaky tests. | 143 // Display the number of flaky tests. |
142 int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky); | 144 int flaky_count = GetTestCount(&TestSuite::IsMarkedFlaky); |
143 if (flaky_count) { | 145 if (flaky_count) { |
144 printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count, | 146 printf(" YOU HAVE %d FLAKY %s\n\n", flaky_count, |
145 flaky_count == 1 ? "TEST" : "TESTS"); | 147 flaky_count == 1 ? "TEST" : "TESTS"); |
146 } | 148 } |
147 | 149 |
148 // Display the number of tests with ignored failures (FAILS). | 150 // Display the number of tests with ignored failures (FAILS). |
149 int failing_count = GetTestCount(&TestSuite::IsMarkedFailing); | 151 int failing_count = GetTestCount(&TestSuite::IsMarkedFailing); |
150 if (failing_count) { | 152 if (failing_count) { |
151 printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n", | 153 printf(" YOU HAVE %d %s with ignored failures (FAILS prefix)\n\n", |
152 failing_count, failing_count == 1 ? "test" : "tests"); | 154 failing_count, failing_count == 1 ? "test" : "tests"); |
153 } | 155 } |
154 | 156 |
| 157 #if defined(OS_MACOSX) |
155 // This MUST happen before Shutdown() since Shutdown() tears down | 158 // This MUST happen before Shutdown() since Shutdown() tears down |
156 // objects (such as NotificationService::current()) that Cocoa | 159 // objects (such as NotificationService::current()) that Cocoa |
157 // objects use to remove themselves as observers. | 160 // objects use to remove themselves as observers. |
158 scoped_pool.Recycle(); | 161 scoped_pool.Recycle(); |
| 162 #endif |
159 | 163 |
160 Shutdown(); | 164 Shutdown(); |
161 | 165 |
162 return result; | 166 return result; |
163 } | 167 } |
164 | 168 |
165 // static | 169 // static |
166 void TestSuite::UnitTestAssertHandler(const std::string& str) { | 170 void TestSuite::UnitTestAssertHandler(const std::string& str) { |
167 RAW_LOG(FATAL, str.c_str()); | 171 RAW_LOG(FATAL, str.c_str()); |
168 } | 172 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 icu_util::Initialize(); | 229 icu_util::Initialize(); |
226 #endif | 230 #endif |
227 | 231 |
228 CatchMaybeTests(); | 232 CatchMaybeTests(); |
229 | 233 |
230 TestTimeouts::Initialize(); | 234 TestTimeouts::Initialize(); |
231 } | 235 } |
232 | 236 |
233 void TestSuite::Shutdown() { | 237 void TestSuite::Shutdown() { |
234 } | 238 } |
OLD | NEW |