Index: base/logging_unittest.cc |
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc |
index 08d78307f2ff3f16ad058f01818875e09033fec7..ee12caff079a9194e07da2e8c3939debdb58f109 100644 |
--- a/base/logging_unittest.cc |
+++ b/base/logging_unittest.cc |
@@ -182,16 +182,16 @@ TEST_F(LoggingTest, CheckStreamsAreLazy) { |
<< mock_log_source.Log(); |
} |
-TEST_F(LoggingTest, DebugLoggingReleaseBehavior) { |
-#if !defined(NDEBUG) |
- int debug_only_variable = 1; |
+TEST_F(LoggingTest, DebugLoggingOfficialBuildBehavior) { |
+#if (!defined(LOGGING_IS_OFFICIAL_BUILD)) |
+ int non_official_build_only_variable = 1; |
#endif |
- // These should avoid emitting references to |debug_only_variable| |
- // in release mode. |
- DLOG_IF(INFO, debug_only_variable) << "test"; |
- DLOG_ASSERT(debug_only_variable) << "test"; |
- DPLOG_IF(INFO, debug_only_variable) << "test"; |
- DVLOG_IF(1, debug_only_variable) << "test"; |
+ // These should avoid emitting references to |
+ // |non_official_build_only_variable| in official build. |
+ DLOG_IF(INFO, non_official_build_only_variable) << "test"; |
+ DLOG_ASSERT(non_official_build_only_variable) << "test"; |
+ DPLOG_IF(INFO, non_official_build_only_variable) << "test"; |
+ DVLOG_IF(1, non_official_build_only_variable) << "test"; |
} |
TEST_F(LoggingTest, DcheckStreamsAreLazy) { |
@@ -209,6 +209,62 @@ TEST_F(LoggingTest, DcheckStreamsAreLazy) { |
#endif |
} |
+TEST_F(LoggingTest, Dlog) { |
+#if defined(LOGGING_IS_OFFICIAL_BUILD) |
+ // Official build. |
+ EXPECT_FALSE(DLOG_IS_ON(ERROR)); |
+ |
+ // Make sure the |undefined_param| is not part of the build. |
+ DLOG_IF(ERROR, true) << undefined_param; |
+ DPLOG_IF(ERROR, true) << undefined_param; |
+ DVLOG_IF(LOG_ERROR, true) << undefined_param; |
+ DVPLOG_IF(LOG_ERROR, true) << undefined_param; |
+#elif defined(NDEBUG) |
+ // Unofficial release build. |
+ g_dlog_state = ENABLE_DLOG_FOR_NON_OFFICIAL_RELEASE_BUILDS; |
+ MockLogSource mock_log_source, uncalled_mock_log_source; |
+ |
+ // VLOG_* is enabled only if the min log level is negative. |
+ SetMinLogLevel(-LOG_ERROR); |
+ EXPECT_CALL(mock_log_source, Log()).Times(4). |
+ WillRepeatedly(Return("check message")); |
+ |
+ EXPECT_TRUE(DLOG_IS_ON(ERROR)); |
+ |
+ DLOG_IF(ERROR, true) << mock_log_source.Log(); |
+ DPLOG_IF(ERROR, true) << mock_log_source.Log(); |
+ DVLOG_IF(LOG_ERROR, true) << mock_log_source.Log(); |
+ DVPLOG_IF(LOG_ERROR, true) << mock_log_source.Log(); |
+ |
+ g_dlog_state = DISABLE_DLOG_FOR_NON_OFFICIAL_RELEASE_BUILDS; |
+ |
+ EXPECT_CALL(uncalled_mock_log_source, Log()).Times(0); |
+ |
+ EXPECT_FALSE(DLOG_IS_ON(FATAL)); |
+ |
+ DLOG_IF(ERROR, true) << uncalled_mock_log_source.Log(); |
+ DPLOG_IF(ERROR, true) << uncalled_mock_log_source.Log(); |
+ DVLOG_IF(LOG_ERROR, true) << uncalled_mock_log_source.Log(); |
+ DVPLOG_IF(LOG_ERROR, true) << uncalled_mock_log_source.Log(); |
+ |
+#else |
+ // Debug builds. |
+ MockLogSource mock_log_source; |
+ SetMinLogLevel(-LOG_ERROR); |
+ EXPECT_CALL(mock_log_source, Log()).Times(4). |
+ WillRepeatedly(Return("check message")); |
+ |
+ EXPECT_TRUE(DLOG_IS_ON(ERROR)); |
+ |
+ DLOG_IF(ERROR, true) << mock_log_source.Log(); |
+ DPLOG_IF(ERROR, true) << mock_log_source.Log(); |
+ DVLOG_IF(LOG_ERROR, true) << mock_log_source.Log(); |
+ DVPLOG_IF(LOG_ERROR, true) << mock_log_source.Log(); |
+ |
+#endif // defined(LOGGING_IS_OFFICIAL_BUILD) |
+} |
+ |
+ |
TEST_F(LoggingTest, Dcheck) { |
#if defined(LOGGING_IS_OFFICIAL_BUILD) |
// Official build. |