Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3758)

Unified Diff: base/logging_unittest.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Add stack trace marker. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/logging_unittest.cc
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc
index f41cce2f43b390fa9603a14f3f689fe87d0dcb33..8a8339a745f90a8931c7e2ec6b1e973f6273d963 100644
--- a/base/logging_unittest.cc
+++ b/base/logging_unittest.cc
@@ -52,6 +52,20 @@ class MockLogSource {
MOCK_METHOD0(Log, const char*());
};
+// Scoped object to temporary clear any log message handlers for testing
+// DCHECK/CHECK functionality.
+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);

Powered by Google App Engine
This is Rietveld 408576698