xref: /aosp_15_r20/external/webrtc/sdk/objc/unittests/RTCDataChannelConfigurationTest.mm (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker/*
2*d9f75844SAndroid Build Coastguard Worker *  Copyright 2015 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker *
4*d9f75844SAndroid Build Coastguard Worker *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker */
10*d9f75844SAndroid Build Coastguard Worker
11*d9f75844SAndroid Build Coastguard Worker#import <Foundation/Foundation.h>
12*d9f75844SAndroid Build Coastguard Worker#import <XCTest/XCTest.h>
13*d9f75844SAndroid Build Coastguard Worker
14*d9f75844SAndroid Build Coastguard Worker#include "rtc_base/gunit.h"
15*d9f75844SAndroid Build Coastguard Worker
16*d9f75844SAndroid Build Coastguard Worker#import "api/peerconnection/RTCDataChannelConfiguration+Private.h"
17*d9f75844SAndroid Build Coastguard Worker#import "api/peerconnection/RTCDataChannelConfiguration.h"
18*d9f75844SAndroid Build Coastguard Worker#import "helpers/NSString+StdString.h"
19*d9f75844SAndroid Build Coastguard Worker
20*d9f75844SAndroid Build Coastguard Worker@interface RTCDataChannelConfigurationTest : XCTestCase
21*d9f75844SAndroid Build Coastguard Worker@end
22*d9f75844SAndroid Build Coastguard Worker
23*d9f75844SAndroid Build Coastguard Worker@implementation RTCDataChannelConfigurationTest
24*d9f75844SAndroid Build Coastguard Worker
25*d9f75844SAndroid Build Coastguard Worker- (void)testConversionToNativeDataChannelInit {
26*d9f75844SAndroid Build Coastguard Worker  BOOL isOrdered = NO;
27*d9f75844SAndroid Build Coastguard Worker  int maxPacketLifeTime = 5;
28*d9f75844SAndroid Build Coastguard Worker  int maxRetransmits = 4;
29*d9f75844SAndroid Build Coastguard Worker  BOOL isNegotiated = YES;
30*d9f75844SAndroid Build Coastguard Worker  int channelId = 4;
31*d9f75844SAndroid Build Coastguard Worker  NSString *protocol = @"protocol";
32*d9f75844SAndroid Build Coastguard Worker
33*d9f75844SAndroid Build Coastguard Worker  RTC_OBJC_TYPE(RTCDataChannelConfiguration) *dataChannelConfig =
34*d9f75844SAndroid Build Coastguard Worker      [[RTC_OBJC_TYPE(RTCDataChannelConfiguration) alloc] init];
35*d9f75844SAndroid Build Coastguard Worker  dataChannelConfig.isOrdered = isOrdered;
36*d9f75844SAndroid Build Coastguard Worker  dataChannelConfig.maxPacketLifeTime = maxPacketLifeTime;
37*d9f75844SAndroid Build Coastguard Worker  dataChannelConfig.maxRetransmits = maxRetransmits;
38*d9f75844SAndroid Build Coastguard Worker  dataChannelConfig.isNegotiated = isNegotiated;
39*d9f75844SAndroid Build Coastguard Worker  dataChannelConfig.channelId = channelId;
40*d9f75844SAndroid Build Coastguard Worker  dataChannelConfig.protocol = protocol;
41*d9f75844SAndroid Build Coastguard Worker
42*d9f75844SAndroid Build Coastguard Worker  webrtc::DataChannelInit nativeInit = dataChannelConfig.nativeDataChannelInit;
43*d9f75844SAndroid Build Coastguard Worker  EXPECT_EQ(isOrdered, nativeInit.ordered);
44*d9f75844SAndroid Build Coastguard Worker  EXPECT_EQ(maxPacketLifeTime, nativeInit.maxRetransmitTime);
45*d9f75844SAndroid Build Coastguard Worker  EXPECT_EQ(maxRetransmits, nativeInit.maxRetransmits);
46*d9f75844SAndroid Build Coastguard Worker  EXPECT_EQ(isNegotiated, nativeInit.negotiated);
47*d9f75844SAndroid Build Coastguard Worker  EXPECT_EQ(channelId, nativeInit.id);
48*d9f75844SAndroid Build Coastguard Worker  EXPECT_EQ(protocol.stdString, nativeInit.protocol);
49*d9f75844SAndroid Build Coastguard Worker}
50*d9f75844SAndroid Build Coastguard Worker
51*d9f75844SAndroid Build Coastguard Worker@end
52