OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 28 matching lines...) Expand all Loading... |
39 #import "RTCVideoRenderer.h" | 39 #import "RTCVideoRenderer.h" |
40 #import "RTCVideoTrack.h" | 40 #import "RTCVideoTrack.h" |
41 | 41 |
42 #include "webrtc/base/gunit.h" | 42 #include "webrtc/base/gunit.h" |
43 #include "webrtc/base/ssladapter.h" | 43 #include "webrtc/base/ssladapter.h" |
44 | 44 |
45 #if !defined(__has_feature) || !__has_feature(objc_arc) | 45 #if !defined(__has_feature) || !__has_feature(objc_arc) |
46 #error "This file requires ARC support." | 46 #error "This file requires ARC support." |
47 #endif | 47 #endif |
48 | 48 |
| 49 const NSTimeInterval kRTCPeerConnectionTestTimeout = 20; |
| 50 |
49 @interface RTCFakeRenderer : NSObject <RTCVideoRenderer> | 51 @interface RTCFakeRenderer : NSObject <RTCVideoRenderer> |
50 @end | 52 @end |
51 | 53 |
52 @implementation RTCFakeRenderer | 54 @implementation RTCFakeRenderer |
53 | 55 |
54 - (void)setSize:(CGSize)size {} | 56 - (void)setSize:(CGSize)size {} |
55 - (void)renderFrame:(RTCI420Frame*)frame {} | 57 - (void)renderFrame:(RTCI420Frame*)frame {} |
56 | 58 |
57 @end | 59 @end |
58 | 60 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 230 |
229 for (RTCICECandidate* candidate in offeringExpectations | 231 for (RTCICECandidate* candidate in offeringExpectations |
230 .releaseReceivedICECandidates) { | 232 .releaseReceivedICECandidates) { |
231 [pcAnswer addICECandidate:candidate]; | 233 [pcAnswer addICECandidate:candidate]; |
232 } | 234 } |
233 for (RTCICECandidate* candidate in answeringExpectations | 235 for (RTCICECandidate* candidate in answeringExpectations |
234 .releaseReceivedICECandidates) { | 236 .releaseReceivedICECandidates) { |
235 [pcOffer addICECandidate:candidate]; | 237 [pcOffer addICECandidate:candidate]; |
236 } | 238 } |
237 | 239 |
238 [offeringExpectations waitForAllExpectationsToBeSatisfied]; | 240 EXPECT_TRUE( |
239 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 241 [offeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 242 kRTCPeerConnectionTestTimeout]); |
| 243 EXPECT_TRUE( |
| 244 [answeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 245 kRTCPeerConnectionTestTimeout]); |
240 | 246 |
241 EXPECT_EQ(pcOffer.signalingState, RTCSignalingStable); | 247 EXPECT_EQ(pcOffer.signalingState, RTCSignalingStable); |
242 EXPECT_EQ(pcAnswer.signalingState, RTCSignalingStable); | 248 EXPECT_EQ(pcAnswer.signalingState, RTCSignalingStable); |
243 | 249 |
244 // Test send and receive UTF-8 text | 250 // Test send and receive UTF-8 text |
245 NSString* text = @"你好"; | 251 NSString* text = @"你好"; |
246 NSData* textData = [text dataUsingEncoding:NSUTF8StringEncoding]; | 252 NSData* textData = [text dataUsingEncoding:NSUTF8StringEncoding]; |
247 RTCDataBuffer* buffer = | 253 RTCDataBuffer* buffer = |
248 [[RTCDataBuffer alloc] initWithData:textData isBinary:NO]; | 254 [[RTCDataBuffer alloc] initWithData:textData isBinary:NO]; |
249 [answeringExpectations expectMessage:[textData copy] isBinary:NO]; | 255 [answeringExpectations expectMessage:[textData copy] isBinary:NO]; |
250 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); | 256 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); |
251 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 257 EXPECT_TRUE( |
| 258 [answeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 259 kRTCPeerConnectionTestTimeout]); |
252 | 260 |
253 // Test send and receive binary data | 261 // Test send and receive binary data |
254 const size_t byteLength = 5; | 262 const size_t byteLength = 5; |
255 char bytes[byteLength] = {1, 2, 3, 4, 5}; | 263 char bytes[byteLength] = {1, 2, 3, 4, 5}; |
256 NSData* byteData = [NSData dataWithBytes:bytes length:byteLength]; | 264 NSData* byteData = [NSData dataWithBytes:bytes length:byteLength]; |
257 buffer = [[RTCDataBuffer alloc] initWithData:byteData isBinary:YES]; | 265 buffer = [[RTCDataBuffer alloc] initWithData:byteData isBinary:YES]; |
258 [answeringExpectations expectMessage:[byteData copy] isBinary:YES]; | 266 [answeringExpectations expectMessage:[byteData copy] isBinary:YES]; |
259 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); | 267 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); |
260 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 268 EXPECT_TRUE( |
| 269 [answeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 270 kRTCPeerConnectionTestTimeout]); |
261 | 271 |
262 [offeringExpectations expectStateChange:kRTCDataChannelStateClosing]; | 272 [offeringExpectations expectStateChange:kRTCDataChannelStateClosing]; |
263 [answeringExpectations expectStateChange:kRTCDataChannelStateClosing]; | 273 [answeringExpectations expectStateChange:kRTCDataChannelStateClosing]; |
264 [offeringExpectations expectStateChange:kRTCDataChannelStateClosed]; | 274 [offeringExpectations expectStateChange:kRTCDataChannelStateClosed]; |
265 [answeringExpectations expectStateChange:kRTCDataChannelStateClosed]; | 275 [answeringExpectations expectStateChange:kRTCDataChannelStateClosed]; |
266 | 276 |
267 [answeringExpectations.dataChannel close]; | 277 [answeringExpectations.dataChannel close]; |
268 [offeringExpectations.dataChannel close]; | 278 [offeringExpectations.dataChannel close]; |
269 | 279 |
270 [offeringExpectations waitForAllExpectationsToBeSatisfied]; | 280 EXPECT_TRUE( |
271 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 281 [offeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 282 kRTCPeerConnectionTestTimeout]); |
| 283 EXPECT_TRUE( |
| 284 [answeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 285 kRTCPeerConnectionTestTimeout]); |
272 // Don't need to listen to further state changes. | 286 // Don't need to listen to further state changes. |
273 // TODO(tkchin): figure out why Closed->Closing without this. | 287 // TODO(tkchin): figure out why Closed->Closing without this. |
274 offeringExpectations.dataChannel.delegate = nil; | 288 offeringExpectations.dataChannel.delegate = nil; |
275 answeringExpectations.dataChannel.delegate = nil; | 289 answeringExpectations.dataChannel.delegate = nil; |
276 | 290 |
277 // Let the audio feedback run for 2s to allow human testing and to ensure | 291 // Let the audio feedback run for 2s to allow human testing and to ensure |
278 // things stabilize. TODO(fischman): replace seconds with # of video frames, | 292 // things stabilize. TODO(fischman): replace seconds with # of video frames, |
279 // when we have video flowing. | 293 // when we have video flowing. |
280 [[NSRunLoop currentRunLoop] | 294 [[NSRunLoop currentRunLoop] |
281 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]]; | 295 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]]; |
282 | 296 |
283 [offeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; | 297 [offeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; |
284 [answeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; | 298 [answeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; |
285 [offeringExpectations expectSignalingChange:RTCSignalingClosed]; | 299 [offeringExpectations expectSignalingChange:RTCSignalingClosed]; |
286 [answeringExpectations expectSignalingChange:RTCSignalingClosed]; | 300 [answeringExpectations expectSignalingChange:RTCSignalingClosed]; |
287 | 301 |
288 [pcOffer close]; | 302 [pcOffer close]; |
289 [pcAnswer close]; | 303 [pcAnswer close]; |
290 | 304 |
291 [offeringExpectations waitForAllExpectationsToBeSatisfied]; | 305 EXPECT_TRUE( |
292 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 306 [offeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 307 kRTCPeerConnectionTestTimeout]); |
| 308 EXPECT_TRUE( |
| 309 [answeringExpectations waitForAllExpectationsToBeSatisfiedWithTimeout: |
| 310 kRTCPeerConnectionTestTimeout]); |
293 | 311 |
294 capturer = nil; | 312 capturer = nil; |
295 videoSource = nil; | 313 videoSource = nil; |
296 pcOffer = nil; | 314 pcOffer = nil; |
297 pcAnswer = nil; | 315 pcAnswer = nil; |
298 // TODO(fischman): be stricter about shutdown checks; ensure thread | 316 // TODO(fischman): be stricter about shutdown checks; ensure thread |
299 // counts return to where they were before the test kicked off, and | 317 // counts return to where they were before the test kicked off, and |
300 // that all objects have in fact shut down. | 318 // that all objects have in fact shut down. |
301 } | 319 } |
302 | 320 |
(...skipping 13 matching lines...) Expand all Loading... |
316 // factory outlives RTCPeerConnection:dealloc. | 334 // factory outlives RTCPeerConnection:dealloc. |
317 // See https://code.google.com/p/webrtc/issues/detail?id=3100. | 335 // See https://code.google.com/p/webrtc/issues/detail?id=3100. |
318 RTCPeerConnectionFactory* factory = [[RTCPeerConnectionFactory alloc] init]; | 336 RTCPeerConnectionFactory* factory = [[RTCPeerConnectionFactory alloc] init]; |
319 @autoreleasepool { | 337 @autoreleasepool { |
320 RTCPeerConnectionTest* pcTest = [[RTCPeerConnectionTest alloc] init]; | 338 RTCPeerConnectionTest* pcTest = [[RTCPeerConnectionTest alloc] init]; |
321 [pcTest testCompleteSessionWithFactory:factory]; | 339 [pcTest testCompleteSessionWithFactory:factory]; |
322 } | 340 } |
323 rtc::CleanupSSL(); | 341 rtc::CleanupSSL(); |
324 } | 342 } |
325 } | 343 } |
OLD | NEW |