Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: webrtc/api/objctests/RTCIceCandidateTest.mm

Issue 1517253005: Update API for Objective-C RTCIceCandidate. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@updateRTCIceServer
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
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 "webrtc/base/gunit.h"
14
15 #import "webrtc/api/objc/RTCIceCandidate.h"
16 #import "webrtc/api/objc/RTCIceCandidate+Private.h"
17 #import "webrtc/base/objc/NSString+StdString.h"
18
19 @interface RTCIceCandidateTest : NSObject
20 - (void)testCandidate;
21 - (void)testInitFromNativeCandidate;
22 @end
23
24 @implementation RTCIceCandidateTest
25
26 - (void)testCandidate {
27 NSString *sdp = @"candidate:4025901590 1 udp 2122265343 fdff:2642:12a6:fe38:c0 01:beda:fcf9:51aa 59052 typ host generation 0";
tkchin_webrtc 2015/12/15 01:55:44 80 chars. You can split it like so: @"foo" "bar
hjon 2015/12/15 17:35:44 Done.
28
29 RTCIceCandidate *candidate = [[RTCIceCandidate alloc] initWithSdpMid:@"audio"
30 sdpMLineIndex:0
31 sdp:sdp];
32
33 rtc::scoped_ptr<webrtc::IceCandidateInterface> nativeCandidate =
34 candidate.candidate;
35 EXPECT_EQ("audio", nativeCandidate->sdp_mid());
36 EXPECT_EQ(0, nativeCandidate->sdp_mline_index());
37
38 std::string sdpString;
39 nativeCandidate->ToString(&sdpString);
40 EXPECT_EQ(sdp.stdString, sdpString);
41 }
42
43 - (void)testInitFromNativeCandidate {
44 std::string sdp = "candidate:4025901590 1 udp 2122265343 fdff:2642:12a6:fe38:c 001:beda:fcf9:51aa 59052 typ host generation 0";
45 webrtc::IceCandidateInterface *nativeCandidate;
46
47 nativeCandidate = webrtc::CreateIceCandidate("audio", 0, sdp, nullptr);
48
49 RTCIceCandidate *iceCandidate = [[RTCIceCandidate alloc] initWithCandidate:
50 nativeCandidate];
51 EXPECT_TRUE([@"audio" isEqualToString:iceCandidate.sdpMid]);
52 EXPECT_EQ(0, iceCandidate.sdpMLineIndex);
53
54 EXPECT_EQ(sdp, iceCandidate.sdp.stdString);
55 }
56
57 @end
58
59 TEST(RTCIceCandidateTest, CandidateTest) {
60 @autoreleasepool {
61 RTCIceCandidateTest *test = [[RTCIceCandidateTest alloc] init];
62 [test testCandidate];
63 }
64 }
65
66 TEST(RTCIceCandidateTest, InitFromCandidateTest) {
67 @autoreleasepool {
68 RTCIceCandidateTest *test = [[RTCIceCandidateTest alloc] init];
69 [test testInitFromNativeCandidate];
70 }
71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698