| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 value += factor; | 178 value += factor; |
| 179 audio_packet_[i] = value % 100; | 179 audio_packet_[i] = value % 100; |
| 180 } | 180 } |
| 181 CopyPacketToAudioBus(); | 181 CopyPacketToAudioBus(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 protected: | 184 protected: |
| 185 base::MessageLoopForIO message_loop_; | 185 base::MessageLoopForIO message_loop_; |
| 186 BrowserThreadImpl io_thread_; | 186 BrowserThreadImpl io_thread_; |
| 187 scoped_refptr<SpeechRecognizerImpl> recognizer_; | 187 scoped_refptr<SpeechRecognizerImpl> recognizer_; |
| 188 scoped_ptr<AudioManager> audio_manager_; | 188 std::unique_ptr<AudioManager> audio_manager_; |
| 189 bool recognition_started_; | 189 bool recognition_started_; |
| 190 bool recognition_ended_; | 190 bool recognition_ended_; |
| 191 bool result_received_; | 191 bool result_received_; |
| 192 bool audio_started_; | 192 bool audio_started_; |
| 193 bool audio_ended_; | 193 bool audio_ended_; |
| 194 bool sound_started_; | 194 bool sound_started_; |
| 195 bool sound_ended_; | 195 bool sound_ended_; |
| 196 SpeechRecognitionErrorCode error_; | 196 SpeechRecognitionErrorCode error_; |
| 197 net::TestURLFetcherFactory url_fetcher_factory_; | 197 net::TestURLFetcherFactory url_fetcher_factory_; |
| 198 TestAudioInputControllerFactory audio_input_controller_factory_; | 198 TestAudioInputControllerFactory audio_input_controller_factory_; |
| 199 std::vector<uint8_t> audio_packet_; | 199 std::vector<uint8_t> audio_packet_; |
| 200 scoped_ptr<media::AudioBus> audio_bus_; | 200 std::unique_ptr<media::AudioBus> audio_bus_; |
| 201 int bytes_per_sample_; | 201 int bytes_per_sample_; |
| 202 float volume_; | 202 float volume_; |
| 203 float noise_volume_; | 203 float noise_volume_; |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 TEST_F(SpeechRecognizerImplTest, StopNoData) { | 206 TEST_F(SpeechRecognizerImplTest, StopNoData) { |
| 207 // Check for callbacks when stopping record before any audio gets recorded. | 207 // Check for callbacks when stopping record before any audio gets recorded. |
| 208 recognizer_->StartRecognition(media::AudioManagerBase::kDefaultDeviceId); | 208 recognizer_->StartRecognition(media::AudioManagerBase::kDefaultDeviceId); |
| 209 recognizer_->StopAudioCapture(); | 209 recognizer_->StopAudioCapture(); |
| 210 base::MessageLoop::current()->RunUntilIdle(); | 210 base::MessageLoop::current()->RunUntilIdle(); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 495 |
| 496 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); | 496 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); |
| 497 EXPECT_FALSE(audio_ended_); | 497 EXPECT_FALSE(audio_ended_); |
| 498 EXPECT_FALSE(recognition_ended_); | 498 EXPECT_FALSE(recognition_ended_); |
| 499 recognizer_->AbortRecognition(); | 499 recognizer_->AbortRecognition(); |
| 500 base::MessageLoop::current()->RunUntilIdle(); | 500 base::MessageLoop::current()->RunUntilIdle(); |
| 501 CheckFinalEventsConsistency(); | 501 CheckFinalEventsConsistency(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 } // namespace content | 504 } // namespace content |
| OLD | NEW |