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

Side by Side Diff: net/test/gtest_util.h

Issue 2034393004: Allow multiple logging::LogMessage{Handler,Listener}s Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up, MockLog uses listener Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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
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(&gtest_log)) { \ 54 if (!testing::Mock::VerifyAndClear(&gtest_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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698