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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/video_source_handler_unittest.cc
===================================================================
--- content/renderer/media/video_source_handler_unittest.cc (revision 0)
+++ content/renderer/media/video_source_handler_unittest.cc (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "base/utf_string_conversions.h"
+#include "content/renderer/media/media_stream_extra_data.h"
+#include "content/renderer/media/media_stream_registry_interface.h"
+#include "content/renderer/media/mock_media_stream_dependency_factory.h"
+#include "content/renderer/media/mock_media_stream_registry.h"
+#include "content/renderer/media/video_source_handler.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
+#include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h"
+
+namespace content {
+
+static const std::string kTestStreamUrl = "stream_url";
+static const std::string kTestVideoTrackId = "video_track_id";
+static const std::string kUnknownStreamUrl = "unknown_stream_url";
+
+class VideoSourceHandlerTest : public ::testing::Test {
+ public:
+ VideoSourceHandlerTest() : registry_(&dependency_factory_) {
+ handler_.reset(new VideoSourceHandler(&dependency_factory_, &registry_));
+ dependency_factory_.EnsurePeerConnectionFactory();
+ registry_.Init(kTestStreamUrl);
+ registry_.AddVideoTrack(kTestVideoTrackId);
+ }
+
+ protected:
+ scoped_ptr<VideoSourceHandler> handler_;
+ MockMediaStreamDependencyFactory dependency_factory_;
+ MockMediaStreamRegistry registry_;
+};
+
+TEST_F(VideoSourceHandlerTest, OpenClose) {
+ FrameReaderInterface* frame_reader = NULL;
+ // Unknow url will return false.
+ EXPECT_FALSE(handler_->Open(kUnknownStreamUrl, &frame_reader));
+ EXPECT_TRUE(handler_->Open(kTestStreamUrl, &frame_reader));
+ EXPECT_TRUE(frame_reader);
+ cricket::WebRtcVideoFrame test_frame;
+ int width = 640;
+ int height = 360;
+ int64 et = 123456;
+ int64 ts = 789012;
+ test_frame.InitToBlack(width, height, 1, 1, et, ts);
+ PpFrameReader* source = static_cast<PpFrameReader*>(frame_reader);
+ source->RenderFrame(&test_frame);
+ cricket::VideoFrame* frame;
+ EXPECT_TRUE(frame_reader->GetFrame(&frame));
+ ASSERT_TRUE(frame != NULL);
+
+ // Compare |frame| to |test_frame|.
+ EXPECT_EQ(test_frame.GetWidth(), frame->GetWidth());
+ EXPECT_EQ(test_frame.GetHeight(), frame->GetHeight());
+ EXPECT_EQ(test_frame.GetElapsedTime(), frame->GetElapsedTime());
+ EXPECT_EQ(test_frame.GetTimeStamp(), frame->GetTimeStamp());
+ EXPECT_EQ(test_frame.GetYPlane(), frame->GetYPlane());
+ EXPECT_EQ(test_frame.GetUPlane(), frame->GetUPlane());
+ EXPECT_EQ(test_frame.GetVPlane(), frame->GetVPlane());
+
+ EXPECT_TRUE(handler_->Close(kTestStreamUrl, frame_reader));
+}
+
+} // namespace content
Property changes on: content/renderer/media/video_source_handler_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698