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

Side by Side Diff: webrtc/p2p/base/session_unittest.cc

Issue 1350523003: TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing Mac test. Created 5 years, 3 months 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
« no previous file with comments | « webrtc/p2p/base/session.cc ('k') | webrtc/p2p/base/transport.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "webrtc/base/gunit.h"
12 #include "webrtc/base/helpers.h"
13 #include "webrtc/base/scoped_ptr.h"
14 #include "webrtc/base/thread.h"
15 #include "webrtc/p2p/base/dtlstransportchannel.h"
16 #include "webrtc/p2p/base/p2ptransportchannel.h"
17 #include "webrtc/p2p/base/portallocator.h"
18 #include "webrtc/p2p/base/session.h"
19 #include "webrtc/p2p/base/transportchannelproxy.h"
20 #include "webrtc/p2p/client/fakeportallocator.h"
21
22 using cricket::BaseSession;
23 using cricket::DtlsTransportChannelWrapper;
24 using cricket::FakePortAllocator;
25 using cricket::P2PTransportChannel;
26 using cricket::PortAllocator;
27 using cricket::TransportChannelProxy;
28 using cricket::TransportProxy;
29
30 class BaseSessionForTest : public BaseSession {
31 public:
32 BaseSessionForTest(rtc::Thread* signaling_thread,
33 rtc::Thread* worker_thread,
34 PortAllocator* port_allocator,
35 const std::string& sid,
36 const std::string& content_type,
37 bool initiator)
38 : BaseSession(signaling_thread,
39 worker_thread,
40 port_allocator,
41 sid,
42 content_type,
43 initiator) {}
44 using BaseSession::GetOrCreateTransportProxy;
45 };
46
47 class BaseSessionTest : public testing::Test {
48 public:
49 BaseSessionTest()
50 : port_allocator_(new FakePortAllocator(rtc::Thread::Current(), nullptr)),
51 session_(new BaseSessionForTest(rtc::Thread::Current(),
52 rtc::Thread::Current(),
53 port_allocator_.get(),
54 "123",
55 cricket::NS_JINGLE_RTP,
56 false)) {}
57 P2PTransportChannel* CreateChannel(const std::string& content,
58 int component) {
59 TransportProxy* transport_proxy =
60 session_->GetOrCreateTransportProxy(content);
61 // This hacking is needed in order that the p2p transport channel
62 // will be created in the following.
63 transport_proxy->CompleteNegotiation();
64
65 TransportChannelProxy* channel_proxy = static_cast<TransportChannelProxy*>(
66 session_->CreateChannel(content, component));
67 DtlsTransportChannelWrapper* dtls_channel =
68 static_cast<DtlsTransportChannelWrapper*>(channel_proxy->impl());
69 return static_cast<P2PTransportChannel*>(dtls_channel->channel());
70 }
71
72 rtc::scoped_ptr<PortAllocator> port_allocator_;
73 rtc::scoped_ptr<BaseSessionForTest> session_;
74 };
75
76 TEST_F(BaseSessionTest, TestSetIceReceivingTimeout) {
77 P2PTransportChannel* channel1 = CreateChannel("audio", 1);
78 ASSERT_NE(channel1, nullptr);
79 // These are the default values.
80 EXPECT_EQ(2500, channel1->receiving_timeout());
81 EXPECT_EQ(250, channel1->check_receiving_delay());
82 // Set the timeout to a different value.
83 session_->SetIceConnectionReceivingTimeout(1000);
84 EXPECT_EQ(1000, channel1->receiving_timeout());
85 EXPECT_EQ(100, channel1->check_receiving_delay());
86
87 // Even if a channel is created after setting the receiving timeout,
88 // the set timeout value is applied to the new channel.
89 P2PTransportChannel* channel2 = CreateChannel("video", 2);
90 ASSERT_NE(channel2, nullptr);
91 EXPECT_EQ(1000, channel2->receiving_timeout());
92 EXPECT_EQ(100, channel2->check_receiving_delay());
93
94 // Test minimum checking delay.
95 session_->SetIceConnectionReceivingTimeout(200);
96 EXPECT_EQ(200, channel1->receiving_timeout());
97 EXPECT_EQ(50, channel1->check_receiving_delay());
98 EXPECT_EQ(200, channel2->receiving_timeout());
99 EXPECT_EQ(50, channel2->check_receiving_delay());
100 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/session.cc ('k') | webrtc/p2p/base/transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698