OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 SpeechRecognitionEngine* sr_engine = | 47 SpeechRecognitionEngine* sr_engine = |
48 new GoogleOneShotRemoteEngine(NULL /* URLRequestContextGetter */); | 48 new GoogleOneShotRemoteEngine(NULL /* URLRequestContextGetter */); |
49 SpeechRecognitionEngineConfig config; | 49 SpeechRecognitionEngineConfig config; |
50 config.audio_num_bits_per_sample = | 50 config.audio_num_bits_per_sample = |
51 SpeechRecognizerImpl::kNumBitsPerAudioSample; | 51 SpeechRecognizerImpl::kNumBitsPerAudioSample; |
52 config.audio_sample_rate = SpeechRecognizerImpl::kAudioSampleRate; | 52 config.audio_sample_rate = SpeechRecognizerImpl::kAudioSampleRate; |
53 config.filter_profanities = false; | 53 config.filter_profanities = false; |
54 sr_engine->SetConfig(config); | 54 sr_engine->SetConfig(config); |
55 | 55 |
56 const int kTestingSessionId = 1; | 56 const int kTestingSessionId = 1; |
57 const bool kOneShotMode = true; | |
58 recognizer_ = new SpeechRecognizerImpl( | 57 recognizer_ = new SpeechRecognizerImpl( |
59 this, kTestingSessionId, kOneShotMode, sr_engine); | 58 this, kTestingSessionId, false, false, sr_engine); |
60 audio_manager_.reset(new media::MockAudioManager( | 59 audio_manager_.reset(new media::MockAudioManager( |
61 base::MessageLoop::current()->message_loop_proxy().get())); | 60 base::MessageLoop::current()->message_loop_proxy().get())); |
62 recognizer_->SetAudioManagerForTesting(audio_manager_.get()); | 61 recognizer_->SetAudioManagerForTesting(audio_manager_.get()); |
63 | 62 |
64 int audio_packet_length_bytes = | 63 int audio_packet_length_bytes = |
65 (SpeechRecognizerImpl::kAudioSampleRate * | 64 (SpeechRecognizerImpl::kAudioSampleRate * |
66 GoogleOneShotRemoteEngine::kAudioPacketIntervalMs * | 65 GoogleOneShotRemoteEngine::kAudioPacketIntervalMs * |
67 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout) * | 66 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout) * |
68 SpeechRecognizerImpl::kNumBitsPerAudioSample) / (8 * 1000); | 67 SpeechRecognizerImpl::kNumBitsPerAudioSample) / (8 * 1000); |
69 audio_packet_.resize(audio_packet_length_bytes); | 68 audio_packet_.resize(audio_packet_length_bytes); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 489 |
491 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); | 490 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); |
492 EXPECT_FALSE(audio_ended_); | 491 EXPECT_FALSE(audio_ended_); |
493 EXPECT_FALSE(recognition_ended_); | 492 EXPECT_FALSE(recognition_ended_); |
494 recognizer_->AbortRecognition(); | 493 recognizer_->AbortRecognition(); |
495 base::MessageLoop::current()->RunUntilIdle(); | 494 base::MessageLoop::current()->RunUntilIdle(); |
496 CheckFinalEventsConsistency(); | 495 CheckFinalEventsConsistency(); |
497 } | 496 } |
498 | 497 |
499 } // namespace content | 498 } // namespace content |
OLD | NEW |