Chromium Code Reviews| 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 #define TIMEOUT_SECONDS 20 | |
|
tkchin_webrtc
2015/09/25 15:40:32
Avoid defines, prefer constants.
const NSTimeInter
Taylor Brandstetter
2015/09/25 18:01:57
Ah. I wasn't sure how to avoid the constant having
tkchin_webrtc
2015/09/25 19:51:03
Yeh, this is a standard thing in ObjC - just add t
| |
| 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([offeringExpectations |
|
tkchin_webrtc
2015/09/25 15:40:32
Wouldn't this be a critical failure? Do we want AS
Taylor Brandstetter
2015/09/25 18:01:57
Well, not necessarily. The last time this broke fo
tkchin_webrtc
2015/09/25 19:51:03
Gotcha.
| |
| 239 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 241 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); |
| 242 EXPECT_TRUE([answeringExpectations | |
| 243 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); | |
| 240 | 244 |
| 241 EXPECT_EQ(pcOffer.signalingState, RTCSignalingStable); | 245 EXPECT_EQ(pcOffer.signalingState, RTCSignalingStable); |
| 242 EXPECT_EQ(pcAnswer.signalingState, RTCSignalingStable); | 246 EXPECT_EQ(pcAnswer.signalingState, RTCSignalingStable); |
| 243 | 247 |
| 244 // Test send and receive UTF-8 text | 248 // Test send and receive UTF-8 text |
| 245 NSString* text = @"你好"; | 249 NSString* text = @"你好"; |
| 246 NSData* textData = [text dataUsingEncoding:NSUTF8StringEncoding]; | 250 NSData* textData = [text dataUsingEncoding:NSUTF8StringEncoding]; |
| 247 RTCDataBuffer* buffer = | 251 RTCDataBuffer* buffer = |
| 248 [[RTCDataBuffer alloc] initWithData:textData isBinary:NO]; | 252 [[RTCDataBuffer alloc] initWithData:textData isBinary:NO]; |
| 249 [answeringExpectations expectMessage:[textData copy] isBinary:NO]; | 253 [answeringExpectations expectMessage:[textData copy] isBinary:NO]; |
| 250 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); | 254 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); |
| 251 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 255 EXPECT_TRUE([answeringExpectations |
| 256 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); | |
| 252 | 257 |
| 253 // Test send and receive binary data | 258 // Test send and receive binary data |
| 254 const size_t byteLength = 5; | 259 const size_t byteLength = 5; |
| 255 char bytes[byteLength] = {1, 2, 3, 4, 5}; | 260 char bytes[byteLength] = {1, 2, 3, 4, 5}; |
| 256 NSData* byteData = [NSData dataWithBytes:bytes length:byteLength]; | 261 NSData* byteData = [NSData dataWithBytes:bytes length:byteLength]; |
| 257 buffer = [[RTCDataBuffer alloc] initWithData:byteData isBinary:YES]; | 262 buffer = [[RTCDataBuffer alloc] initWithData:byteData isBinary:YES]; |
| 258 [answeringExpectations expectMessage:[byteData copy] isBinary:YES]; | 263 [answeringExpectations expectMessage:[byteData copy] isBinary:YES]; |
| 259 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); | 264 EXPECT_TRUE([offeringExpectations.dataChannel sendData:buffer]); |
| 260 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 265 EXPECT_TRUE([answeringExpectations |
| 266 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); | |
| 261 | 267 |
| 262 [offeringExpectations expectStateChange:kRTCDataChannelStateClosing]; | 268 [offeringExpectations expectStateChange:kRTCDataChannelStateClosing]; |
| 263 [answeringExpectations expectStateChange:kRTCDataChannelStateClosing]; | 269 [answeringExpectations expectStateChange:kRTCDataChannelStateClosing]; |
| 264 [offeringExpectations expectStateChange:kRTCDataChannelStateClosed]; | 270 [offeringExpectations expectStateChange:kRTCDataChannelStateClosed]; |
| 265 [answeringExpectations expectStateChange:kRTCDataChannelStateClosed]; | 271 [answeringExpectations expectStateChange:kRTCDataChannelStateClosed]; |
| 266 | 272 |
| 267 [answeringExpectations.dataChannel close]; | 273 [answeringExpectations.dataChannel close]; |
| 268 [offeringExpectations.dataChannel close]; | 274 [offeringExpectations.dataChannel close]; |
| 269 | 275 |
| 270 [offeringExpectations waitForAllExpectationsToBeSatisfied]; | 276 EXPECT_TRUE([offeringExpectations |
| 271 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 277 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); |
| 278 EXPECT_TRUE([answeringExpectations | |
| 279 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); | |
| 272 // Don't need to listen to further state changes. | 280 // Don't need to listen to further state changes. |
| 273 // TODO(tkchin): figure out why Closed->Closing without this. | 281 // TODO(tkchin): figure out why Closed->Closing without this. |
| 274 offeringExpectations.dataChannel.delegate = nil; | 282 offeringExpectations.dataChannel.delegate = nil; |
| 275 answeringExpectations.dataChannel.delegate = nil; | 283 answeringExpectations.dataChannel.delegate = nil; |
| 276 | 284 |
| 277 // Let the audio feedback run for 2s to allow human testing and to ensure | 285 // 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, | 286 // things stabilize. TODO(fischman): replace seconds with # of video frames, |
| 279 // when we have video flowing. | 287 // when we have video flowing. |
| 280 [[NSRunLoop currentRunLoop] | 288 [[NSRunLoop currentRunLoop] |
| 281 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]]; | 289 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]]; |
| 282 | 290 |
| 283 [offeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; | 291 [offeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; |
| 284 [answeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; | 292 [answeringExpectations expectICEConnectionChange:RTCICEConnectionClosed]; |
| 285 [offeringExpectations expectSignalingChange:RTCSignalingClosed]; | 293 [offeringExpectations expectSignalingChange:RTCSignalingClosed]; |
| 286 [answeringExpectations expectSignalingChange:RTCSignalingClosed]; | 294 [answeringExpectations expectSignalingChange:RTCSignalingClosed]; |
| 287 | 295 |
| 288 [pcOffer close]; | 296 [pcOffer close]; |
| 289 [pcAnswer close]; | 297 [pcAnswer close]; |
| 290 | 298 |
| 291 [offeringExpectations waitForAllExpectationsToBeSatisfied]; | 299 EXPECT_TRUE([offeringExpectations |
| 292 [answeringExpectations waitForAllExpectationsToBeSatisfied]; | 300 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); |
| 301 EXPECT_TRUE([answeringExpectations | |
| 302 waitForAllExpectationsToBeSatisfiedWithTimeout:TIMEOUT_SECONDS]); | |
| 293 | 303 |
| 294 capturer = nil; | 304 capturer = nil; |
| 295 videoSource = nil; | 305 videoSource = nil; |
| 296 pcOffer = nil; | 306 pcOffer = nil; |
| 297 pcAnswer = nil; | 307 pcAnswer = nil; |
| 298 // TODO(fischman): be stricter about shutdown checks; ensure thread | 308 // TODO(fischman): be stricter about shutdown checks; ensure thread |
| 299 // counts return to where they were before the test kicked off, and | 309 // counts return to where they were before the test kicked off, and |
| 300 // that all objects have in fact shut down. | 310 // that all objects have in fact shut down. |
| 301 } | 311 } |
| 302 | 312 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 316 // factory outlives RTCPeerConnection:dealloc. | 326 // factory outlives RTCPeerConnection:dealloc. |
| 317 // See https://code.google.com/p/webrtc/issues/detail?id=3100. | 327 // See https://code.google.com/p/webrtc/issues/detail?id=3100. |
| 318 RTCPeerConnectionFactory* factory = [[RTCPeerConnectionFactory alloc] init]; | 328 RTCPeerConnectionFactory* factory = [[RTCPeerConnectionFactory alloc] init]; |
| 319 @autoreleasepool { | 329 @autoreleasepool { |
| 320 RTCPeerConnectionTest* pcTest = [[RTCPeerConnectionTest alloc] init]; | 330 RTCPeerConnectionTest* pcTest = [[RTCPeerConnectionTest alloc] init]; |
| 321 [pcTest testCompleteSessionWithFactory:factory]; | 331 [pcTest testCompleteSessionWithFactory:factory]; |
| 322 } | 332 } |
| 323 rtc::CleanupSSL(); | 333 rtc::CleanupSSL(); |
| 324 } | 334 } |
| 325 } | 335 } |
| OLD | NEW |