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

Unified Diff: webrtc/pc/webrtcsession_unittest.cc

Issue 2794943002: Delete MediaController class, move Call ownership to PeerConnection. (Closed)
Patch Set: Hack for injecting a FakeCall, and re-enable TestPacketOptionsAndOnPacketSent test. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« webrtc/pc/webrtcsession.h ('K') | « webrtc/pc/webrtcsession.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/pc/webrtcsession_unittest.cc
diff --git a/webrtc/pc/webrtcsession_unittest.cc b/webrtc/pc/webrtcsession_unittest.cc
index 757e14e0497fe23347176da952f8f842f91ef984..a610183b3c36dbd9d494dc703be99ad658f3d978 100644
--- a/webrtc/pc/webrtcsession_unittest.cc
+++ b/webrtc/pc/webrtcsession_unittest.cc
@@ -41,7 +41,6 @@
#include "webrtc/p2p/client/basicportallocator.h"
#include "webrtc/pc/audiotrack.h"
#include "webrtc/pc/channelmanager.h"
-#include "webrtc/pc/fakemediacontroller.h"
#include "webrtc/pc/mediasession.h"
#include "webrtc/pc/peerconnection.h"
#include "webrtc/pc/sctputils.h"
@@ -255,21 +254,25 @@ class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory {
class WebRtcSessionForTest : public webrtc::WebRtcSession {
public:
WebRtcSessionForTest(
- webrtc::MediaControllerInterface* media_controller,
+ cricket::ChannelManager* channel_manager,
+ const cricket::MediaConfig& media_config,
+ webrtc::RtcEventLog* event_log,
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
rtc::Thread* signaling_thread,
cricket::PortAllocator* port_allocator,
webrtc::IceObserver* ice_observer,
std::unique_ptr<cricket::TransportController> transport_controller,
- std::unique_ptr<FakeSctpTransportFactory> sctp_factory)
- : WebRtcSession(media_controller,
+ std::unique_ptr<FakeSctpTransportFactory> sctp_factory,
+ webrtc::Call*fake_call)
+ : WebRtcSession(channel_manager, media_config, event_log,
network_thread,
worker_thread,
signaling_thread,
port_allocator,
std::move(transport_controller),
- std::move(sctp_factory)) {
+ std::move(sctp_factory)),
+ fake_call_(fake_call) {
RegisterIceObserver(ice_observer);
}
virtual ~WebRtcSessionForTest() {}
@@ -293,6 +296,12 @@ class WebRtcSessionForTest : public webrtc::WebRtcSession {
}
private:
+ webrtc::Call* call() override {
+ if (fake_call_)
+ return fake_call_;
+ return WebRtcSession::call();
+ }
+
rtc::PacketTransportInternal* rtp_transport_channel(
cricket::BaseChannel* ch) {
if (!ch) {
@@ -308,6 +317,8 @@ class WebRtcSessionForTest : public webrtc::WebRtcSession {
}
return ch->rtcp_dtls_transport();
}
+
+ webrtc::Call* fake_call_ = nullptr;
};
class WebRtcSessionCreateSDPObserverForTest
@@ -375,11 +386,6 @@ class WebRtcSessionTest
std::unique_ptr<cricket::DataEngineInterface>(data_engine_),
rtc::Thread::Current())),
fake_call_(webrtc::Call::Config(&event_log_)),
- media_controller_(
- webrtc::MediaControllerInterface::Create(cricket::MediaConfig(),
- rtc::Thread::Current(),
- channel_manager_.get(),
- &event_log_)),
tdesc_factory_(new cricket::TransportDescriptionFactory()),
desc_factory_(
new cricket::MediaSessionDescriptionFactory(channel_manager_.get(),
@@ -421,11 +427,13 @@ class WebRtcSessionTest
void Init(
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy,
- const rtc::CryptoOptions& crypto_options) {
+ const rtc::CryptoOptions& crypto_options,
+ webrtc::Call* fake_call) {
ASSERT_TRUE(session_.get() == NULL);
fake_sctp_transport_factory_ = new FakeSctpTransportFactory();
session_.reset(new WebRtcSessionForTest(
- media_controller_.get(), rtc::Thread::Current(), rtc::Thread::Current(),
+ channel_manager_.get(), cricket::MediaConfig(), &event_log_,
+ rtc::Thread::Current(), rtc::Thread::Current(),
rtc::Thread::Current(), allocator_.get(), &observer_,
std::unique_ptr<cricket::TransportController>(
new cricket::TransportController(
@@ -433,7 +441,8 @@ class WebRtcSessionTest
allocator_.get(),
/*redetermine_role_on_ice_restart=*/true, crypto_options)),
std::unique_ptr<FakeSctpTransportFactory>(
- fake_sctp_transport_factory_)));
+ fake_sctp_transport_factory_),
+ fake_call));
session_->SignalDataChannelOpenMessage.connect(
this, &WebRtcSessionTest::OnDataChannelOpenMessage);
@@ -457,7 +466,12 @@ class WebRtcSessionTest
void Init() {
Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
- rtc::CryptoOptions());
+ rtc::CryptoOptions(), nullptr);
+ }
+
+ void InitWithFakeCall(webrtc::Call* fake_call) {
+ Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
+ rtc::CryptoOptions(), fake_call);
}
void InitWithBundlePolicy(
@@ -469,12 +483,12 @@ class WebRtcSessionTest
void InitWithRtcpMuxPolicy(
PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy) {
PeerConnectionInterface::RTCConfiguration configuration;
- Init(nullptr, rtcp_mux_policy, rtc::CryptoOptions());
+ Init(nullptr, rtcp_mux_policy, rtc::CryptoOptions(), nullptr);
}
void InitWithCryptoOptions(const rtc::CryptoOptions& crypto_options) {
Init(nullptr, PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
- crypto_options);
+ crypto_options, nullptr);
}
// Successfully init with DTLS; with a certificate generated and supplied or
@@ -492,7 +506,7 @@ class WebRtcSessionTest
}
Init(std::move(cert_generator),
PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
- rtc::CryptoOptions());
+ rtc::CryptoOptions(), nullptr);
}
// Init with DTLS with a store that will fail to generate a certificate.
@@ -502,7 +516,7 @@ class WebRtcSessionTest
cert_generator->set_should_fail(true);
Init(std::move(cert_generator),
PeerConnectionInterface::kRtcpMuxPolicyNegotiate,
- rtc::CryptoOptions());
+ rtc::CryptoOptions(), nullptr);
}
void InitWithGcm() {
@@ -1307,8 +1321,8 @@ class WebRtcSessionTest
// -> Failed.
// The Gathering state should go: New -> Gathering -> Completed.
- void SetupLoopbackCall() {
- Init();
+ void SetupLoopbackCall(webrtc::Call* fake_call = nullptr) {
+ InitWithFakeCall(fake_call);
SendAudioVideoStream1();
SessionDescriptionInterface* offer = CreateOffer();
@@ -1380,12 +1394,10 @@ class WebRtcSessionTest
}
void TestPacketOptions() {
- media_controller_.reset(
- new cricket::FakeMediaController(channel_manager_.get(), &fake_call_));
LoopbackNetworkConfiguration config;
LoopbackNetworkManager loopback_network_manager(this, config);
- SetupLoopbackCall();
+ SetupLoopbackCall(&fake_call_);
// Wait for channel to be ready for sending.
EXPECT_TRUE_WAIT(media_engine_->GetVideoChannel(0)->sending(), 100);
@@ -1515,7 +1527,6 @@ class WebRtcSessionTest
FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr;
std::unique_ptr<cricket::ChannelManager> channel_manager_;
cricket::FakeCall fake_call_;
- std::unique_ptr<webrtc::MediaControllerInterface> media_controller_;
std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_;
std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_;
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
« webrtc/pc/webrtcsession.h ('K') | « webrtc/pc/webrtcsession.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698