blob: 5fa43f84477edde9c2085cb6c2e6d030e7e267e7 [file] [log] [blame]
hjonaa32c3e2015-12-13 19:58:11 -08001/*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#import <Foundation/Foundation.h>
12
13#include <vector>
14
15#include "webrtc/base/gunit.h"
16
17#import "webrtc/api/objc/RTCIceServer.h"
18#import "webrtc/api/objc/RTCIceServer+Private.h"
19
20@interface RTCIceServerTest : NSObject
21- (void)testOneURLServer;
22- (void)testTwoURLServer;
23- (void)testPasswordCredential;
24@end
25
26@implementation RTCIceServerTest
27
28- (void)testOneURLServer {
29 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[
30 @"stun:stun1.example.net" ]];
31
32 webrtc::PeerConnectionInterface::IceServer iceStruct = server.iceServer;
33 EXPECT_EQ((size_t)1, iceStruct.urls.size());
34 EXPECT_EQ("stun:stun1.example.net", iceStruct.urls.front());
35 EXPECT_EQ("", iceStruct.username);
36 EXPECT_EQ("", iceStruct.password);
37}
38
39- (void)testTwoURLServer {
40 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[
41 @"turn1:turn1.example.net", @"turn2:turn2.example.net" ]];
42
43 webrtc::PeerConnectionInterface::IceServer iceStruct = server.iceServer;
44 EXPECT_EQ((size_t)2, iceStruct.urls.size());
45 EXPECT_EQ("turn1:turn1.example.net", iceStruct.urls.front());
46 EXPECT_EQ("turn2:turn2.example.net", iceStruct.urls.back());
47 EXPECT_EQ("", iceStruct.username);
48 EXPECT_EQ("", iceStruct.password);
49}
50
51- (void)testPasswordCredential {
52 RTCIceServer *server = [[RTCIceServer alloc]
53 initWithURLStrings:@[ @"turn1:turn1.example.net" ]
54 username:@"username"
55 credential:@"credential"];
56 webrtc::PeerConnectionInterface::IceServer iceStruct = server.iceServer;
57 EXPECT_EQ((size_t)1, iceStruct.urls.size());
58 EXPECT_EQ("turn1:turn1.example.net", iceStruct.urls.front());
59 EXPECT_EQ("username", iceStruct.username);
60 EXPECT_EQ("credential", iceStruct.password);
61}
62
63@end
64
65TEST(RTCIceServerTest, OneURLTest) {
66 @autoreleasepool {
67 RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
68 [test testOneURLServer];
69 }
70}
71
72TEST(RTCIceServerTest, TwoURLTest) {
73 @autoreleasepool {
74 RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
75 [test testTwoURLServer];
76 }
77}
78
79TEST(RTCIceServerTest, PasswordCredentialTest) {
80 @autoreleasepool {
81 RTCIceServerTest *test = [[RTCIceServerTest alloc] init];
82 [test testPasswordCredential];
83 }
84}