Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 SetUp() override { | |
| 21 dependency_factory_.reset(new MockPeerConnectionDependencyFactory()); | |
| 22 } | |
| 23 | |
| 24 void SetVideoTrack(blink::WebMediaConstraints constraints) { | |
| 25 registry_.Init("stream URL"); | |
| 26 registry_.AddVideoTrack("test video track", constraints); | |
| 27 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; | |
| 28 registry_.test_stream().videoTracks(video_tracks); | |
| 29 track_ = video_tracks[0]; | |
| 30 // TODO(hta): Verify that track_ is valid. When constraints produce | |
| 31 // no valid format, using the track will cause a crash. | |
| 32 } | |
| 33 | |
| 34 protected: | |
| 35 blink::WebMediaStreamTrack track_; | |
| 36 std::unique_ptr<MockPeerConnectionDependencyFactory> dependency_factory_; | |
|
tommi (sloooow) - chröme
2016/10/10 09:53:35
nit: what about MockPeerConnectionDependencyFactor
hta - Chromium
2016/10/10 13:15:03
Done.
| |
| 37 | |
| 38 private: | |
| 39 MockMediaStreamRegistry registry_; | |
| 40 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks | |
| 41 // and Sources in |registry_| into believing they are on the right threads. | |
| 42 base::MessageLoopForUI message_loop_; | |
| 43 const ChildProcess child_process_; | |
| 44 }; | |
| 45 | |
| 46 TEST_F(MediaStreamVideoWebRtcSinkTest, ObjectConstructor) { | |
| 47 blink::WebMediaConstraints constraints; | |
| 48 constraints.initialize(); | |
| 49 SetVideoTrack(constraints); | |
| 50 MediaStreamVideoWebRtcSink my_sink(track_, dependency_factory_.get()); | |
| 51 EXPECT_TRUE(my_sink.webrtc_video_track()); | |
| 52 } | |
| 53 | |
| 54 TEST_F(MediaStreamVideoWebRtcSinkTest, NoiseReductionConstraintPassThrough) { | |
| 55 MockConstraintFactory factory; | |
| 56 factory.basic().googNoiseReduction.setExact(true); | |
| 57 SetVideoTrack(factory.CreateWebMediaConstraints()); | |
| 58 MediaStreamVideoWebRtcSink my_sink(track_, dependency_factory_.get()); | |
| 59 EXPECT_TRUE(my_sink.SourceNeedsDenoising()); | |
| 60 EXPECT_TRUE(*(my_sink.SourceNeedsDenoising())); | |
| 61 } | |
| 62 | |
| 63 } // namespace | |
| 64 } // namespace content | |
| OLD | NEW |