mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-17 23:57:59 +01:00

Bug: webrtc:9231 Change-Id: I3b90400bf619938817d7a04a7a1130ba86ad65df Reviewed-on: https://webrtc-review.googlesource.com/87623 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23896}
150 lines
4.7 KiB
Objective-C
150 lines
4.7 KiB
Objective-C
/*
|
|
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#import <WebRTC/RTCConfiguration.h>
|
|
#import <WebRTC/RTCDataChannel.h>
|
|
#import <WebRTC/RTCDataChannelConfiguration.h>
|
|
#import <WebRTC/RTCMediaConstraints.h>
|
|
#import <WebRTC/RTCMediaStreamTrack.h>
|
|
#import <WebRTC/RTCPeerConnection.h>
|
|
#import <WebRTC/RTCPeerConnectionFactory.h>
|
|
#import <WebRTC/RTCRtpSender.h>
|
|
#import <WebRTC/RTCRtpTransceiver.h>
|
|
|
|
#import <XCTest/XCTest.h>
|
|
|
|
@interface RTCPeerConnectionFactoryTests : XCTestCase
|
|
- (void)testPeerConnectionLifetime;
|
|
@end
|
|
|
|
@implementation RTCPeerConnectionFactoryTests
|
|
|
|
- (void)testPeerConnectionLifetime {
|
|
@autoreleasepool {
|
|
RTCConfiguration *config = [[RTCConfiguration alloc] init];
|
|
|
|
RTCMediaConstraints *contraints =
|
|
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{} optionalConstraints:nil];
|
|
|
|
RTCPeerConnectionFactory *factory;
|
|
RTCPeerConnection *peerConnection;
|
|
|
|
@autoreleasepool {
|
|
factory = [[RTCPeerConnectionFactory alloc] init];
|
|
peerConnection =
|
|
[factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
|
|
[peerConnection close];
|
|
factory = nil;
|
|
}
|
|
peerConnection = nil;
|
|
}
|
|
|
|
XCTAssertTrue(true, @"Expect test does not crash");
|
|
}
|
|
|
|
- (void)testMediaStreamLifetime {
|
|
@autoreleasepool {
|
|
RTCPeerConnectionFactory *factory;
|
|
RTCMediaStream *mediaStream;
|
|
|
|
@autoreleasepool {
|
|
factory = [[RTCPeerConnectionFactory alloc] init];
|
|
mediaStream = [factory mediaStreamWithStreamId:@"mediaStream"];
|
|
factory = nil;
|
|
}
|
|
mediaStream = nil;
|
|
}
|
|
|
|
XCTAssertTrue(true, "Expect test does not crash");
|
|
}
|
|
|
|
- (void)testDataChannelLifetime {
|
|
@autoreleasepool {
|
|
RTCConfiguration *config = [[RTCConfiguration alloc] init];
|
|
RTCMediaConstraints *contraints =
|
|
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{} optionalConstraints:nil];
|
|
RTCDataChannelConfiguration *dataChannelConfig = [[RTCDataChannelConfiguration alloc] init];
|
|
|
|
RTCPeerConnectionFactory *factory;
|
|
RTCPeerConnection *peerConnection;
|
|
RTCDataChannel *dataChannel;
|
|
|
|
@autoreleasepool {
|
|
factory = [[RTCPeerConnectionFactory alloc] init];
|
|
peerConnection =
|
|
[factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
|
|
dataChannel =
|
|
[peerConnection dataChannelForLabel:@"test_channel" configuration:dataChannelConfig];
|
|
XCTAssertTrue(dataChannel != nil);
|
|
[peerConnection close];
|
|
peerConnection = nil;
|
|
factory = nil;
|
|
}
|
|
dataChannel = nil;
|
|
}
|
|
|
|
XCTAssertTrue(true, "Expect test does not crash");
|
|
}
|
|
|
|
- (void)testRTCRtpTransceiverLifetime {
|
|
@autoreleasepool {
|
|
RTCConfiguration *config = [[RTCConfiguration alloc] init];
|
|
config.sdpSemantics = RTCSdpSemanticsUnifiedPlan;
|
|
RTCMediaConstraints *contraints =
|
|
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{} optionalConstraints:nil];
|
|
RTCRtpTransceiverInit *init = [[RTCRtpTransceiverInit alloc] init];
|
|
|
|
RTCPeerConnectionFactory *factory;
|
|
RTCPeerConnection *peerConnection;
|
|
RTCRtpTransceiver *tranceiver;
|
|
|
|
@autoreleasepool {
|
|
factory = [[RTCPeerConnectionFactory alloc] init];
|
|
peerConnection =
|
|
[factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
|
|
tranceiver = [peerConnection addTransceiverOfType:RTCRtpMediaTypeAudio init:init];
|
|
XCTAssertTrue(tranceiver != nil);
|
|
[peerConnection close];
|
|
peerConnection = nil;
|
|
factory = nil;
|
|
}
|
|
tranceiver = nil;
|
|
}
|
|
|
|
XCTAssertTrue(true, "Expect test does not crash");
|
|
}
|
|
|
|
- (void)testRTCRtpSenderLifetime {
|
|
@autoreleasepool {
|
|
RTCConfiguration *config = [[RTCConfiguration alloc] init];
|
|
RTCMediaConstraints *contraints =
|
|
[[RTCMediaConstraints alloc] initWithMandatoryConstraints:@{} optionalConstraints:nil];
|
|
|
|
RTCPeerConnectionFactory *factory;
|
|
RTCPeerConnection *peerConnection;
|
|
RTCRtpSender *sender;
|
|
|
|
@autoreleasepool {
|
|
factory = [[RTCPeerConnectionFactory alloc] init];
|
|
peerConnection =
|
|
[factory peerConnectionWithConfiguration:config constraints:contraints delegate:nil];
|
|
sender = [peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo streamId:@"stream"];
|
|
XCTAssertTrue(sender != nil);
|
|
[peerConnection close];
|
|
peerConnection = nil;
|
|
factory = nil;
|
|
}
|
|
sender = nil;
|
|
}
|
|
|
|
XCTAssertTrue(true, "Expect test does not crash");
|
|
}
|
|
|
|
@end
|