Chromium Code Reviews| Index: base/logging_unittest.cc |
| diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc |
| index 62323972b8a12c4ac7fa6061eeb5812b294eb4e1..b239d3d4a202faac0015adf81d87ca2ed30e2b20 100644 |
| --- a/base/logging_unittest.cc |
| +++ b/base/logging_unittest.cc |
| @@ -2,9 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "base/compiler_specific.h" |
| #include "base/logging.h" |
| +#include "base/bind.h" |
| +#include "base/callback.h" |
| +#include "base/compiler_specific.h" |
| #include "base/macros.h" |
| +#include "base/strings/string_piece.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -34,7 +37,10 @@ using ::testing::Return; |
| int log_sink_call_count = 0; |
| #if !defined(OFFICIAL_BUILD) || defined(DCHECK_ALWAYS_ON) || !defined(NDEBUG) |
| -void LogSink(const std::string& str) { |
| +void LogSink(const char* file, |
|
brettw
2017/04/17 22:20:34
Now that we have a stack, is there a test for the
alex-ac
2017/04/18 06:34:21
Done.
|
| + int line, |
| + const base::StringPiece message, |
| + const base::StringPiece stack_trace) { |
| ++log_sink_call_count; |
| } |
| #endif |
| @@ -47,7 +53,6 @@ class LogStateSaver { |
| ~LogStateSaver() { |
| SetMinLogLevel(old_min_log_level_); |
| - SetLogAssertHandler(NULL); |
| log_sink_call_count = 0; |
| } |
| @@ -197,7 +202,7 @@ TEST_F(LoggingTest, MAYBE_CheckStreamsAreLazy) { |
| WillRepeatedly(Return("check message")); |
| EXPECT_CALL(uncalled_mock_log_source, Log()).Times(0); |
| - SetLogAssertHandler(&LogSink); |
| + ScopedLogAssertHandler scoped_assert_handler(base::Bind(LogSink)); |
| CHECK(mock_log_source.Log()) << uncalled_mock_log_source.Log(); |
| PCHECK(!mock_log_source.Log()) << mock_log_source.Log(); |
| @@ -405,12 +410,12 @@ TEST_F(LoggingTest, MAYBE_Dcheck) { |
| EXPECT_FALSE(DLOG_IS_ON(DCHECK)); |
| #elif defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) |
| // Release build with real DCHECKS. |
| - SetLogAssertHandler(&LogSink); |
| + ScopedLogAssertHandler scoped_assert_handler(base::Bind(LogSink)); |
| EXPECT_TRUE(DCHECK_IS_ON()); |
| EXPECT_TRUE(DLOG_IS_ON(DCHECK)); |
| #else |
| // Debug build. |
| - SetLogAssertHandler(&LogSink); |
| + ScopedLogAssertHandler scoped_assert_handler(base::Bind(LogSink)); |
| EXPECT_TRUE(DCHECK_IS_ON()); |
| EXPECT_TRUE(DLOG_IS_ON(DCHECK)); |
| #endif |