Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // TODO(pthatcher): Increase this to 10ms to speed up some tests. | |
|
Taylor Brandstetter
2017/02/06 19:23:42
I'd recommend removing this TODO. Individual tests
| |
| 95 #define SIMULATED_WAIT(ex, timeout, clock) \ | 96 #define SIMULATED_WAIT(ex, timeout, clock) \ |
| 96 for (int64_t start = rtc::TimeMillis(); \ | 97 for (int64_t start = rtc::TimeMillis(); \ |
| 97 !(ex) && rtc::TimeMillis() < start + (timeout);) { \ | 98 !(ex) && rtc::TimeMillis() < start + (timeout);) { \ |
| 98 (clock).AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); \ | 99 (clock).AdvanceTime(rtc::TimeDelta::FromMilliseconds(1)); \ |
| 99 } | 100 } |
| 100 | 101 |
| 101 // This returns the result of the test in res, so that we don't re-evaluate | 102 // 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 | 103 // 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. | 104 // when the expression is only true the first time you check it. |
| 104 #define SIMULATED_WAIT_(ex, timeout, res, clock) \ | 105 #define SIMULATED_WAIT_(ex, timeout, res, clock) \ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 141 |
| 141 #define ASSERT_EQ_SIMULATED_WAIT(v1, v2, timeout, clock) \ | 142 #define ASSERT_EQ_SIMULATED_WAIT(v1, v2, timeout, clock) \ |
| 142 do { \ | 143 do { \ |
| 143 bool res; \ | 144 bool res; \ |
| 144 SIMULATED_WAIT_(v1 == v2, timeout, res, clock); \ | 145 SIMULATED_WAIT_(v1 == v2, timeout, res, clock); \ |
| 145 if (!res) \ | 146 if (!res) \ |
| 146 ASSERT_EQ(v1, v2); \ | 147 ASSERT_EQ(v1, v2); \ |
| 147 } while (0) | 148 } while (0) |
| 148 | 149 |
| 149 #endif // WEBRTC_BASE_GUNIT_H_ | 150 #endif // WEBRTC_BASE_GUNIT_H_ |
| OLD | NEW |