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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 - (void)expectStateChange:(RTCDataChannelState)state { | 132 - (void)expectStateChange:(RTCDataChannelState)state { |
| 133 [_expectedStateChanges addObject:@(state)]; | 133 [_expectedStateChanges addObject:@(state)]; |
| 134 } | 134 } |
| 135 | 135 |
| 136 - (void)expectMessage:(NSData*)message isBinary:(BOOL)isBinary { | 136 - (void)expectMessage:(NSData*)message isBinary:(BOOL)isBinary { |
| 137 RTCDataBuffer* buffer = [[RTCDataBuffer alloc] initWithData:message | 137 RTCDataBuffer* buffer = [[RTCDataBuffer alloc] initWithData:message |
| 138 isBinary:isBinary]; | 138 isBinary:isBinary]; |
| 139 [_expectedMessages addObject:buffer]; | 139 [_expectedMessages addObject:buffer]; |
| 140 } | 140 } |
| 141 | 141 |
| 142 - (void)waitForAllExpectationsToBeSatisfied { | 142 - (BOOL)waitForAllExpectationsToBeSatisfiedWithTimeout:(NSTimeInterval)timeout { |
|
tkchin_webrtc
2015/09/25 19:51:04
might want to NSParameterAssert(timeout >= 0); or
| |
| 143 // TODO (fischman): Revisit. Keeping in sync with the Java version, but | 143 // TODO (fischman): Revisit. Keeping in sync with the Java version, but |
| 144 // polling is not optimal. | 144 // polling is not optimal. |
| 145 // https://code.google.com/p/libjingle/source/browse/trunk/talk/app/webrtc/jav atests/src/org/webrtc/PeerConnectionTest.java?line=212#212 | 145 // https://code.google.com/p/libjingle/source/browse/trunk/talk/app/webrtc/jav atests/src/org/webrtc/PeerConnectionTest.java?line=212#212 |
| 146 NSDate *endTime = [NSDate dateWithTimeIntervalSinceNow:timeout]; | |
|
tkchin_webrtc
2015/09/25 19:51:04
nit: dot syntax for properties.
Also, consider usi
| |
| 146 while (![self areAllExpectationsSatisfied]) { | 147 while (![self areAllExpectationsSatisfied]) { |
| 148 if ([endTime timeIntervalSinceNow] < 0) { | |
| 149 return NO; | |
| 150 } | |
| 147 [[NSRunLoop currentRunLoop] | 151 [[NSRunLoop currentRunLoop] |
| 148 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; | 152 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; |
| 149 } | 153 } |
| 154 return YES; | |
| 150 } | 155 } |
| 151 | 156 |
| 152 #pragma mark - RTCPeerConnectionDelegate methods | 157 #pragma mark - RTCPeerConnectionDelegate methods |
| 153 | 158 |
| 154 - (void)peerConnection:(RTCPeerConnection*)peerConnection | 159 - (void)peerConnection:(RTCPeerConnection*)peerConnection |
| 155 signalingStateChanged:(RTCSignalingState)stateChanged { | 160 signalingStateChanged:(RTCSignalingState)stateChanged { |
| 156 int expectedState = [self popFirstElementAsInt:_expectedSignalingChanges]; | 161 int expectedState = [self popFirstElementAsInt:_expectedSignalingChanges]; |
| 157 NSString* message = | 162 NSString* message = |
| 158 [NSString stringWithFormat:@"RTCPeerConnectionDelegate::" | 163 [NSString stringWithFormat:@"RTCPeerConnectionDelegate::" |
| 159 @"onSignalingStateChange [%d] expected[%d]", | 164 @"onSignalingStateChange [%d] expected[%d]", |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 @"Unexpected message received"); | 247 @"Unexpected message received"); |
| 243 RTCDataBuffer* expectedBuffer = [_expectedMessages objectAtIndex:0]; | 248 RTCDataBuffer* expectedBuffer = [_expectedMessages objectAtIndex:0]; |
| 244 NSAssert(expectedBuffer.isBinary == buffer.isBinary, | 249 NSAssert(expectedBuffer.isBinary == buffer.isBinary, |
| 245 @"Buffer isBinary should match"); | 250 @"Buffer isBinary should match"); |
| 246 NSAssert([expectedBuffer.data isEqual:buffer.data], | 251 NSAssert([expectedBuffer.data isEqual:buffer.data], |
| 247 @"Buffer data should match"); | 252 @"Buffer data should match"); |
| 248 [_expectedMessages removeObjectAtIndex:0]; | 253 [_expectedMessages removeObjectAtIndex:0]; |
| 249 } | 254 } |
| 250 | 255 |
| 251 @end | 256 @end |
| OLD | NEW |