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

Side by Side Diff: content/browser/speech/speech_recognizer_impl_unittest.cc

Issue 549373003: Binding media stream audio track to speech recognition [browser] Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Audio Receiver unit test Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <vector> 5 #include <vector>
6 6
7 #include "content/browser/browser_thread_impl.h" 7 #include "content/browser/browser_thread_impl.h"
8 #include "content/browser/speech/google_one_shot_remote_engine.h" 8 #include "content/browser/speech/google_one_shot_remote_engine.h"
9 #include "content/browser/speech/speech_recognizer_impl.h" 9 #include "content/browser/speech/speech_recognizer_impl.h"
10 #include "content/public/browser/speech_recognition_event_listener.h" 10 #include "content/public/browser/speech_recognition_event_listener.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 SpeechRecognitionEngine* sr_engine = 48 SpeechRecognitionEngine* sr_engine =
49 new GoogleOneShotRemoteEngine(NULL /* URLRequestContextGetter */); 49 new GoogleOneShotRemoteEngine(NULL /* URLRequestContextGetter */);
50 SpeechRecognitionEngineConfig config; 50 SpeechRecognitionEngineConfig config;
51 config.audio_num_bits_per_sample = 51 config.audio_num_bits_per_sample =
52 SpeechRecognizerImpl::kNumBitsPerAudioSample; 52 SpeechRecognizerImpl::kNumBitsPerAudioSample;
53 config.audio_sample_rate = SpeechRecognizerImpl::kAudioSampleRate; 53 config.audio_sample_rate = SpeechRecognizerImpl::kAudioSampleRate;
54 config.filter_profanities = false; 54 config.filter_profanities = false;
55 sr_engine->SetConfig(config); 55 sr_engine->SetConfig(config);
56 56
57 const int kTestingSessionId = 1; 57 const int kTestingSessionId = 1;
58 recognizer_ = new SpeechRecognizerImpl( 58 recognizer_ = new SpeechRecognizerImpl(this,
59 this, kTestingSessionId, false, false, sr_engine); 59 kTestingSessionId,
60 false, // continuous
61 false, // provisional_results
62 false, // using_audio_receiver
63 base::kNullProcessHandle,
64 sr_engine);
60 audio_manager_.reset(new media::MockAudioManager( 65 audio_manager_.reset(new media::MockAudioManager(
61 base::MessageLoop::current()->message_loop_proxy().get())); 66 base::MessageLoop::current()->message_loop_proxy().get()));
62 recognizer_->SetAudioManagerForTesting(audio_manager_.get()); 67 recognizer_->SetAudioManagerForTesting(audio_manager_.get());
63 68
64 int audio_packet_length_bytes = 69 int audio_packet_length_bytes =
65 (SpeechRecognizerImpl::kAudioSampleRate * 70 (SpeechRecognizerImpl::kAudioSampleRate *
66 GoogleOneShotRemoteEngine::kAudioPacketIntervalMs * 71 GoogleOneShotRemoteEngine::kAudioPacketIntervalMs *
67 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout) * 72 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout) *
68 SpeechRecognizerImpl::kNumBitsPerAudioSample) / (8 * 1000); 73 SpeechRecognizerImpl::kNumBitsPerAudioSample) / (8 * 1000);
69 audio_packet_.resize(audio_packet_length_bytes); 74 audio_packet_.resize(audio_packet_length_bytes);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 CheckEventsConsistency(); 133 CheckEventsConsistency();
129 } 134 }
130 135
131 virtual void OnRecognitionStart(int session_id) override { 136 virtual void OnRecognitionStart(int session_id) override {
132 recognition_started_ = true; 137 recognition_started_ = true;
133 CheckEventsConsistency(); 138 CheckEventsConsistency();
134 } 139 }
135 140
136 virtual void OnEnvironmentEstimationComplete(int session_id) override {} 141 virtual void OnEnvironmentEstimationComplete(int session_id) override {}
137 142
143 virtual void OnAudioReceiverReady(
144 int session_id,
145 const media::AudioParameters& params,
146 const base::SharedMemoryHandle memory,
147 const base::SyncSocket::TransitDescriptor socket) override {}
148
138 virtual void OnSoundStart(int session_id) override { 149 virtual void OnSoundStart(int session_id) override {
139 sound_started_ = true; 150 sound_started_ = true;
140 CheckEventsConsistency(); 151 CheckEventsConsistency();
141 } 152 }
142 153
143 virtual void OnSoundEnd(int session_id) override { 154 virtual void OnSoundEnd(int session_id) override {
144 sound_ended_ = true; 155 sound_ended_ = true;
145 CheckEventsConsistency(); 156 CheckEventsConsistency();
146 } 157 }
147 158
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 509
499 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 510 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
500 EXPECT_FALSE(audio_ended_); 511 EXPECT_FALSE(audio_ended_);
501 EXPECT_FALSE(recognition_ended_); 512 EXPECT_FALSE(recognition_ended_);
502 recognizer_->AbortRecognition(); 513 recognizer_->AbortRecognition();
503 base::MessageLoop::current()->RunUntilIdle(); 514 base::MessageLoop::current()->RunUntilIdle();
504 CheckFinalEventsConsistency(); 515 CheckFinalEventsConsistency();
505 } 516 }
506 517
507 } // namespace content 518 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698