| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 | 7 |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace logging { | 11 namespace logging { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 using ::testing::Return; | 15 using ::testing::Return; |
| 16 | 16 |
| 17 // Needs to be global since log assert handlers can't maintain state. | 17 // Needs to be global since log assert handlers can't maintain state. |
| 18 int log_sink_call_count = 0; | 18 int log_sink_call_count = 0; |
| 19 | 19 |
| 20 #if !defined(LOGGING_IS_OFFICIAL_BUILD) |
| 20 void LogSink(const std::string& str) { | 21 void LogSink(const std::string& str) { |
| 21 ++log_sink_call_count; | 22 ++log_sink_call_count; |
| 22 } | 23 } |
| 24 #endif // !defined(LOGGING_IS_OFFICIAL_BUILD) |
| 23 | 25 |
| 24 // Class to make sure any manipulations we do to the min log level are | 26 // Class to make sure any manipulations we do to the min log level are |
| 25 // contained (i.e., do not affect other unit tests). | 27 // contained (i.e., do not affect other unit tests). |
| 26 class LogStateSaver { | 28 class LogStateSaver { |
| 27 public: | 29 public: |
| 28 LogStateSaver() : old_min_log_level_(GetMinLogLevel()) {} | 30 LogStateSaver() : old_min_log_level_(GetMinLogLevel()) {} |
| 29 | 31 |
| 30 ~LogStateSaver() { | 32 ~LogStateSaver() { |
| 31 SetMinLogLevel(old_min_log_level_); | 33 SetMinLogLevel(old_min_log_level_); |
| 32 SetLogAssertHandler(NULL); | 34 SetLogAssertHandler(NULL); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // These should still reference |some_variable| so we don't get | 254 // These should still reference |some_variable| so we don't get |
| 253 // unused variable warnings. | 255 // unused variable warnings. |
| 254 DCHECK(some_variable) << "test"; | 256 DCHECK(some_variable) << "test"; |
| 255 DPCHECK(some_variable) << "test"; | 257 DPCHECK(some_variable) << "test"; |
| 256 DCHECK_EQ(some_variable, 1) << "test"; | 258 DCHECK_EQ(some_variable, 1) << "test"; |
| 257 } | 259 } |
| 258 | 260 |
| 259 } // namespace | 261 } // namespace |
| 260 | 262 |
| 261 } // namespace logging | 263 } // namespace logging |
| OLD | NEW |