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

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

Issue 14312015: Effects Pepper Plugin and MediaStream Glue. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/utf_string_conversions.h"
8 #include "content/renderer/media/media_stream_extra_data.h"
9 #include "content/renderer/media/media_stream_registry_interface.h"
10 #include "content/renderer/media/mock_media_stream_dependency_factory.h"
11 #include "content/renderer/media/mock_media_stream_registry.h"
12 #include "content/renderer/media/video_source_handler.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack .h"
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
18
19 using cricket::VideoFrame;
20
21 namespace content {
22
23 static const std::string kTestStreamUrl = "stream_url";
24 static const std::string kTestVideoTrackId = "video_track_id";
25 static const std::string kUnknownStreamUrl = "unknown_stream_url";
26
27 class FakeFrameReader : public FrameReaderInterface {
28 public:
29 virtual bool GotFrame(VideoFrame* frame) OVERRIDE {
30 last_frame_.reset(frame);
31 return true;
32 }
33
34 const VideoFrame* last_frame() {
35 return last_frame_.get();
36 }
37
38 private:
39 scoped_ptr<VideoFrame> last_frame_;
40 };
41
42 class VideoSourceHandlerTest : public ::testing::Test {
43 public:
44 VideoSourceHandlerTest() : registry_(&dependency_factory_) {
45 handler_.reset(new VideoSourceHandler(&dependency_factory_, &registry_));
46 dependency_factory_.EnsurePeerConnectionFactory();
47 registry_.Init(kTestStreamUrl);
48 registry_.AddVideoTrack(kTestVideoTrackId);
49 }
50
51 protected:
52 scoped_ptr<VideoSourceHandler> handler_;
53 MockMediaStreamDependencyFactory dependency_factory_;
54 MockMediaStreamRegistry registry_;
55 };
56
57 TEST_F(VideoSourceHandlerTest, OpenClose) {
58 FakeFrameReader reader;
59 // Unknow url will return false.
60 EXPECT_FALSE(handler_->Open(kUnknownStreamUrl, &reader));
61 EXPECT_TRUE(handler_->Open(kTestStreamUrl, &reader));
62 cricket::WebRtcVideoFrame test_frame;
63 int width = 640;
64 int height = 360;
65 int64 et = 123456;
66 int64 ts = 789012;
67 test_frame.InitToBlack(width, height, 1, 1, et, ts);
68 cricket::VideoRenderer* receiver = handler_->GetReceiver(&reader);
69 ASSERT(receiver != NULL);
70 receiver->RenderFrame(&test_frame);
71
72 const VideoFrame* frame = reader.last_frame();
73 ASSERT_TRUE(frame != NULL);
74
75 // Compare |frame| to |test_frame|.
76 EXPECT_EQ(test_frame.GetWidth(), frame->GetWidth());
77 EXPECT_EQ(test_frame.GetHeight(), frame->GetHeight());
78 EXPECT_EQ(test_frame.GetElapsedTime(), frame->GetElapsedTime());
79 EXPECT_EQ(test_frame.GetTimeStamp(), frame->GetTimeStamp());
80 EXPECT_EQ(test_frame.GetYPlane(), frame->GetYPlane());
81 EXPECT_EQ(test_frame.GetUPlane(), frame->GetUPlane());
82 EXPECT_EQ(test_frame.GetVPlane(), frame->GetVPlane());
83
84 EXPECT_TRUE(handler_->Close(kTestStreamUrl, &reader));
85 }
86
87 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698