| Index: webrtc/p2p/base/transportcontroller_unittest.cc
|
| diff --git a/webrtc/p2p/base/session_unittest.cc b/webrtc/p2p/base/transportcontroller_unittest.cc
|
| similarity index 56%
|
| rename from webrtc/p2p/base/session_unittest.cc
|
| rename to webrtc/p2p/base/transportcontroller_unittest.cc
|
| index 3419cc3c468bbf47fe9c2b4cbd4db9ed814ee297..60f3386ad503b58a83c5bfda90a8d7195e34d8c6 100644
|
| --- a/webrtc/p2p/base/session_unittest.cc
|
| +++ b/webrtc/p2p/base/transportcontroller_unittest.cc
|
| @@ -15,72 +15,61 @@
|
| #include "webrtc/p2p/base/dtlstransportchannel.h"
|
| #include "webrtc/p2p/base/p2ptransportchannel.h"
|
| #include "webrtc/p2p/base/portallocator.h"
|
| -#include "webrtc/p2p/base/session.h"
|
| +#include "webrtc/p2p/base/transportcontroller.h"
|
| #include "webrtc/p2p/base/transportchannelproxy.h"
|
| #include "webrtc/p2p/client/fakeportallocator.h"
|
|
|
| -using cricket::BaseSession;
|
| +using cricket::TransportController;
|
| +using cricket::TransportChannel;
|
| using cricket::DtlsTransportChannelWrapper;
|
| using cricket::FakePortAllocator;
|
| using cricket::P2PTransportChannel;
|
| using cricket::PortAllocator;
|
| using cricket::TransportChannelProxy;
|
| -using cricket::TransportProxy;
|
|
|
| -class BaseSessionForTest : public BaseSession {
|
| +class TransportControllerForTest : public TransportController {
|
| public:
|
| - BaseSessionForTest(rtc::Thread* signaling_thread,
|
| - rtc::Thread* worker_thread,
|
| - PortAllocator* port_allocator,
|
| - const std::string& sid,
|
| - const std::string& content_type,
|
| - bool initiator)
|
| - : BaseSession(signaling_thread,
|
| - worker_thread,
|
| - port_allocator,
|
| - sid,
|
| - content_type,
|
| - initiator) {}
|
| - using BaseSession::GetOrCreateTransportProxy;
|
| + TransportControllerForTest(rtc::Thread* signaling_thread,
|
| + rtc::Thread* worker_thread,
|
| + PortAllocator* port_allocator,
|
| + bool initiator)
|
| + : TransportController(signaling_thread, worker_thread, port_allocator) {
|
| + SetIceRole(initiator ? cricket::ICEROLE_CONTROLLING
|
| + : cricket::ICEROLE_CONTROLLED);
|
| + }
|
| };
|
|
|
| -class BaseSessionTest : public testing::Test {
|
| +class TransportControllerTest : public testing::Test {
|
| public:
|
| - BaseSessionTest()
|
| + TransportControllerTest()
|
| : port_allocator_(new FakePortAllocator(rtc::Thread::Current(), nullptr)),
|
| - session_(new BaseSessionForTest(rtc::Thread::Current(),
|
| - rtc::Thread::Current(),
|
| - port_allocator_.get(),
|
| - "123",
|
| - cricket::NS_JINGLE_RTP,
|
| - false)) {}
|
| + transport_controller_(
|
| + new TransportControllerForTest(rtc::Thread::Current(),
|
| + rtc::Thread::Current(),
|
| + port_allocator_.get(),
|
| + false)) {}
|
| +
|
| P2PTransportChannel* CreateChannel(const std::string& content,
|
| int component) {
|
| - TransportProxy* transport_proxy =
|
| - session_->GetOrCreateTransportProxy(content);
|
| - // This hacking is needed in order that the p2p transport channel
|
| - // will be created in the following.
|
| - transport_proxy->CompleteNegotiation();
|
| -
|
| - TransportChannelProxy* channel_proxy = static_cast<TransportChannelProxy*>(
|
| - session_->CreateChannel(content, component));
|
| + TransportChannel* channel =
|
| + transport_controller_->CreateTransportChannel_w(content, component);
|
| DtlsTransportChannelWrapper* dtls_channel =
|
| - static_cast<DtlsTransportChannelWrapper*>(channel_proxy->impl());
|
| + static_cast<DtlsTransportChannelWrapper*>(channel);
|
| return static_cast<P2PTransportChannel*>(dtls_channel->channel());
|
| }
|
|
|
| rtc::scoped_ptr<PortAllocator> port_allocator_;
|
| - rtc::scoped_ptr<BaseSessionForTest> session_;
|
| + rtc::scoped_ptr<TransportControllerForTest> transport_controller_;
|
| };
|
|
|
| -TEST_F(BaseSessionTest, TestSetIceReceivingTimeout) {
|
| +TEST_F(TransportControllerTest, TestSetIceReceivingTimeout) {
|
| P2PTransportChannel* channel1 = CreateChannel("audio", 1);
|
| ASSERT_NE(channel1, nullptr);
|
| // These are the default values.
|
| EXPECT_EQ(2500, channel1->receiving_timeout());
|
| EXPECT_EQ(250, channel1->check_receiving_delay());
|
| // Set the timeout to a different value.
|
| - session_->SetIceConnectionReceivingTimeout(1000);
|
| + transport_controller_->SetIceConnectionReceivingTimeout(1000);
|
| EXPECT_EQ(1000, channel1->receiving_timeout());
|
| EXPECT_EQ(100, channel1->check_receiving_delay());
|
|
|
| @@ -92,7 +81,7 @@ TEST_F(BaseSessionTest, TestSetIceReceivingTimeout) {
|
| EXPECT_EQ(100, channel2->check_receiving_delay());
|
|
|
| // Test minimum checking delay.
|
| - session_->SetIceConnectionReceivingTimeout(200);
|
| + transport_controller_->SetIceConnectionReceivingTimeout(200);
|
| EXPECT_EQ(200, channel1->receiving_timeout());
|
| EXPECT_EQ(50, channel1->check_receiving_delay());
|
| EXPECT_EQ(200, channel2->receiving_timeout());
|
|
|