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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 EXPECT_FALSE(failure_); | 139 EXPECT_FALSE(failure_); |
140 EXPECT_FALSE(timeout_); | 140 EXPECT_FALSE(timeout_); |
141 delete res; | 141 delete res; |
142 } | 142 } |
143 | 143 |
144 // Test that requests are sent at the right times, and that the 9th request | 144 // Test that requests are sent at the right times, and that the 9th request |
145 // (sent at 7900 ms) can be properly replied to. | 145 // (sent at 7900 ms) can be properly replied to. |
146 TEST_F(StunRequestTest, TestBackoff) { | 146 TEST_F(StunRequestTest, TestBackoff) { |
147 StunMessage* req = CreateStunMessage(STUN_BINDING_REQUEST, NULL); | 147 StunMessage* req = CreateStunMessage(STUN_BINDING_REQUEST, NULL); |
148 | 148 |
149 uint32 start = rtc::Time(); | 149 uint32_t start = rtc::Time(); |
150 manager_.Send(new StunRequestThunker(req, this)); | 150 manager_.Send(new StunRequestThunker(req, this)); |
151 StunMessage* res = CreateStunMessage(STUN_BINDING_RESPONSE, req); | 151 StunMessage* res = CreateStunMessage(STUN_BINDING_RESPONSE, req); |
152 for (int i = 0; i < 9; ++i) { | 152 for (int i = 0; i < 9; ++i) { |
153 while (request_count_ == i) | 153 while (request_count_ == i) |
154 rtc::Thread::Current()->ProcessMessages(1); | 154 rtc::Thread::Current()->ProcessMessages(1); |
155 int32 elapsed = rtc::TimeSince(start); | 155 int32_t elapsed = rtc::TimeSince(start); |
156 LOG(LS_INFO) << "STUN request #" << (i + 1) | 156 LOG(LS_INFO) << "STUN request #" << (i + 1) |
157 << " sent at " << elapsed << " ms"; | 157 << " sent at " << elapsed << " ms"; |
158 EXPECT_GE(TotalDelay(i + 1), elapsed); | 158 EXPECT_GE(TotalDelay(i + 1), elapsed); |
159 } | 159 } |
160 EXPECT_TRUE(manager_.CheckResponse(res)); | 160 EXPECT_TRUE(manager_.CheckResponse(res)); |
161 | 161 |
162 EXPECT_TRUE(response_ == res); | 162 EXPECT_TRUE(response_ == res); |
163 EXPECT_TRUE(success_); | 163 EXPECT_TRUE(success_); |
164 EXPECT_FALSE(failure_); | 164 EXPECT_FALSE(failure_); |
165 EXPECT_FALSE(timeout_); | 165 EXPECT_FALSE(timeout_); |
(...skipping 28 matching lines...) Expand all Loading... |
194 StunMessage* res = CreateStunMessage(STUN_BINDING_RESPONSE, &dummy_req); | 194 StunMessage* res = CreateStunMessage(STUN_BINDING_RESPONSE, &dummy_req); |
195 | 195 |
196 EXPECT_TRUE(manager_.CheckResponse(res)); | 196 EXPECT_TRUE(manager_.CheckResponse(res)); |
197 | 197 |
198 EXPECT_TRUE(response_ == res); | 198 EXPECT_TRUE(response_ == res); |
199 EXPECT_TRUE(success_); | 199 EXPECT_TRUE(success_); |
200 EXPECT_FALSE(failure_); | 200 EXPECT_FALSE(failure_); |
201 EXPECT_FALSE(timeout_); | 201 EXPECT_FALSE(timeout_); |
202 delete res; | 202 delete res; |
203 } | 203 } |
OLD | NEW |