| 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 "chrome/test/logging/win/test_log_collector.h" | 5 #include "chrome/test/logging/win/test_log_collector.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <ios> | 10 #include <ios> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 TestLogCollector::TestLogCollector() | 169 TestLogCollector::TestLogCollector() |
| 170 : unit_test_(NULL), also_emit_success_logs_(false) { | 170 : unit_test_(NULL), also_emit_success_logs_(false) { |
| 171 } | 171 } |
| 172 | 172 |
| 173 TestLogCollector::~TestLogCollector() { | 173 TestLogCollector::~TestLogCollector() { |
| 174 } | 174 } |
| 175 | 175 |
| 176 void TestLogCollector::Initialize(testing::UnitTest* unit_test) { | 176 void TestLogCollector::Initialize(testing::UnitTest* unit_test) { |
| 177 if (unit_test_ != NULL) { | 177 if (unit_test_ != NULL) { |
| 178 CHECK_EQ(unit_test, unit_test_) | 178 // Cannot install the test log collector in multiple unit tests. |
| 179 << "Cannot install the test log collector in multiple unit tests."; | 179 CHECK_EQ(unit_test, unit_test_); |
| 180 return; // Already initialized. | 180 return; // Already initialized. |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Remove the default result printer and install the collector's listener | 183 // Remove the default result printer and install the collector's listener |
| 184 // which delegates to the printer. If the default result printer has already | 184 // which delegates to the printer. If the default result printer has already |
| 185 // been released, log an error and move on. | 185 // been released, log an error and move on. |
| 186 testing::TestEventListeners& listeners = unit_test->listeners(); | 186 testing::TestEventListeners& listeners = unit_test->listeners(); |
| 187 testing::TestEventListener* default_result_printer = | 187 testing::TestEventListener* default_result_printer = |
| 188 listeners.default_result_printer(); | 188 listeners.default_result_printer(); |
| 189 if (default_result_printer == NULL) { | 189 if (default_result_printer == NULL) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 void InstallTestLogCollector(testing::UnitTest* unit_test) { | 280 void InstallTestLogCollector(testing::UnitTest* unit_test) { |
| 281 // Must be called before running any tests. | 281 // Must be called before running any tests. |
| 282 DCHECK(unit_test); | 282 DCHECK(unit_test); |
| 283 DCHECK(!unit_test->current_test_case()); | 283 DCHECK(!unit_test->current_test_case()); |
| 284 | 284 |
| 285 g_test_log_collector.Get().Initialize(unit_test); | 285 g_test_log_collector.Get().Initialize(unit_test); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace logging_win | 288 } // namespace logging_win |
| OLD | NEW |