Chromium Code Reviews| Index: base/logging_unittest.cc |
| diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc |
| index f41cce2f43b390fa9603a14f3f689fe87d0dcb33..e5c65d7d20ce7622d5f7008eb6d6296becf5e148 100644 |
| --- a/base/logging_unittest.cc |
| +++ b/base/logging_unittest.cc |
| @@ -52,6 +52,20 @@ class MockLogSource { |
| MOCK_METHOD0(Log, const char*()); |
| }; |
| +// Message handler used by test launcher to debug CHECK/DCHECK. |
| +// This object will temporary disable message handler for test. |
|
dcheng
2017/01/20 08:26:23
Nit: Scoper object to temporarily clear any log me
alex-ac
2017/01/20 12:11:16
Done.
|
| +class MockLogMessageHandler { |
| + public: |
| + MockLogMessageHandler() : saved_handler_(GetLogMessageHandler()) { |
| + SetLogMessageHandler(nullptr); |
| + } |
| + |
| + ~MockLogMessageHandler() { SetLogMessageHandler(saved_handler_); } |
| + |
| + private: |
| + LogMessageHandlerFunction saved_handler_; |
| +}; |
| + |
| TEST_F(LoggingTest, BasicLogging) { |
| MockLogSource mock_log_source; |
| EXPECT_CALL(mock_log_source, Log()).Times(DEBUG_MODE ? 16 : 8). |
| @@ -152,6 +166,7 @@ TEST_F(LoggingTest, LoggingIsLazyBySeverity) { |
| } |
| TEST_F(LoggingTest, LoggingIsLazyByDestination) { |
| + MockLogMessageHandler mock_handler; |
| MockLogSource mock_log_source; |
| MockLogSource mock_log_source_error; |
| EXPECT_CALL(mock_log_source, Log()).Times(0); |