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

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/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack .h"
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
17 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h"
18
19 namespace content {
20
21 static const std::string kTestStreamUrl = "stream_url";
22 static const std::string kTestVideoTrackId = "video_track_id";
23 static const std::string kUnknownStreamUrl = "unknown_stream_url";
24
25 class VideoSourceHandlerTest : public ::testing::Test {
26 public:
27 VideoSourceHandlerTest() : registry_(&dependency_factory_) {
28 handler_.reset(new VideoSourceHandler(&dependency_factory_, &registry_));
29 dependency_factory_.EnsurePeerConnectionFactory();
30 registry_.Init(kTestStreamUrl);
31 registry_.AddVideoTrack(kTestVideoTrackId);
32 }
33
34 protected:
35 scoped_ptr<VideoSourceHandler> handler_;
36 MockMediaStreamDependencyFactory dependency_factory_;
37 MockMediaStreamRegistry registry_;
38 };
39
40 TEST_F(VideoSourceHandlerTest, OpenClose) {
41 FrameReaderInterface* frame_reader = NULL;
42 // Unknow url will return false.
43 EXPECT_FALSE(handler_->Open(kUnknownStreamUrl, &frame_reader));
44 EXPECT_TRUE(handler_->Open(kTestStreamUrl, &frame_reader));
45 EXPECT_TRUE(frame_reader);
46 cricket::WebRtcVideoFrame test_frame;
47 int width = 640;
48 int height = 360;
49 int64 et = 123456;
50 int64 ts = 789012;
51 test_frame.InitToBlack(width, height, 1, 1, et, ts);
52 PpFrameReader* source = static_cast<PpFrameReader*>(frame_reader);
53 source->RenderFrame(&test_frame);
54 cricket::VideoFrame* frame;
55 EXPECT_TRUE(frame_reader->GetFrame(&frame));
56 ASSERT_TRUE(frame != NULL);
57
58 // Compare |frame| to |test_frame|.
59 EXPECT_EQ(test_frame.GetWidth(), frame->GetWidth());
60 EXPECT_EQ(test_frame.GetHeight(), frame->GetHeight());
61 EXPECT_EQ(test_frame.GetElapsedTime(), frame->GetElapsedTime());
62 EXPECT_EQ(test_frame.GetTimeStamp(), frame->GetTimeStamp());
63 EXPECT_EQ(test_frame.GetYPlane(), frame->GetYPlane());
64 EXPECT_EQ(test_frame.GetUPlane(), frame->GetUPlane());
65 EXPECT_EQ(test_frame.GetVPlane(), frame->GetVPlane());
66
67 EXPECT_TRUE(handler_->Close(kTestStreamUrl, frame_reader));
68 }
69
70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698