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 "content/renderer/media/speech_recognition_audio_sink.h" | 5 #include "content/renderer/media/speech_recognition_audio_sink.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/renderer/media/media_stream_audio_source.h" | 9 #include "content/renderer/media/media_stream_audio_source.h" |
10 #include "content/renderer/media/mock_media_constraint_factory.h" | 10 #include "content/renderer/media/mock_media_constraint_factory.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 explicit MockSyncSocket(SharedBuffer* shared_buffer) | 59 explicit MockSyncSocket(SharedBuffer* shared_buffer) |
60 : buffer_(shared_buffer), | 60 : buffer_(shared_buffer), |
61 in_failure_mode_(false) {} | 61 in_failure_mode_(false) {} |
62 | 62 |
63 MockSyncSocket(SharedBuffer* shared_buffer, const OnSendCB& on_send_cb) | 63 MockSyncSocket(SharedBuffer* shared_buffer, const OnSendCB& on_send_cb) |
64 : buffer_(shared_buffer), | 64 : buffer_(shared_buffer), |
65 on_send_cb_(on_send_cb), | 65 on_send_cb_(on_send_cb), |
66 in_failure_mode_(false) {} | 66 in_failure_mode_(false) {} |
67 | 67 |
68 virtual size_t Send(const void* buffer, size_t length) override; | 68 size_t Send(const void* buffer, size_t length) override; |
69 virtual size_t Receive(void* buffer, size_t length) override; | 69 size_t Receive(void* buffer, size_t length) override; |
70 | 70 |
71 // When |in_failure_mode_| == true, the socket fails to send. | 71 // When |in_failure_mode_| == true, the socket fails to send. |
72 void SetFailureMode(bool in_failure_mode) { | 72 void SetFailureMode(bool in_failure_mode) { |
73 in_failure_mode_ = in_failure_mode; | 73 in_failure_mode_ = in_failure_mode; |
74 } | 74 } |
75 | 75 |
76 private: | 76 private: |
77 SharedBuffer* buffer_; | 77 SharedBuffer* buffer_; |
78 const OnSendCB on_send_cb_; | 78 const OnSendCB on_send_cb_; |
79 bool in_failure_mode_; | 79 bool in_failure_mode_; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 const uint32 kBuffersPerNotification = Initialize(44100, 441, 16000, 1600); | 505 const uint32 kBuffersPerNotification = Initialize(44100, 441, 16000, 1600); |
506 AssertConsumedBuffers(0U); | 506 AssertConsumedBuffers(0U); |
507 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); | 507 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); |
508 EXPECT_CALL(*this, StoppedCallback()).Times(1); | 508 EXPECT_CALL(*this, StoppedCallback()).Times(1); |
509 | 509 |
510 native_track()->Stop(); | 510 native_track()->Stop(); |
511 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); | 511 CaptureAudioAndAssertConsumedBuffers(kBuffersPerNotification, 1U); |
512 } | 512 } |
513 | 513 |
514 } // namespace content | 514 } // namespace content |
OLD | NEW |