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

Unified Diff: content/renderer/media/webrtc_local_audio_track_unittest.cc

Issue 21183002: Adding key press detection in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
Index: content/renderer/media/webrtc_local_audio_track_unittest.cc
diff --git a/content/renderer/media/webrtc_local_audio_track_unittest.cc b/content/renderer/media/webrtc_local_audio_track_unittest.cc
index 1638feb86744a30bd493fb029ffdb27c42bf01ae..638d3747ac8ccd4dc60a411bd9bdde409fa4275b 100644
--- a/content/renderer/media/webrtc_local_audio_track_unittest.cc
+++ b/content/renderer/media/webrtc_local_audio_track_unittest.cc
@@ -49,7 +49,7 @@ class FakeAudioThread : public base::PlatformThread::Delegate {
static_cast<media::AudioCapturerSource::CaptureCallback*>(
capturer_.get());
audio_bus_->Zero();
- callback->Capture(audio_bus_.get(), 0, 0);
+ callback->Capture(audio_bus_.get(), 0, 0, false);
// Sleep 1ms to yield the resource for the main thread.
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
@@ -95,11 +95,13 @@ class MockWebRtcAudioCapturerSink : public WebRtcAudioCapturerSink {
public:
MockWebRtcAudioCapturerSink() {}
~MockWebRtcAudioCapturerSink() {}
- MOCK_METHOD5(CaptureData, void(const int16* audio_data,
- int number_of_channels,
- int number_of_frames,
- int audio_delay_milliseconds,
- double volume));
+ MOCK_METHOD6(CaptureData,
+ void(const int16* audio_data,
+ int number_of_channels,
+ int number_of_frames,
+ int audio_delay_milliseconds,
+ double volume,
+ bool key_pressed));
MOCK_METHOD1(SetCaptureFormat, void(const media::AudioParameters& params));
};
@@ -147,8 +149,10 @@ TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) {
const media::AudioParameters params = capturer_->audio_parameters();
base::WaitableEvent event(false, false);
EXPECT_CALL(*sink, SetCaptureFormat(_)).WillOnce(Return());
- EXPECT_CALL(*sink, CaptureData(
- _, params.channels(), params.frames_per_buffer(), 0, 0))
+ EXPECT_CALL(
+ *sink,
+ CaptureData(
+ _, params.channels(), params.frames_per_buffer(), 0, 0, false))
.Times(AtLeast(1)).WillRepeatedly(SignalEvent(&event));
track->AddSink(sink.get());
@@ -178,15 +182,19 @@ TEST_F(WebRtcLocalAudioTrackTest, DISABLED_DisableEnableAudioTrack) {
const media::AudioParameters params = capturer_->audio_parameters();
base::WaitableEvent event(false, false);
EXPECT_CALL(*sink, SetCaptureFormat(_)).WillOnce(Return());
- EXPECT_CALL(*sink, CaptureData(
- _, params.channels(), params.frames_per_buffer(), 0, 0))
+ EXPECT_CALL(
+ *sink,
+ CaptureData(
+ _, params.channels(), params.frames_per_buffer(), 0, 0, false))
.Times(0);
track->AddSink(sink.get());
EXPECT_FALSE(event.TimedWait(TestTimeouts::tiny_timeout()));
event.Reset();
- EXPECT_CALL(*sink, CaptureData(
- _, params.channels(), params.frames_per_buffer(), 0, 0))
+ EXPECT_CALL(
+ *sink,
+ CaptureData(
+ _, params.channels(), params.frames_per_buffer(), 0, 0, false))
.Times(AtLeast(1)).WillRepeatedly(SignalEvent(&event));
EXPECT_TRUE(track->set_enabled(true));
EXPECT_TRUE(event.TimedWait(TestTimeouts::tiny_timeout()));
@@ -210,8 +218,10 @@ TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) {
const media::AudioParameters params = capturer_->audio_parameters();
base::WaitableEvent event_1(false, false);
EXPECT_CALL(*sink_1, SetCaptureFormat(_)).WillOnce(Return());
- EXPECT_CALL(*sink_1, CaptureData(
- _, params.channels(), params.frames_per_buffer(), 0, 0))
+ EXPECT_CALL(
+ *sink_1,
+ CaptureData(
+ _, params.channels(), params.frames_per_buffer(), 0, 0, false))
.Times(AtLeast(1)).WillRepeatedly(SignalEvent(&event_1));
track_1->AddSink(sink_1.get());
EXPECT_TRUE(event_1.TimedWait(TestTimeouts::tiny_timeout()));
@@ -228,11 +238,15 @@ TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) {
scoped_ptr<MockWebRtcAudioCapturerSink> sink_2(
new MockWebRtcAudioCapturerSink());
EXPECT_CALL(*sink_2, SetCaptureFormat(_)).WillOnce(Return());
- EXPECT_CALL(*sink_1, CaptureData(
- _, params.channels(), params.frames_per_buffer(), 0, 0))
+ EXPECT_CALL(
+ *sink_1,
+ CaptureData(
+ _, params.channels(), params.frames_per_buffer(), 0, 0, false))
.Times(AtLeast(1)).WillRepeatedly(SignalEvent(&event_1));
- EXPECT_CALL(*sink_2, CaptureData(
- _, params.channels(), params.frames_per_buffer(), 0, 0))
+ EXPECT_CALL(
+ *sink_2,
+ CaptureData(
+ _, params.channels(), params.frames_per_buffer(), 0, 0, false))
.Times(AtLeast(1)).WillRepeatedly(SignalEvent(&event_2));
track_2->AddSink(sink_2.get());
EXPECT_TRUE(event_1.TimedWait(TestTimeouts::tiny_timeout()));
@@ -271,7 +285,7 @@ TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) {
scoped_ptr<MockWebRtcAudioCapturerSink> default_sink(
new MockWebRtcAudioCapturerSink());
EXPECT_CALL(*default_sink, SetCaptureFormat(_)).WillOnce(Return());
- EXPECT_CALL(*default_sink, CaptureData(_, _, _, 0, 0))
+ EXPECT_CALL(*default_sink, CaptureData(_, _, _, 0, 0, false))
.Times(AnyNumber()).WillRepeatedly(Return());
capturer_->SetDefaultSink(default_sink.get());
EXPECT_CALL(*capturer_source_.get(), Start()).Times(0);

Powered by Google App Engine
This is Rietveld 408576698