OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 #include <memory> |
| 12 |
11 #include "webrtc/api/datachannel.h" | 13 #include "webrtc/api/datachannel.h" |
12 #include "webrtc/api/sctputils.h" | 14 #include "webrtc/api/sctputils.h" |
13 #include "webrtc/api/test/fakedatachannelprovider.h" | 15 #include "webrtc/api/test/fakedatachannelprovider.h" |
14 #include "webrtc/base/gunit.h" | 16 #include "webrtc/base/gunit.h" |
15 | 17 |
16 using webrtc::DataChannel; | 18 using webrtc::DataChannel; |
17 using webrtc::SctpSidAllocator; | 19 using webrtc::SctpSidAllocator; |
18 | 20 |
19 class FakeDataChannelObserver : public webrtc::DataChannelObserver { | 21 class FakeDataChannelObserver : public webrtc::DataChannelObserver { |
20 public: | 22 public: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 provider_.set_ready_to_send(true); | 80 provider_.set_ready_to_send(true); |
79 } | 81 } |
80 | 82 |
81 void AddObserver() { | 83 void AddObserver() { |
82 observer_.reset(new FakeDataChannelObserver()); | 84 observer_.reset(new FakeDataChannelObserver()); |
83 webrtc_data_channel_->RegisterObserver(observer_.get()); | 85 webrtc_data_channel_->RegisterObserver(observer_.get()); |
84 } | 86 } |
85 | 87 |
86 webrtc::InternalDataChannelInit init_; | 88 webrtc::InternalDataChannelInit init_; |
87 FakeDataChannelProvider provider_; | 89 FakeDataChannelProvider provider_; |
88 rtc::scoped_ptr<FakeDataChannelObserver> observer_; | 90 std::unique_ptr<FakeDataChannelObserver> observer_; |
89 rtc::scoped_refptr<DataChannel> webrtc_data_channel_; | 91 rtc::scoped_refptr<DataChannel> webrtc_data_channel_; |
90 }; | 92 }; |
91 | 93 |
92 // Verifies that the data channel is connected to the transport after creation. | 94 // Verifies that the data channel is connected to the transport after creation. |
93 TEST_F(SctpDataChannelTest, ConnectedToTransportOnCreated) { | 95 TEST_F(SctpDataChannelTest, ConnectedToTransportOnCreated) { |
94 provider_.set_transport_available(true); | 96 provider_.set_transport_available(true); |
95 rtc::scoped_refptr<DataChannel> dc = DataChannel::Create( | 97 rtc::scoped_refptr<DataChannel> dc = DataChannel::Create( |
96 &provider_, cricket::DCT_SCTP, "test1", init_); | 98 &provider_, cricket::DCT_SCTP, "test1", init_); |
97 | 99 |
98 EXPECT_TRUE(provider_.IsConnected(dc.get())); | 100 EXPECT_TRUE(provider_.IsConnected(dc.get())); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); | 557 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); |
556 EXPECT_EQ(even_id, allocated_id); | 558 EXPECT_EQ(even_id, allocated_id); |
557 | 559 |
558 // Verifies that used higher ids are not reused. | 560 // Verifies that used higher ids are not reused. |
559 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_SERVER, &allocated_id)); | 561 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_SERVER, &allocated_id)); |
560 EXPECT_EQ(odd_id + 6, allocated_id); | 562 EXPECT_EQ(odd_id + 6, allocated_id); |
561 | 563 |
562 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); | 564 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); |
563 EXPECT_EQ(even_id + 6, allocated_id); | 565 EXPECT_EQ(even_id + 6, allocated_id); |
564 } | 566 } |
OLD | NEW |