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 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, ObjectConstructor) { | |
|
pbos
2016/10/10 15:43:32
Can you put something descriptive of the test, suc
| |
| 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.SourceNeedsDenoisingTestHelper()); | |
| 49 } | |
| 50 | |
| 51 TEST_F(MediaStreamVideoWebRtcSinkTest, NoiseReductionConstraintPassThrough) { | |
|
pbos
2016/10/10 15:43:32
Pref naming this test PassesThroughNoiseReductionC
| |
| 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.SourceNeedsDenoisingTestHelper()); | |
| 57 EXPECT_TRUE(*(my_sink.SourceNeedsDenoisingTestHelper())); | |
| 58 } | |
| 59 | |
| 60 } // namespace | |
| 61 } // namespace content | |
| OLD | NEW |