| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/browser_thread.h" | 7 #include "chrome/browser/browser_thread.h" |
| 8 #include "chrome/browser/speech/speech_recognizer.h" | 8 #include "chrome/browser/speech/speech_recognizer.h" |
| 9 #include "chrome/common/net/test_url_fetcher_factory.h" | 9 #include "chrome/common/net/test_url_fetcher_factory.h" |
| 10 #include "media/audio/test_audio_input_controller_factory.h" | 10 #include "media/audio/test_audio_input_controller_factory.h" |
| 11 #include "net/url_request/url_request_status.h" | 11 #include "net/url_request/url_request_status.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using media::AudioInputController; | 14 using media::AudioInputController; |
| 15 using media::TestAudioInputController; | 15 using media::TestAudioInputController; |
| 16 using media::TestAudioInputControllerFactory; | 16 using media::TestAudioInputControllerFactory; |
| 17 | 17 |
| 18 namespace speech_input { | 18 namespace speech_input { |
| 19 | 19 |
| 20 class SpeechRecognizerTest : public SpeechRecognizerDelegate, | 20 class SpeechRecognizerTest : public SpeechRecognizerDelegate, |
| 21 public testing::Test { | 21 public testing::Test { |
| 22 public: | 22 public: |
| 23 SpeechRecognizerTest() | 23 SpeechRecognizerTest() |
| 24 : io_thread_(BrowserThread::IO, &message_loop_), | 24 : io_thread_(BrowserThread::IO, &message_loop_), |
| 25 ALLOW_THIS_IN_INITIALIZER_LIST( | 25 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 26 recognizer_(new SpeechRecognizer(this, 1, std::string()))), | 26 recognizer_(new SpeechRecognizer(this, 1, std::string(), |
| 27 std::string()))), |
| 27 recording_complete_(false), | 28 recording_complete_(false), |
| 28 recognition_complete_(false), | 29 recognition_complete_(false), |
| 29 result_received_(false), | 30 result_received_(false), |
| 30 error_(SpeechRecognizer::RECOGNIZER_NO_ERROR), | 31 error_(SpeechRecognizer::RECOGNIZER_NO_ERROR), |
| 31 volume_(-1.0f) { | 32 volume_(-1.0f) { |
| 32 int audio_packet_length_bytes = | 33 int audio_packet_length_bytes = |
| 33 (SpeechRecognizer::kAudioSampleRate * | 34 (SpeechRecognizer::kAudioSampleRate * |
| 34 SpeechRecognizer::kAudioPacketIntervalMs * | 35 SpeechRecognizer::kAudioPacketIntervalMs * |
| 35 SpeechRecognizer::kNumAudioChannels * | 36 SpeechRecognizer::kNumAudioChannels * |
| 36 SpeechRecognizer::kNumBitsPerAudioSample) / (8 * 1000); | 37 SpeechRecognizer::kNumBitsPerAudioSample) / (8 * 1000); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 MessageLoop::current()->RunAllPending(); | 294 MessageLoop::current()->RunAllPending(); |
| 294 EXPECT_FLOAT_EQ(0.9f, volume_); | 295 EXPECT_FLOAT_EQ(0.9f, volume_); |
| 295 | 296 |
| 296 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); | 297 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); |
| 297 EXPECT_FALSE(recording_complete_); | 298 EXPECT_FALSE(recording_complete_); |
| 298 EXPECT_FALSE(recognition_complete_); | 299 EXPECT_FALSE(recognition_complete_); |
| 299 recognizer_->CancelRecognition(); | 300 recognizer_->CancelRecognition(); |
| 300 } | 301 } |
| 301 | 302 |
| 302 } // namespace speech_input | 303 } // namespace speech_input |
| OLD | NEW |