Chromium Code Reviews| 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..d57d50ccecff25172655504c08667d3caac7764f |
| --- /dev/null |
| +++ b/content/renderer/media/media_stream_impl_unittest.cc |
| @@ -0,0 +1,67 @@ |
| +// 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_web_peer_connection_handler_client.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/WebPeerConnectionHandler.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. |
| + |
| + // TODO(grunell): Enable and update implementation when available again. |
| +// int request_id(1); |
|
tommi (sloooow) - chröme
2011/11/08 12:27:24
remove?
Henrik Grunell
2011/11/08 22:06:41
Done.
|
| +// 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::MockWebPeerConnectionHandlerClient client; |
| +// WebKit::WebPeerConnectionHandler* handler = |
| + ms_impl->CreatePeerConnectionHandler(&client); |
| + EXPECT_TRUE(ms_impl->peer_connection_handler_.get()); |
| + |
| +// webrtc::MockPeerConnectionImpl* mock_peer_connection = |
| +// static_cast<webrtc::MockPeerConnectionImpl*>( |
| +// ms_impl->peer_connection_handler_.get()); |
| + |
| + ms_impl->ClosePeerConnection(); |
| + EXPECT_FALSE(ms_impl->peer_connection_handler_.get()); |
| +} |