| 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 27 matching lines...) Expand all Loading... |
| 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, matcher, fail) \ | 41 #define GTEST_DFATAL_(statement, matcher, fail) \ |
| 42 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ | 42 GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ |
| 43 if (true) { \ | 43 if (true) { \ |
| 44 ::base::test::MockLog gtest_log; \ | 44 ::base::test::MockLog gtest_log; \ |
| 45 ::net::test::ScopedDisableExitOnDFatal gtest_disable_exit; \ | 45 ::net::test::ScopedDisableExitOnDFatal gtest_disable_exit; \ |
| 46 using ::testing::_; \ | 46 using ::testing::_; \ |
| 47 EXPECT_CALL(gtest_log, Log(_, _, _, _, _)) \ | 47 EXPECT_CALL(gtest_log, Log(_, _, _, _, _)) \ |
| 48 .WillRepeatedly(::testing::Return(false)); \ | 48 .Times(::testing::AtLeast(0)); \ |
| 49 EXPECT_CALL(gtest_log, Log(logging::LOG_DFATAL, _, _, _, matcher)) \ | 49 EXPECT_CALL(gtest_log, Log(logging::LOG_DFATAL, _, _, _, matcher)) \ |
| 50 .Times(::testing::AtLeast(1)) \ | 50 .Times(::testing::AtLeast(1)); \ |
| 51 .WillOnce(::testing::Return(false)); \ | |
| 52 gtest_log.StartCapturingLogs(); \ | 51 gtest_log.StartCapturingLogs(); \ |
| 53 { statement; } \ | 52 { statement; } \ |
| 54 gtest_log.StopCapturingLogs(); \ | 53 gtest_log.StopCapturingLogs(); \ |
| 55 if (!testing::Mock::VerifyAndClear(>est_log)) { \ | 54 if (!testing::Mock::VerifyAndClear(>est_log)) { \ |
| 56 goto GTEST_CONCAT_TOKEN_(gtest_label_dfatal_, __LINE__); \ | 55 goto GTEST_CONCAT_TOKEN_(gtest_label_dfatal_, __LINE__); \ |
| 57 } \ | 56 } \ |
| 58 } else \ | 57 } else \ |
| 59 GTEST_CONCAT_TOKEN_(gtest_label_dfatal_, __LINE__) : fail("") | 58 GTEST_CONCAT_TOKEN_(gtest_label_dfatal_, __LINE__) : fail("") |
| 60 | 59 |
| 61 // The EXPECT_DFATAL and ASSERT_DFATAL macros are lightweight | 60 // The EXPECT_DFATAL and ASSERT_DFATAL macros are lightweight |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 statement; \ | 109 statement; \ |
| 111 } else \ | 110 } else \ |
| 112 GTEST_NONFATAL_FAILURE_("") | 111 GTEST_NONFATAL_FAILURE_("") |
| 113 | 112 |
| 114 #endif // NDEBUG | 113 #endif // NDEBUG |
| 115 | 114 |
| 116 } // namespace test | 115 } // namespace test |
| 117 } // namespace net | 116 } // namespace net |
| 118 | 117 |
| 119 #endif // NET_TEST_GTEST_UTIL_H_ | 118 #endif // NET_TEST_GTEST_UTIL_H_ |
| OLD | NEW |