| Index: content/renderer/media/media_stream_impl_unittest.cc
|
| diff --git a/content/renderer/media/media_stream_impl_unittest.cc b/content/renderer/media/media_stream_impl_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..566b22c818b6a5dea9cf94af1adeb050a56fe6c8
|
| --- /dev/null
|
| +++ b/content/renderer/media/media_stream_impl_unittest.cc
|
| @@ -0,0 +1,73 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/message_loop.h"
|
| +#include "base/utf_string_conversions.h"
|
| +#include "content/renderer/media/media_stream_impl.h"
|
| +#include "content/renderer/media/mock_media_stream_dependency_factory.h"
|
| +#include "content/renderer/media/mock_media_stream_dispatcher.h"
|
| +#include "content/renderer/media/mock_peer_connection_impl.h"
|
| +#include "content/renderer/media/video_capture_impl_manager.h"
|
| +#include "content/renderer/p2p/socket_dispatcher.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPeerConnection.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
|
| +
|
| +TEST(MediaStreamImplTest, Basic) {
|
| + MessageLoop loop;
|
| +
|
| + // Create our test object
|
| + scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher(
|
| + new MockMediaStreamDispatcher());
|
| + scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher(
|
| + new content::P2PSocketDispatcher(NULL));
|
| + scoped_refptr<VideoCaptureImplManager> vc_manager(
|
| + new VideoCaptureImplManager());
|
| + MockMediaStreamDependencyFactory* dependency_factory =
|
| + new MockMediaStreamDependencyFactory();
|
| + scoped_refptr<MediaStreamImpl> ms_impl(new MediaStreamImpl(
|
| + ms_dispatcher.get(),
|
| + p2p_socket_dispatcher.get(),
|
| + vc_manager.get(),
|
| + dependency_factory));
|
| +
|
| + // TODO(grunell): Add tests for functions going to WebKit. Waiting for WebKit
|
| + // patches that changes the interface.
|
| +
|
| + int request_id(1);
|
| + WebKit::WebGenerateStreamOptionFlags flags =
|
| + WebKit::WebGenerateStreamRequestAudio |
|
| + WebKit::WebGenerateStreamRequestVideoFacingUser;
|
| + WebKit::WebSecurityOrigin web_security_origin =
|
| + WebKit::WebSecurityOrigin::create(WebKit::WebURL());
|
| + ms_impl->generateStream(request_id, flags, web_security_origin);
|
| + EXPECT_EQ(ms_dispatcher->request_id_, request_id);
|
| + EXPECT_TRUE(ms_dispatcher->components_->audio);
|
| + EXPECT_EQ(ms_dispatcher->components_->video_option,
|
| + media_stream::StreamOptions::kFacingUser);
|
| +
|
| + WebKit::WebPeerConnection web_peer_connection;
|
| + WebKit::WebString configuration;
|
| + ms_impl->newPeerConnection(web_peer_connection, configuration);
|
| + EXPECT_TRUE(ms_impl->native_peer_connection_ != NULL);
|
| +
|
| + webrtc::MockPeerConnectionImpl* mock_peer_connection =
|
| + static_cast<webrtc::MockPeerConnectionImpl*>(
|
| + ms_impl->native_peer_connection_.get());
|
| +
|
| + std::string message("message");
|
| + ms_impl->processSignalingMessage(web_peer_connection,
|
| + WebKit::WebString::fromUTF8(message));
|
| + EXPECT_EQ(mock_peer_connection->signaling_message_, message);
|
| +
|
| + // TODO(grunell): Add test for addStream and removeStream.
|
| +
|
| + ms_impl->closePeerConnection(web_peer_connection);
|
| + EXPECT_TRUE(ms_impl->native_peer_connection_ == NULL);
|
| +}
|
|
|