OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "content/public/common/content_switches.h" | 6 #include "content/public/common/content_switches.h" |
7 #include "content/renderer/media/mock_media_constraint_factory.h" | 7 #include "content/renderer/media/mock_media_constraint_factory.h" |
8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
9 #include "content/renderer/media/webrtc_local_audio_track.h" | 9 #include "content/renderer/media/webrtc_local_audio_track.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Send a packet via |track_| and it data should reach the sink of the | 67 // Send a packet via |track_| and it data should reach the sink of the |
68 // |adapter_|. | 68 // |adapter_|. |
69 const int length = params_.frames_per_buffer() * params_.channels(); | 69 const int length = params_.frames_per_buffer() * params_.channels(); |
70 scoped_ptr<int16[]> data(new int16[length]); | 70 scoped_ptr<int16[]> data(new int16[length]); |
71 // Initialize the data to 0 to avoid Memcheck:Uninitialized warning. | 71 // Initialize the data to 0 to avoid Memcheck:Uninitialized warning. |
72 memset(data.get(), 0, length * sizeof(data[0])); | 72 memset(data.get(), 0, length * sizeof(data[0])); |
73 | 73 |
74 EXPECT_CALL(*sink, | 74 EXPECT_CALL(*sink, |
75 OnData(_, 16, params_.sample_rate(), params_.channels(), | 75 OnData(_, 16, params_.sample_rate(), params_.channels(), |
76 params_.frames_per_buffer())); | 76 params_.frames_per_buffer())); |
77 track_->Capture(data.get(), base::TimeDelta(), 255, false, false); | 77 track_->Capture(data.get(), base::TimeDelta(), 255, false, false, false); |
78 | 78 |
79 // Remove the sink from the webrtc track. | 79 // Remove the sink from the webrtc track. |
80 webrtc_track->RemoveSink(sink.get()); | 80 webrtc_track->RemoveSink(sink.get()); |
81 sink.reset(); | 81 sink.reset(); |
82 | 82 |
83 // Verify that no more callback gets into the sink. | 83 // Verify that no more callback gets into the sink. |
84 track_->Capture(data.get(), base::TimeDelta(), 255, false, false); | 84 track_->Capture(data.get(), base::TimeDelta(), 255, false, false, false); |
85 } | 85 } |
86 | 86 |
87 TEST_F(WebRtcLocalAudioTrackAdapterTest, GetSignalLevel) { | 87 TEST_F(WebRtcLocalAudioTrackAdapterTest, GetSignalLevel) { |
88 webrtc::AudioTrackInterface* webrtc_track = | 88 webrtc::AudioTrackInterface* webrtc_track = |
89 static_cast<webrtc::AudioTrackInterface*>(adapter_.get()); | 89 static_cast<webrtc::AudioTrackInterface*>(adapter_.get()); |
90 int signal_level = 0; | 90 int signal_level = 0; |
91 EXPECT_TRUE(webrtc_track->GetSignalLevel(&signal_level)); | 91 EXPECT_TRUE(webrtc_track->GetSignalLevel(&signal_level)); |
92 | 92 |
93 // Disable the audio processing in the audio track. | 93 // Disable the audio processing in the audio track. |
94 CommandLine::ForCurrentProcess()->AppendSwitch( | 94 CommandLine::ForCurrentProcess()->AppendSwitch( |
95 switches::kDisableAudioTrackProcessing); | 95 switches::kDisableAudioTrackProcessing); |
96 EXPECT_FALSE(webrtc_track->GetSignalLevel(&signal_level)); | 96 EXPECT_FALSE(webrtc_track->GetSignalLevel(&signal_level)); |
97 } | 97 } |
98 | 98 |
99 } // namespace content | 99 } // namespace content |
OLD | NEW |