OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import <Foundation/Foundation.h> | 11 #import <Foundation/Foundation.h> |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "webrtc/base/gunit.h" | 15 #include "webrtc/base/gunit.h" |
16 | 16 |
17 #import "webrtc/api/objc/RTCIceServer.h" | 17 #import "webrtc/api/objc/RTCIceServer.h" |
18 #import "webrtc/api/objc/RTCIceServer+Private.h" | 18 #import "webrtc/api/objc/RTCIceServer+Private.h" |
| 19 #import "webrtc/base/objc/NSString+StdString.h" |
19 | 20 |
20 @interface RTCIceServerTest : NSObject | 21 @interface RTCIceServerTest : NSObject |
21 - (void)testOneURLServer; | 22 - (void)testOneURLServer; |
22 - (void)testTwoURLServer; | 23 - (void)testTwoURLServer; |
23 - (void)testPasswordCredential; | 24 - (void)testPasswordCredential; |
| 25 - (void)testInitFromNativeServer; |
24 @end | 26 @end |
25 | 27 |
26 @implementation RTCIceServerTest | 28 @implementation RTCIceServerTest |
27 | 29 |
28 - (void)testOneURLServer { | 30 - (void)testOneURLServer { |
29 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[ | 31 RTCIceServer *server = [[RTCIceServer alloc] initWithURLStrings:@[ |
30 @"stun:stun1.example.net" ]]; | 32 @"stun:stun1.example.net" ]]; |
31 | 33 |
32 webrtc::PeerConnectionInterface::IceServer iceStruct = server.iceServer; | 34 webrtc::PeerConnectionInterface::IceServer iceStruct = server.iceServer; |
33 EXPECT_EQ((size_t)1, iceStruct.urls.size()); | 35 EXPECT_EQ((size_t)1, iceStruct.urls.size()); |
(...skipping 19 matching lines...) Expand all Loading... |
53 initWithURLStrings:@[ @"turn1:turn1.example.net" ] | 55 initWithURLStrings:@[ @"turn1:turn1.example.net" ] |
54 username:@"username" | 56 username:@"username" |
55 credential:@"credential"]; | 57 credential:@"credential"]; |
56 webrtc::PeerConnectionInterface::IceServer iceStruct = server.iceServer; | 58 webrtc::PeerConnectionInterface::IceServer iceStruct = server.iceServer; |
57 EXPECT_EQ((size_t)1, iceStruct.urls.size()); | 59 EXPECT_EQ((size_t)1, iceStruct.urls.size()); |
58 EXPECT_EQ("turn1:turn1.example.net", iceStruct.urls.front()); | 60 EXPECT_EQ("turn1:turn1.example.net", iceStruct.urls.front()); |
59 EXPECT_EQ("username", iceStruct.username); | 61 EXPECT_EQ("username", iceStruct.username); |
60 EXPECT_EQ("credential", iceStruct.password); | 62 EXPECT_EQ("credential", iceStruct.password); |
61 } | 63 } |
62 | 64 |
| 65 - (void)testInitFromNativeServer { |
| 66 webrtc::PeerConnectionInterface::IceServer nativeServer; |
| 67 nativeServer.username = "username"; |
| 68 nativeServer.password = "password"; |
| 69 nativeServer.urls.push_back("stun:stun.example.net"); |
| 70 |
| 71 RTCIceServer *iceServer = |
| 72 [[RTCIceServer alloc] initWithNativeServer:nativeServer]; |
| 73 EXPECT_EQ((size_t)1, iceServer.urlStrings.count); |
| 74 EXPECT_EQ("stun:stun.example.net", |
| 75 [NSString stdStringForString:iceServer.urlStrings.firstObject]); |
| 76 EXPECT_EQ("username", [NSString stdStringForString:iceServer.username]); |
| 77 EXPECT_EQ("password", [NSString stdStringForString:iceServer.credential]); |
| 78 } |
| 79 |
63 @end | 80 @end |
64 | 81 |
65 TEST(RTCIceServerTest, OneURLTest) { | 82 TEST(RTCIceServerTest, OneURLTest) { |
66 @autoreleasepool { | 83 @autoreleasepool { |
67 RTCIceServerTest *test = [[RTCIceServerTest alloc] init]; | 84 RTCIceServerTest *test = [[RTCIceServerTest alloc] init]; |
68 [test testOneURLServer]; | 85 [test testOneURLServer]; |
69 } | 86 } |
70 } | 87 } |
71 | 88 |
72 TEST(RTCIceServerTest, TwoURLTest) { | 89 TEST(RTCIceServerTest, TwoURLTest) { |
73 @autoreleasepool { | 90 @autoreleasepool { |
74 RTCIceServerTest *test = [[RTCIceServerTest alloc] init]; | 91 RTCIceServerTest *test = [[RTCIceServerTest alloc] init]; |
75 [test testTwoURLServer]; | 92 [test testTwoURLServer]; |
76 } | 93 } |
77 } | 94 } |
78 | 95 |
79 TEST(RTCIceServerTest, PasswordCredentialTest) { | 96 TEST(RTCIceServerTest, PasswordCredentialTest) { |
80 @autoreleasepool { | 97 @autoreleasepool { |
81 RTCIceServerTest *test = [[RTCIceServerTest alloc] init]; | 98 RTCIceServerTest *test = [[RTCIceServerTest alloc] init]; |
82 [test testPasswordCredential]; | 99 [test testPasswordCredential]; |
83 } | 100 } |
84 } | 101 } |
| 102 |
| 103 TEST(RTCIceServerTest, InitFromNativeServerTest) { |
| 104 @autoreleasepool { |
| 105 RTCIceServerTest *test = [[RTCIceServerTest alloc] init]; |
| 106 [test testInitFromNativeServer]; |
| 107 } |
| 108 } |
OLD | NEW |