Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: talk/app/webrtc/objctests/RTCPeerConnectionSyncObserver.m

Issue 1361213002: Adding 20-second timeout to Java and Objective-C tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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:(int)timeoutSeconds {
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:timeoutSeconds];
tkchin_webrtc 2015/09/25 15:40:32 Since you are using NSDate API, use NSTimeInterval
Taylor Brandstetter 2015/09/25 18:01:57 Done.
146 while (![self areAllExpectationsSatisfied]) { 147 while (![self areAllExpectationsSatisfied]) {
148 if ([endTime compare:[NSDate date]] != NSOrderedDescending) {
tkchin_webrtc 2015/09/25 15:40:32 I think it's easier/clearer to use a comparison wi
Taylor Brandstetter 2015/09/25 18:01:57 Done.
149 return false;
tkchin_webrtc 2015/09/25 15:40:32 return NO;
Taylor Brandstetter 2015/09/25 18:01:57 Done.
150 }
147 [[NSRunLoop currentRunLoop] 151 [[NSRunLoop currentRunLoop]
148 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; 152 runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
149 } 153 }
154 return true;
tkchin_webrtc 2015/09/25 15:40:32 return YES;
Taylor Brandstetter 2015/09/25 18:01:57 Done.
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698