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/media_stream_impl.h" | |
11 #include "content/renderer/media/mock_media_stream_dependency_factory.h" | |
12 #include "content/renderer/media/mock_media_stream_dispatcher.h" | |
13 #include "content/renderer/media/mock_peer_connection_impl.h" | |
14 #include "content/renderer/media/video_capture_impl_manager.h" | |
15 #include "content/renderer/p2p/socket_dispatcher.h" | |
16 #include "testing/gtest/include/gtest/gtest.h" | |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPeerConnection.h" | |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | |
21 | |
22 TEST(MediaStreamImplTest, Basic) { | |
23 MessageLoop loop; | |
24 | |
25 // Create our test object | |
scherkus (not reviewing)
2011/10/31 01:59:13
nit: comments end with periods
Henrik Grunell
2011/10/31 13:17:53
Done.
| |
26 scoped_ptr<MockMediaStreamDispatcher> ms_dispatcher( | |
27 new MockMediaStreamDispatcher()); | |
28 scoped_ptr<content::P2PSocketDispatcher> p2p_socket_dispatcher( | |
29 new content::P2PSocketDispatcher(NULL)); | |
30 scoped_refptr<VideoCaptureImplManager> vc_manager( | |
31 new VideoCaptureImplManager()); | |
32 MockMediaStreamDependencyFactory* dependency_factory = | |
33 new MockMediaStreamDependencyFactory(); | |
34 scoped_refptr<MediaStreamImpl> ms_impl(new MediaStreamImpl( | |
35 ms_dispatcher.get(), | |
36 p2p_socket_dispatcher.get(), | |
37 vc_manager.get(), | |
38 dependency_factory)); | |
39 | |
40 // TODO(grunell): Add tests for functions going to WebKit. Waiting for WebKit | |
41 // patches that changes the interface. | |
42 | |
43 int request_id(1); | |
44 WebKit::WebGenerateStreamOptionFlags flags = | |
45 WebKit::WebGenerateStreamRequestAudio | | |
46 WebKit::WebGenerateStreamRequestVideoFacingUser; | |
47 WebKit::WebSecurityOrigin web_security_origin = | |
48 WebKit::WebSecurityOrigin::create(WebKit::WebURL()); | |
49 ms_impl->generateStream(request_id, flags, web_security_origin); | |
50 EXPECT_EQ(ms_dispatcher->request_id_, request_id); | |
51 EXPECT_TRUE(ms_dispatcher->components_->audio); | |
52 EXPECT_EQ(ms_dispatcher->components_->video_option, | |
53 media_stream::StreamOptions::kFacingUser); | |
54 | |
55 WebKit::WebPeerConnection web_peer_connection; | |
56 WebKit::WebString configuration; | |
57 ms_impl->newPeerConnection(web_peer_connection, configuration); | |
58 EXPECT_TRUE(ms_impl->native_peer_connection_ != NULL); | |
scherkus (not reviewing)
2011/10/31 01:59:13
nit: use EXPECT_TRUE(ms_impl->native_peer_connecti
Henrik Grunell
2011/10/31 13:17:53
Done.
| |
59 | |
60 webrtc::MockPeerConnectionImpl* mock_peer_connection = | |
61 static_cast<webrtc::MockPeerConnectionImpl*>( | |
62 ms_impl->native_peer_connection_.get()); | |
63 | |
64 std::string message("message"); | |
65 ms_impl->processSignalingMessage(web_peer_connection, | |
66 WebKit::WebString::fromUTF8(message)); | |
67 EXPECT_EQ(mock_peer_connection->signaling_message_, message); | |
68 | |
69 // TODO(grunell): Add test for addStream and removeStream. | |
70 | |
71 ms_impl->closePeerConnection(web_peer_connection); | |
72 EXPECT_TRUE(ms_impl->native_peer_connection_ == NULL); | |
scherkus (not reviewing)
2011/10/31 01:59:13
nit: use EXPECT_FALSE
Henrik Grunell
2011/10/31 13:17:53
Done.
| |
73 } | |
OLD | NEW |