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

Unified Diff: content/renderer/media/peer_connection_handler_unittest.cc

Issue 9284020: Enabling usage of native PeerConnection v2 in libjingle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 11 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
« no previous file with comments | « content/renderer/media/peer_connection_handler.cc ('k') | third_party/libjingle/libjingle.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/peer_connection_handler_unittest.cc
diff --git a/content/renderer/media/peer_connection_handler_unittest.cc b/content/renderer/media/peer_connection_handler_unittest.cc
index 766db5d60982712533900d8c6fa061fa0ae6bf2f..8cb4076947bfbbc63048e03bc64652d6614081c3 100644
--- a/content/renderer/media/peer_connection_handler_unittest.cc
+++ b/content/renderer/media/peer_connection_handler_unittest.cc
@@ -15,10 +15,22 @@
#include "content/renderer/media/rtc_video_decoder.h"
#include "jingle/glue/thread_wrapper.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/libjingle/source/talk/app/webrtcv1/peerconnection.h"
+#include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamDescriptor.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStreamSource.h"
+namespace webrtc {
+
+class MockVideoRendererWrapper : public VideoRendererWrapperInterface {
+ public:
+ virtual cricket::VideoRenderer* renderer() OVERRIDE { return NULL; }
+
+ protected:
+ virtual ~MockVideoRendererWrapper() {}
+};
+
+} // namespace webrtc
+
TEST(PeerConnectionHandlerTest, Basic) {
MessageLoop loop;
@@ -27,15 +39,15 @@ TEST(PeerConnectionHandlerTest, Basic) {
scoped_refptr<MockMediaStreamImpl> mock_ms_impl(new MockMediaStreamImpl());
scoped_ptr<MockMediaStreamDependencyFactory> mock_dependency_factory(
new MockMediaStreamDependencyFactory());
- mock_dependency_factory->CreatePeerConnectionFactory(NULL, NULL);
+ mock_dependency_factory->CreatePeerConnectionFactory(NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
scoped_ptr<PeerConnectionHandler> pc_handler(
new PeerConnectionHandler(mock_client.get(),
mock_ms_impl.get(),
- mock_dependency_factory.get(),
- NULL,
- NULL,
- NULL,
- NULL));
+ mock_dependency_factory.get()));
WebKit::WebString server_config(
WebKit::WebString::fromUTF8("STUN stun.l.google.com:19302"));
@@ -45,24 +57,24 @@ TEST(PeerConnectionHandlerTest, Basic) {
webrtc::MockPeerConnectionImpl* mock_peer_connection =
static_cast<webrtc::MockPeerConnectionImpl*>(
pc_handler->native_peer_connection_.get());
- EXPECT_EQ(static_cast<webrtc::PeerConnectionObserver*>(pc_handler.get()),
- mock_peer_connection->observer());
- std::string label("label");
+ // TODO(grunell): Add an audio track as well.
+ std::string stream_label("stream-label");
+ std::string video_track_label("video-label");
+ talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> local_video_track(
+ mock_dependency_factory->CreateLocalVideoTrack(video_track_label, NULL));
+ mock_ms_impl->AddTrack(video_track_label, local_video_track);
WebKit::WebVector<WebKit::WebMediaStreamSource> source_vector(
static_cast<size_t>(1));
- source_vector[0].initialize(WebKit::WebString::fromUTF8(label),
+ source_vector[0].initialize(WebKit::WebString::fromUTF8(video_track_label),
WebKit::WebMediaStreamSource::TypeVideo,
WebKit::WebString::fromUTF8("RemoteVideo"));
- WebKit::WebVector<WebKit::WebMediaStreamDescriptor> pendingAddStreams(
+ WebKit::WebVector<WebKit::WebMediaStreamDescriptor> local_streams(
static_cast<size_t>(1));
- pendingAddStreams[0].initialize(UTF8ToUTF16(label), source_vector);
- pc_handler->produceInitialOffer(pendingAddStreams);
- EXPECT_EQ(label, mock_ms_impl->video_label());
- EXPECT_EQ(label, mock_peer_connection->stream_id());
- EXPECT_TRUE(mock_peer_connection->video_stream());
- EXPECT_TRUE(mock_peer_connection->connected());
- EXPECT_TRUE(mock_peer_connection->video_capture_set());
+ local_streams[0].initialize(UTF8ToUTF16(stream_label), source_vector);
+ pc_handler->produceInitialOffer(local_streams);
+ EXPECT_EQ(stream_label, mock_peer_connection->stream_label());
+ EXPECT_TRUE(mock_peer_connection->stream_changes_committed());
std::string message("message1");
pc_handler->handleInitialOffer(WebKit::WebString::fromUTF8(message));
@@ -76,49 +88,47 @@ TEST(PeerConnectionHandlerTest, Basic) {
pc_handler->OnSignalingMessage(message);
EXPECT_EQ(message, mock_client->sdp());
- std::string remote_label(label);
- remote_label.append("-remote");
- pc_handler->OnAddStream(remote_label, true);
- EXPECT_EQ(remote_label, mock_client->stream_label());
-
- scoped_refptr<RTCVideoDecoder> rtc_video_decoder(
- new RTCVideoDecoder(&loop, ""));
- pc_handler->SetVideoRenderer(label, rtc_video_decoder.get());
- EXPECT_EQ(label, mock_peer_connection->video_renderer_stream_id());
+ std::string remote_stream_label(stream_label);
+ remote_stream_label += "-remote";
+ std::string remote_video_track_label(video_track_label);
+ remote_video_track_label += "-remote";
+ // We use a local stream as a remote since for testing purposes we really
+ // only need the MediaStreamInterface.
+ talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> remote_stream(
+ mock_dependency_factory->CreateLocalMediaStream(remote_stream_label));
+ talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> remote_video_track(
+ mock_dependency_factory->CreateLocalVideoTrack(remote_video_track_label,
+ NULL));
+ remote_video_track->set_enabled(true);
+ remote_stream->AddTrack(remote_video_track);
+ mock_peer_connection->AddRemoteStream(remote_stream);
+ pc_handler->OnAddStream(remote_stream);
+ EXPECT_EQ(remote_stream_label, mock_client->stream_label());
+
+ talk_base::scoped_refptr<webrtc::MockVideoRendererWrapper> renderer(
+ new talk_base::RefCountedObject<webrtc::MockVideoRendererWrapper>());
+ pc_handler->SetVideoRenderer(remote_stream_label, renderer);
+ EXPECT_EQ(renderer, static_cast<webrtc::MockLocalVideoTrack*>(
+ remote_video_track.get())->renderer());
+
+ WebKit::WebVector<WebKit::WebMediaStreamDescriptor> empty_streams(
+ static_cast<size_t>(0));
+ pc_handler->processPendingStreams(empty_streams, local_streams);
+ EXPECT_EQ("", mock_peer_connection->stream_label());
+ mock_peer_connection->ClearStreamChangesCommitted();
+ EXPECT_TRUE(!mock_peer_connection->stream_changes_committed());
- pc_handler->OnRemoveStream(remote_label, true);
+ pc_handler->OnRemoveStream(remote_stream);
EXPECT_TRUE(mock_client->stream_label().empty());
+ pc_handler->processPendingStreams(local_streams, empty_streams);
+ EXPECT_EQ(stream_label, mock_peer_connection->stream_label());
+ EXPECT_TRUE(mock_peer_connection->stream_changes_committed());
+
pc_handler->stop();
EXPECT_FALSE(pc_handler->native_peer_connection_.get());
// PC handler is expected to be deleted when stop calls
// MediaStreamImpl::ClosePeerConnection. We own and delete it here instead of
// in the mock.
pc_handler.reset();
-
- // processPendingStreams must be tested on a new PC handler since removing
- // streams is currently not supported.
- pc_handler.reset(new PeerConnectionHandler(mock_client.get(),
- mock_ms_impl.get(),
- mock_dependency_factory.get(),
- NULL,
- NULL,
- NULL,
- NULL));
- pc_handler->initialize(server_config, security_origin);
- EXPECT_TRUE(pc_handler->native_peer_connection_.get());
- mock_peer_connection = static_cast<webrtc::MockPeerConnectionImpl*>(
- pc_handler->native_peer_connection_.get());
-
- WebKit::WebVector<WebKit::WebMediaStreamDescriptor> pendingRemoveStreams(
- static_cast<size_t>(0));
- pc_handler->processPendingStreams(pendingAddStreams, pendingRemoveStreams);
- EXPECT_EQ(label, mock_ms_impl->video_label());
- EXPECT_EQ(label, mock_peer_connection->stream_id());
- EXPECT_TRUE(mock_peer_connection->video_stream());
- EXPECT_TRUE(mock_peer_connection->connected());
- EXPECT_TRUE(mock_peer_connection->video_capture_set());
-
- pc_handler->stop();
- pc_handler.reset();
}
« no previous file with comments | « content/renderer/media/peer_connection_handler.cc ('k') | third_party/libjingle/libjingle.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698