| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 | 8 |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 InitLogging(settings); | 178 InitLogging(settings); |
| 179 | 179 |
| 180 LOG(INFO) << mock_log_source.Log(); | 180 LOG(INFO) << mock_log_source.Log(); |
| 181 LOG(WARNING) << mock_log_source.Log(); | 181 LOG(WARNING) << mock_log_source.Log(); |
| 182 LOG(ERROR) << mock_log_source_error.Log(); | 182 LOG(ERROR) << mock_log_source_error.Log(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Official builds have CHECKs directly call BreakDebugger. | 185 // Official builds have CHECKs directly call BreakDebugger. |
| 186 #if !defined(OFFICIAL_BUILD) | 186 #if !defined(OFFICIAL_BUILD) |
| 187 | 187 |
| 188 TEST_F(LoggingTest, CheckStreamsAreLazy) { | 188 // https://crbug.com/709067 tracks test flakiness on iOS. |
| 189 #if defined(OS_IOS) |
| 190 #define MAYBE_CheckStreamsAreLazy DISABLED_CheckStreamsAreLazy |
| 191 #else |
| 192 #define MAYBE_CheckStreamsAreLazy CheckStreamsAreLazy |
| 193 #endif |
| 194 TEST_F(LoggingTest, MAYBE_CheckStreamsAreLazy) { |
| 189 MockLogSource mock_log_source, uncalled_mock_log_source; | 195 MockLogSource mock_log_source, uncalled_mock_log_source; |
| 190 EXPECT_CALL(mock_log_source, Log()).Times(8). | 196 EXPECT_CALL(mock_log_source, Log()).Times(8). |
| 191 WillRepeatedly(Return("check message")); | 197 WillRepeatedly(Return("check message")); |
| 192 EXPECT_CALL(uncalled_mock_log_source, Log()).Times(0); | 198 EXPECT_CALL(uncalled_mock_log_source, Log()).Times(0); |
| 193 | 199 |
| 194 SetLogAssertHandler(&LogSink); | 200 SetLogAssertHandler(&LogSink); |
| 195 | 201 |
| 196 CHECK(mock_log_source.Log()) << uncalled_mock_log_source.Log(); | 202 CHECK(mock_log_source.Log()) << uncalled_mock_log_source.Log(); |
| 197 PCHECK(!mock_log_source.Log()) << mock_log_source.Log(); | 203 PCHECK(!mock_log_source.Log()) << mock_log_source.Log(); |
| 198 CHECK_EQ(mock_log_source.Log(), mock_log_source.Log()) | 204 CHECK_EQ(mock_log_source.Log(), mock_log_source.Log()) |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 385 } |
| 380 | 386 |
| 381 void DcheckEmptyFunction1() { | 387 void DcheckEmptyFunction1() { |
| 382 // Provide a body so that Release builds do not cause the compiler to | 388 // Provide a body so that Release builds do not cause the compiler to |
| 383 // optimize DcheckEmptyFunction1 and DcheckEmptyFunction2 as a single | 389 // optimize DcheckEmptyFunction1 and DcheckEmptyFunction2 as a single |
| 384 // function, which breaks the Dcheck tests below. | 390 // function, which breaks the Dcheck tests below. |
| 385 LOG(INFO) << "DcheckEmptyFunction1"; | 391 LOG(INFO) << "DcheckEmptyFunction1"; |
| 386 } | 392 } |
| 387 void DcheckEmptyFunction2() {} | 393 void DcheckEmptyFunction2() {} |
| 388 | 394 |
| 389 TEST_F(LoggingTest, Dcheck) { | 395 // https://crbug.com/709067 tracks test flakiness on iOS. |
| 396 #if defined(OS_IOS) |
| 397 #define MAYBE_Dcheck DISABLED_Dcheck |
| 398 #else |
| 399 #define MAYBE_Dcheck Dcheck |
| 400 #endif |
| 401 TEST_F(LoggingTest, MAYBE_Dcheck) { |
| 390 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) | 402 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
| 391 // Release build. | 403 // Release build. |
| 392 EXPECT_FALSE(DCHECK_IS_ON()); | 404 EXPECT_FALSE(DCHECK_IS_ON()); |
| 393 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); | 405 EXPECT_FALSE(DLOG_IS_ON(DCHECK)); |
| 394 #elif defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) | 406 #elif defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) |
| 395 // Release build with real DCHECKS. | 407 // Release build with real DCHECKS. |
| 396 SetLogAssertHandler(&LogSink); | 408 SetLogAssertHandler(&LogSink); |
| 397 EXPECT_TRUE(DCHECK_IS_ON()); | 409 EXPECT_TRUE(DCHECK_IS_ON()); |
| 398 EXPECT_TRUE(DLOG_IS_ON(DCHECK)); | 410 EXPECT_TRUE(DLOG_IS_ON(DCHECK)); |
| 399 #else | 411 #else |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 std::wstring wstr = L"Hello World"; | 514 std::wstring wstr = L"Hello World"; |
| 503 std::ostringstream ostr; | 515 std::ostringstream ostr; |
| 504 ostr << wstr; | 516 ostr << wstr; |
| 505 EXPECT_EQ("Hello World", ostr.str()); | 517 EXPECT_EQ("Hello World", ostr.str()); |
| 506 } | 518 } |
| 507 } // namespace nested_test | 519 } // namespace nested_test |
| 508 | 520 |
| 509 } // namespace | 521 } // namespace |
| 510 | 522 |
| 511 } // namespace logging | 523 } // namespace logging |
| OLD | NEW |