objc: fix rollback
and add a unit test BUG=webrtc:11796 Change-Id: I8e73b22f007c15c862faad7ca881d93c14a3a46f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/184160 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com> Cr-Commit-Position: refs/heads/master@{#32104}
This commit is contained in:
parent
6e046668d1
commit
daec488749
@ -31,7 +31,6 @@
|
||||
}
|
||||
|
||||
- (instancetype)initWithType:(RTCSdpType)type sdp:(NSString *)sdp {
|
||||
NSParameterAssert(sdp.length);
|
||||
if (self = [super init]) {
|
||||
_type = type;
|
||||
_sdp = [sdp copy];
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#import "api/peerconnection/RTCRtpReceiver.h"
|
||||
#import "api/peerconnection/RTCRtpSender.h"
|
||||
#import "api/peerconnection/RTCRtpTransceiver.h"
|
||||
#import "api/peerconnection/RTCSessionDescription.h"
|
||||
#import "api/peerconnection/RTCVideoSource.h"
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
@ -270,6 +271,56 @@
|
||||
XCTAssertTrue(true, "Expect test does not crash");
|
||||
}
|
||||
|
||||
- (void)testRollback {
|
||||
@autoreleasepool {
|
||||
RTC_OBJC_TYPE(RTCConfiguration) *config = [[RTC_OBJC_TYPE(RTCConfiguration) alloc] init];
|
||||
config.sdpSemantics = RTCSdpSemanticsUnifiedPlan;
|
||||
RTC_OBJC_TYPE(RTCMediaConstraints) *constraints =
|
||||
[[RTC_OBJC_TYPE(RTCMediaConstraints) alloc] initWithMandatoryConstraints:@{
|
||||
kRTCMediaConstraintsOfferToReceiveAudio : kRTCMediaConstraintsValueTrue
|
||||
}
|
||||
optionalConstraints:nil];
|
||||
|
||||
__block RTC_OBJC_TYPE(RTCPeerConnectionFactory) * factory;
|
||||
__block RTC_OBJC_TYPE(RTCPeerConnection) * pc1;
|
||||
RTCSessionDescription *rollback = [[RTCSessionDescription alloc] initWithType:RTCSdpTypeRollback
|
||||
sdp:@""];
|
||||
|
||||
@autoreleasepool {
|
||||
factory = [[RTC_OBJC_TYPE(RTCPeerConnectionFactory) alloc] init];
|
||||
pc1 = [factory peerConnectionWithConfiguration:config constraints:constraints delegate:nil];
|
||||
dispatch_semaphore_t negotiatedSem = dispatch_semaphore_create(0);
|
||||
[pc1 offerForConstraints:constraints
|
||||
completionHandler:^(RTC_OBJC_TYPE(RTCSessionDescription) * offer, NSError * error) {
|
||||
XCTAssertNil(error);
|
||||
XCTAssertNotNil(offer);
|
||||
|
||||
__weak RTC_OBJC_TYPE(RTCPeerConnection) *weakPC1 = pc1;
|
||||
[pc1 setLocalDescription:offer
|
||||
completionHandler:^(NSError *error) {
|
||||
XCTAssertNil(error);
|
||||
[weakPC1 setLocalDescription:rollback
|
||||
completionHandler:^(NSError *error) {
|
||||
XCTAssertNil(error);
|
||||
}];
|
||||
}];
|
||||
NSTimeInterval negotiationTimeout = 15;
|
||||
dispatch_semaphore_wait(
|
||||
negotiatedSem,
|
||||
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(negotiationTimeout * NSEC_PER_SEC)));
|
||||
|
||||
XCTAssertEqual(pc1.signalingState, RTCSignalingStateStable);
|
||||
|
||||
[pc1 close];
|
||||
pc1 = nil;
|
||||
factory = nil;
|
||||
}];
|
||||
}
|
||||
|
||||
XCTAssertTrue(true, "Expect test does not crash");
|
||||
}
|
||||
}
|
||||
|
||||
- (bool)negotiatePeerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)pc1
|
||||
withPeerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)pc2
|
||||
negotiationTimeout:(NSTimeInterval)timeout {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user