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

Unified Diff: content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc

Issue 2393923002: Add unit tests for webrtc_media_stream_adapter.cc (Closed)
Patch Set: Renamed test function Created 4 years, 2 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
« no previous file with comments | « content/renderer/media/webrtc/media_stream_video_webrtc_sink.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc
diff --git a/content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc b/content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5080a5888f694aa1704b859cb1f20ca87d6f4b59
--- /dev/null
+++ b/content/renderer/media/webrtc/media_stream_video_webrtc_sink_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 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 "content/renderer/media/webrtc/media_stream_video_webrtc_sink.h"
+
+#include "content/child/child_process.h"
+#include "content/renderer/media/mock_constraint_factory.h"
+#include "content/renderer/media/mock_media_stream_registry.h"
+#include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+namespace {
+
+class MediaStreamVideoWebRtcSinkTest : public ::testing::Test {
+ public:
+ MediaStreamVideoWebRtcSinkTest() {}
+
+ void SetVideoTrack(blink::WebMediaConstraints constraints) {
+ registry_.Init("stream URL");
+ registry_.AddVideoTrack("test video track", constraints);
+ blink::WebVector<blink::WebMediaStreamTrack> video_tracks;
+ registry_.test_stream().videoTracks(video_tracks);
+ track_ = video_tracks[0];
+ // TODO(hta): Verify that track_ is valid. When constraints produce
+ // no valid format, using the track will cause a crash.
+ }
+
+ protected:
+ blink::WebMediaStreamTrack track_;
+ MockPeerConnectionDependencyFactory dependency_factory_;
+
+ private:
+ MockMediaStreamRegistry registry_;
+ // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks
+ // and Sources in |registry_| into believing they are on the right threads.
+ base::MessageLoopForUI message_loop_;
+ const ChildProcess child_process_;
+};
+
+TEST_F(MediaStreamVideoWebRtcSinkTest, NoiseReductionDefaultsToNotSet) {
+ blink::WebMediaConstraints constraints;
+ constraints.initialize();
+ SetVideoTrack(constraints);
+ MediaStreamVideoWebRtcSink my_sink(track_, &dependency_factory_);
+ EXPECT_TRUE(my_sink.webrtc_video_track());
+ EXPECT_FALSE(my_sink.SourceNeedsDenoisingForTesting());
+}
+
+TEST_F(MediaStreamVideoWebRtcSinkTest, NoiseReductionConstraintPassThrough) {
+ MockConstraintFactory factory;
+ factory.basic().googNoiseReduction.setExact(true);
+ SetVideoTrack(factory.CreateWebMediaConstraints());
+ MediaStreamVideoWebRtcSink my_sink(track_, &dependency_factory_);
+ EXPECT_TRUE(my_sink.SourceNeedsDenoisingForTesting());
+ EXPECT_TRUE(*(my_sink.SourceNeedsDenoisingForTesting()));
+}
+
+} // namespace
+} // namespace content
« no previous file with comments | « content/renderer/media/webrtc/media_stream_video_webrtc_sink.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698