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

Side by Side Diff: webrtc/base/gunit.h

Issue 2212683002: Do not switch a connection if the new connection is not ready to send packets. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Merge Created 4 years, 4 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
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 << (timeout) << "ms; waiting an additional " << margin \ 85 << (timeout) << "ms; waiting an additional " << margin \
86 << "ms"; \ 86 << "ms"; \
87 WAIT_(ex, margin, res); \ 87 WAIT_(ex, margin, res); \
88 if (!res) { \ 88 if (!res) { \
89 EXPECT_TRUE(ex); \ 89 EXPECT_TRUE(ex); \
90 } \ 90 } \
91 } while (0) 91 } while (0)
92 92
93 // Wait until "ex" is true, or "timeout" expires, using fake clock where 93 // Wait until "ex" is true, or "timeout" expires, using fake clock where
94 // messages are processed every millisecond. 94 // messages are processed every millisecond.
95 #define SIMULATED_WAIT(ex, timeout, clock) \ 95 #define SIMULATED_WAIT(ex, timeout, clock) \
96 for (int64_t start = rtc::TimeMillis(); \ 96 for (int64_t start = rtc::TimeMillis(); \
97 !(ex) && rtc::TimeMillis() < start + (timeout);) { \ 97 !(ex) && rtc::TimeMillis() < start + (timeout);) { \
98 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); \ 98 (clock).AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); \
99 } 99 }
100 100
101 // This returns the result of the test in res, so that we don't re-evaluate 101 // This returns the result of the test in res, so that we don't re-evaluate
102 // the expression in the XXXX_WAIT macros below, since that causes problems 102 // the expression in the XXXX_WAIT macros below, since that causes problems
103 // when the expression is only true the first time you check it. 103 // when the expression is only true the first time you check it.
104 #define SIMULATED_WAIT_(ex, timeout, res, clock) \ 104 #define SIMULATED_WAIT_(ex, timeout, res, clock) \
105 do { \ 105 do { \
106 int64_t start = rtc::TimeMillis(); \ 106 int64_t start = rtc::TimeMillis(); \
107 res = (ex); \ 107 res = (ex); \
108 while (!res && rtc::TimeMillis() < start + (timeout)) { \ 108 while (!res && rtc::TimeMillis() < start + (timeout)) { \
109 clock.AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); \ 109 (clock).AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); \
110 res = (ex); \ 110 res = (ex); \
111 } \ 111 } \
112 } while (0) 112 } while (0)
113 113
114 // The typical EXPECT_XXXX, but done until true or a timeout with a fake clock. 114 // The typical EXPECT_XXXX, but done until true or a timeout with a fake clock.
115 #define EXPECT_TRUE_SIMULATED_WAIT(ex, timeout, clock) \ 115 #define EXPECT_TRUE_SIMULATED_WAIT(ex, timeout, clock) \
116 do { \ 116 do { \
117 bool res; \ 117 bool res; \
118 SIMULATED_WAIT_(ex, timeout, res, clock); \ 118 SIMULATED_WAIT_(ex, timeout, res, clock); \
119 if (!res) { \ 119 if (!res) { \
120 EXPECT_TRUE(ex); \ 120 EXPECT_TRUE(ex); \
121 } \ 121 } \
(...skipping 18 matching lines...) Expand all
140 140
141 #define ASSERT_EQ_SIMULATED_WAIT(v1, v2, timeout, clock) \ 141 #define ASSERT_EQ_SIMULATED_WAIT(v1, v2, timeout, clock) \
142 do { \ 142 do { \
143 bool res; \ 143 bool res; \
144 SIMULATED_WAIT_(v1 == v2, timeout, res, clock); \ 144 SIMULATED_WAIT_(v1 == v2, timeout, res, clock); \
145 if (!res) \ 145 if (!res) \
146 ASSERT_EQ(v1, v2); \ 146 ASSERT_EQ(v1, v2); \
147 } while (0) 147 } while (0)
148 148
149 #endif // WEBRTC_BASE_GUNIT_H_ 149 #endif // WEBRTC_BASE_GUNIT_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698