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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 "content/renderer/media/webrtc/media_stream_video_webrtc_sink.h"
6
7 #include "content/child/child_process.h"
8 #include "content/renderer/media/mock_constraint_factory.h"
9 #include "content/renderer/media/mock_media_stream_registry.h"
10 #include "content/renderer/media/webrtc/mock_peer_connection_dependency_factory. h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace content {
14 namespace {
15
16 class MediaStreamVideoWebRtcSinkTest : public ::testing::Test {
17 public:
18 MediaStreamVideoWebRtcSinkTest() {}
19
20 void SetVideoTrack(blink::WebMediaConstraints constraints) {
21 registry_.Init("stream URL");
22 registry_.AddVideoTrack("test video track", constraints);
23 blink::WebVector<blink::WebMediaStreamTrack> video_tracks;
24 registry_.test_stream().videoTracks(video_tracks);
25 track_ = video_tracks[0];
26 // TODO(hta): Verify that track_ is valid. When constraints produce
27 // no valid format, using the track will cause a crash.
28 }
29
30 protected:
31 blink::WebMediaStreamTrack track_;
32 MockPeerConnectionDependencyFactory dependency_factory_;
33
34 private:
35 MockMediaStreamRegistry registry_;
36 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks
37 // and Sources in |registry_| into believing they are on the right threads.
38 base::MessageLoopForUI message_loop_;
39 const ChildProcess child_process_;
40 };
41
42 TEST_F(MediaStreamVideoWebRtcSinkTest, NoiseReductionDefaultsToNotSet) {
43 blink::WebMediaConstraints constraints;
44 constraints.initialize();
45 SetVideoTrack(constraints);
46 MediaStreamVideoWebRtcSink my_sink(track_, &dependency_factory_);
47 EXPECT_TRUE(my_sink.webrtc_video_track());
48 EXPECT_FALSE(my_sink.SourceNeedsDenoisingForTesting());
49 }
50
51 TEST_F(MediaStreamVideoWebRtcSinkTest, NoiseReductionConstraintPassThrough) {
52 MockConstraintFactory factory;
53 factory.basic().googNoiseReduction.setExact(true);
54 SetVideoTrack(factory.CreateWebMediaConstraints());
55 MediaStreamVideoWebRtcSink my_sink(track_, &dependency_factory_);
56 EXPECT_TRUE(my_sink.SourceNeedsDenoisingForTesting());
57 EXPECT_TRUE(*(my_sink.SourceNeedsDenoisingForTesting()));
58 }
59
60 } // namespace
61 } // namespace content
OLDNEW
« 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