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

Side by Side Diff: content/renderer/media/peer_connection_handler_unittest.cc

Issue 9301031: Adding unittest for the reference counting of WebMediaStreamDescriptor/Source (Closed)
Patch Set: Rebase Created 8 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/renderer/media/mock_media_stream_dependency_factory.h" 10 #include "content/renderer/media/mock_media_stream_dependency_factory.h"
(...skipping 13 matching lines...) Expand all
24 class MockVideoRendererWrapper : public VideoRendererWrapperInterface { 24 class MockVideoRendererWrapper : public VideoRendererWrapperInterface {
25 public: 25 public:
26 virtual cricket::VideoRenderer* renderer() OVERRIDE { return NULL; } 26 virtual cricket::VideoRenderer* renderer() OVERRIDE { return NULL; }
27 27
28 protected: 28 protected:
29 virtual ~MockVideoRendererWrapper() {} 29 virtual ~MockVideoRendererWrapper() {}
30 }; 30 };
31 31
32 } // namespace webrtc 32 } // namespace webrtc
33 33
34 TEST(PeerConnectionHandlerTest, WebMediaStreamDescriptorMemoryTest) {
35 std::string stream_label("stream-label");
36 std::string video_track_id("video-label");
37 const size_t kSizeOne = 1;
38
39 WebKit::WebMediaStreamSource source;
40 source.initialize(WebKit::WebString::fromUTF8(video_track_id),
41 WebKit::WebMediaStreamSource::TypeVideo,
42 WebKit::WebString::fromUTF8("RemoteVideo"));
43
44 WebKit::WebVector<WebKit::WebMediaStreamSource> source_vector(kSizeOne);
45 source_vector[0] = source;
46
47 WebKit::WebMediaStreamDescriptor local_stream;
48 local_stream.initialize(UTF8ToUTF16(stream_label), source_vector);
49
50 WebKit::WebMediaStreamDescriptor copy_1(local_stream);
51 {
52 WebKit::WebMediaStreamDescriptor copy_2(copy_1);
53 }
54 }
55
34 TEST(PeerConnectionHandlerTest, Basic) { 56 TEST(PeerConnectionHandlerTest, Basic) {
35 MessageLoop loop; 57 MessageLoop loop;
36 58
37 scoped_ptr<WebKit::MockWebPeerConnectionHandlerClient> mock_client( 59 scoped_ptr<WebKit::MockWebPeerConnectionHandlerClient> mock_client(
38 new WebKit::MockWebPeerConnectionHandlerClient()); 60 new WebKit::MockWebPeerConnectionHandlerClient());
39 scoped_refptr<MockMediaStreamImpl> mock_ms_impl(new MockMediaStreamImpl()); 61 scoped_refptr<MockMediaStreamImpl> mock_ms_impl(new MockMediaStreamImpl());
40 scoped_ptr<MockMediaStreamDependencyFactory> mock_dependency_factory( 62 scoped_ptr<MockMediaStreamDependencyFactory> mock_dependency_factory(
41 new MockMediaStreamDependencyFactory()); 63 new MockMediaStreamDependencyFactory());
42 mock_dependency_factory->CreatePeerConnectionFactory(NULL, 64 mock_dependency_factory->CreatePeerConnectionFactory(NULL,
43 NULL, 65 NULL,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 EXPECT_EQ(stream_label, mock_peer_connection->stream_label()); 147 EXPECT_EQ(stream_label, mock_peer_connection->stream_label());
126 EXPECT_TRUE(mock_peer_connection->stream_changes_committed()); 148 EXPECT_TRUE(mock_peer_connection->stream_changes_committed());
127 149
128 pc_handler->stop(); 150 pc_handler->stop();
129 EXPECT_FALSE(pc_handler->native_peer_connection_.get()); 151 EXPECT_FALSE(pc_handler->native_peer_connection_.get());
130 // PC handler is expected to be deleted when stop calls 152 // PC handler is expected to be deleted when stop calls
131 // MediaStreamImpl::ClosePeerConnection. We own and delete it here instead of 153 // MediaStreamImpl::ClosePeerConnection. We own and delete it here instead of
132 // in the mock. 154 // in the mock.
133 pc_handler.reset(); 155 pc_handler.reset();
134 } 156 }
OLDNEW
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698