OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string> |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" |
| 10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" |
| 11 #include "content/renderer/media/mock_media_stream_impl.h" |
| 12 #include "content/renderer/media/mock_web_peer_connection_handler_client.h" |
| 13 #include "content/renderer/media/mock_peer_connection_impl.h" |
| 14 #include "content/renderer/media/peer_connection_handler.h" |
| 15 #include "jingle/glue/thread_wrapper.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "third_party/libjingle/source/talk/app/webrtc/peerconnection.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamDescrip
tor.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamSource.
h" |
| 20 |
| 21 TEST(PeerConnectionHandlerTest, Basic) { |
| 22 MessageLoop loop; |
| 23 |
| 24 scoped_ptr<WebKit::MockWebPeerConnectionHandlerClient> mock_client( |
| 25 new WebKit::MockWebPeerConnectionHandlerClient()); |
| 26 scoped_refptr<MockMediaStreamImpl> mock_ms_impl(new MockMediaStreamImpl()); |
| 27 MockMediaStreamDependencyFactory* mock_dependency_factory = |
| 28 new MockMediaStreamDependencyFactory(); |
| 29 mock_dependency_factory->CreatePeerConnectionFactory(NULL, NULL, NULL); |
| 30 scoped_ptr<PeerConnectionHandler> pc_handler( |
| 31 new PeerConnectionHandler(mock_client.get(), |
| 32 mock_ms_impl.get(), |
| 33 mock_dependency_factory, |
| 34 NULL)); |
| 35 |
| 36 // TODO(grunell): Add tests for processSDP and processPendingStreams. |
| 37 // TODO(grunell): Add tests for PeerConnectionObserver implementation. |
| 38 |
| 39 WebKit::WebString server_config; |
| 40 WebKit::WebSecurityOrigin security_origin; |
| 41 pc_handler->initialize(server_config, security_origin); |
| 42 EXPECT_TRUE(pc_handler->native_peer_connection_.get()); |
| 43 webrtc::MockPeerConnectionImpl* mock_peer_connection = |
| 44 static_cast<webrtc::MockPeerConnectionImpl*>( |
| 45 pc_handler->native_peer_connection_.get()); |
| 46 EXPECT_EQ(mock_peer_connection->observer(), |
| 47 static_cast<webrtc::PeerConnectionObserver*>(pc_handler.get())); |
| 48 |
| 49 std::string label("label"); |
| 50 WebKit::WebVector<WebKit::WebMediaStreamSource> |
| 51 source_vector(static_cast<size_t>(1)); |
| 52 source_vector[0].initialize(WebKit::WebString::fromUTF8(""), |
| 53 WebKit::WebMediaStreamSource::TypeVideo, |
| 54 WebKit::WebString::fromUTF8(label)); |
| 55 WebKit::WebVector<WebKit::WebMediaStreamDescriptor> |
| 56 pendingAddStreams(static_cast<size_t>(1)); |
| 57 pendingAddStreams[0].initialize(UTF8ToUTF16(label), source_vector); |
| 58 pc_handler->produceInitialOffer(pendingAddStreams); |
| 59 EXPECT_EQ(mock_ms_impl->video_label(), label); |
| 60 EXPECT_EQ(mock_peer_connection->stream_id(), label); |
| 61 EXPECT_TRUE(mock_peer_connection->video_stream()); |
| 62 EXPECT_TRUE(mock_peer_connection->connected()); |
| 63 EXPECT_TRUE(mock_peer_connection->video_capture_set()); |
| 64 |
| 65 std::string message("message"); |
| 66 pc_handler->handleInitialOffer(WebKit::WebString::fromUTF8(message)); |
| 67 EXPECT_EQ(mock_peer_connection->signaling_message(), message); |
| 68 } |
OLD | NEW |