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

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

Issue 264363005: Cast: deliver video frames on the IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload again Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/child/child_process.h" 8 #include "content/child/child_process.h"
9 #include "content/common/media/video_capture.h"
9 #include "content/public/renderer/media_stream_video_sink.h" 10 #include "content/public/renderer/media_stream_video_sink.h"
10 #include "content/renderer/media/media_stream.h" 11 #include "content/renderer/media/media_stream.h"
11 #include "content/renderer/media/media_stream_registry_interface.h" 12 #include "content/renderer/media/media_stream_registry_interface.h"
12 #include "content/renderer/media/mock_media_stream_registry.h" 13 #include "content/renderer/media/mock_media_stream_registry.h"
13 #include "content/renderer/media/video_source_handler.h" 14 #include "content/renderer/media/video_source_handler.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 17 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
17 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
18 19
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 int width = 640; 64 int width = 640;
64 int height = 360; 65 int height = 360;
65 base::TimeDelta ts = base::TimeDelta::FromInternalValue(789012); 66 base::TimeDelta ts = base::TimeDelta::FromInternalValue(789012);
66 67
67 // A new frame is captured. 68 // A new frame is captured.
68 scoped_refptr<media::VideoFrame> captured_frame = 69 scoped_refptr<media::VideoFrame> captured_frame =
69 media::VideoFrame::CreateBlackFrame(gfx::Size(width, height)); 70 media::VideoFrame::CreateBlackFrame(gfx::Size(width, height));
70 captured_frame->set_timestamp(ts); 71 captured_frame->set_timestamp(ts);
71 72
72 // The frame is delivered to VideoSourceHandler. 73 // The frame is delivered to VideoSourceHandler.
73 MediaStreamVideoSink* receiver = handler_->GetReceiver(&reader); 74 handler_->DeliverFrameForTesting(&reader, captured_frame);
74 receiver->OnVideoFrame(captured_frame);
75 75
76 // Compare |frame| to |captured_frame|. 76 // Compare |frame| to |captured_frame|.
77 const media::VideoFrame* frame = reader.last_frame(); 77 const media::VideoFrame* frame = reader.last_frame();
78 ASSERT_TRUE(frame != NULL); 78 ASSERT_TRUE(frame != NULL);
79 EXPECT_EQ(width, frame->coded_size().width()); 79 EXPECT_EQ(width, frame->coded_size().width());
80 EXPECT_EQ(height, frame->coded_size().height()); 80 EXPECT_EQ(height, frame->coded_size().height());
81 EXPECT_EQ(ts, frame->timestamp()); 81 EXPECT_EQ(ts, frame->timestamp());
82 EXPECT_EQ(captured_frame->data(media::VideoFrame::kYPlane), 82 EXPECT_EQ(captured_frame->data(media::VideoFrame::kYPlane),
83 frame->data(media::VideoFrame::kYPlane)); 83 frame->data(media::VideoFrame::kYPlane));
84 84
85 EXPECT_FALSE(handler_->Close(NULL)); 85 EXPECT_FALSE(handler_->Close(NULL));
86 EXPECT_TRUE(handler_->Close(&reader)); 86 EXPECT_TRUE(handler_->Close(&reader));
87 EXPECT_TRUE(handler_->GetReceiver(&reader) == NULL);
88 } 87 }
89 88
90 TEST_F(VideoSourceHandlerTest, OpenWithoutClose) { 89 TEST_F(VideoSourceHandlerTest, OpenWithoutClose) {
91 FakeFrameReader reader; 90 FakeFrameReader reader;
92 EXPECT_TRUE(handler_->Open(kTestStreamUrl, &reader)); 91 EXPECT_TRUE(handler_->Open(kTestStreamUrl, &reader));
93 } 92 }
94 93
95 } // namespace content 94 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698