| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Testing utilities that extend gtest. | 5 // Testing utilities that extend gtest. |
| 6 | 6 |
| 7 #ifndef NET_TEST_GTEST_UTIL_H_ | 7 #ifndef NET_TEST_GTEST_UTIL_H_ |
| 8 #define NET_TEST_GTEST_UTIL_H_ | 8 #define NET_TEST_GTEST_UTIL_H_ |
| 9 | 9 |
| 10 #include "base/test/mock_log.h" | 10 #include "base/test/mock_log.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return arg == net::OK; | 36 return arg == net::OK; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Internal implementation for the EXPECT_DFATAL and ASSERT_DFATAL | 39 // Internal implementation for the EXPECT_DFATAL and ASSERT_DFATAL |
| 40 // macros. Do not use this directly. | 40 // macros. Do not use this directly. |
| 41 #define GTEST_DFATAL_(statement, severity, matcher, fail) \ | 41 #define GTEST_DFATAL_(statement, severity, matcher, fail) \ |
| 42 do { \ | 42 do { \ |
| 43 ::base::test::MockLog gtest_log; \ | 43 ::base::test::MockLog gtest_log; \ |
| 44 ::net::test::ScopedDisableExitOnDFatal gtest_disable_exit; \ | 44 ::net::test::ScopedDisableExitOnDFatal gtest_disable_exit; \ |
| 45 using ::testing::_; \ | 45 using ::testing::_; \ |
| 46 EXPECT_CALL(gtest_log, Log(_, _, _, _, _)) \ | 46 EXPECT_CALL(gtest_log, Log(_, _, _, _, _)).Times(::testing::AtLeast(0)); \ |
| 47 .WillRepeatedly(::testing::Return(false)); \ | |
| 48 EXPECT_CALL(gtest_log, Log(::logging::LOG_##severity, _, _, _, matcher)) \ | 47 EXPECT_CALL(gtest_log, Log(::logging::LOG_##severity, _, _, _, matcher)) \ |
| 49 .Times(::testing::AtLeast(1)) \ | 48 .Times(::testing::AtLeast(1)); \ |
| 50 .WillOnce(::testing::Return(false)); \ | |
| 51 gtest_log.StartCapturingLogs(); \ | 49 gtest_log.StartCapturingLogs(); \ |
| 52 { statement; } \ | 50 { statement; } \ |
| 53 gtest_log.StopCapturingLogs(); \ | 51 gtest_log.StopCapturingLogs(); \ |
| 54 if (!testing::Mock::VerifyAndClear(>est_log)) \ | 52 if (!testing::Mock::VerifyAndClear(>est_log)) \ |
| 55 fail(""); \ | 53 fail(""); \ |
| 56 } while (false) | 54 } while (false) |
| 57 | 55 |
| 58 // The EXPECT_DFATAL and ASSERT_DFATAL macros are lightweight | 56 // The EXPECT_DFATAL and ASSERT_DFATAL macros are lightweight |
| 59 // alternatives to EXPECT_DEBUG_DEATH and ASSERT_DEBUG_DEATH. They | 57 // alternatives to EXPECT_DEBUG_DEATH and ASSERT_DEBUG_DEATH. They |
| 60 // are appropriate for testing that your code logs a message at the | 58 // are appropriate for testing that your code logs a message at the |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 (void)(regex); \ | 129 (void)(regex); \ |
| 132 statement; \ | 130 statement; \ |
| 133 } while (false) | 131 } while (false) |
| 134 | 132 |
| 135 #endif // DCHECK_IS_ON() | 133 #endif // DCHECK_IS_ON() |
| 136 | 134 |
| 137 } // namespace test | 135 } // namespace test |
| 138 } // namespace net | 136 } // namespace net |
| 139 | 137 |
| 140 #endif // NET_TEST_GTEST_UTIL_H_ | 138 #endif // NET_TEST_GTEST_UTIL_H_ |
| OLD | NEW |