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

Unified Diff: base/logging_unittest.cc

Issue 2638763004: Report CHECK/DCHECK to test launcher summary output. (Closed)
Patch Set: Fix logging unittest. 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
« no previous file with comments | « no previous file | base/test/gtest_xml_unittest_result_printer.h » ('j') | base/test/test_suite.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | base/test/gtest_xml_unittest_result_printer.h » ('j') | base/test/test_suite.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698