| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 7 #include "content/browser/browser_thread.h" |
| 8 #include "content/browser/speech/speech_recognizer.h" | 8 #include "content/browser/speech/speech_recognizer.h" |
| 9 #include "content/test/test_url_fetcher_factory.h" | 9 #include "content/test/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" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 error_ = error; | 68 error_ = error; |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual void SetInputVolume(int caller_id, float volume, float noise_volume) { | 71 virtual void SetInputVolume(int caller_id, float volume, float noise_volume) { |
| 72 volume_ = volume; | 72 volume_ = volume; |
| 73 noise_volume_ = noise_volume; | 73 noise_volume_ = noise_volume; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // testing::Test methods. | 76 // testing::Test methods. |
| 77 virtual void SetUp() { | 77 virtual void SetUp() { |
| 78 AudioInputController::set_factory_for_testing( | 78 AudioInputController::set_factory(&audio_input_controller_factory_); |
| 79 &audio_input_controller_factory_); | |
| 80 } | 79 } |
| 81 | 80 |
| 82 virtual void TearDown() { | 81 virtual void TearDown() { |
| 83 AudioInputController::set_factory_for_testing(NULL); | 82 AudioInputController::set_factory(NULL); |
| 84 } | 83 } |
| 85 | 84 |
| 86 void FillPacketWithTestWaveform() { | 85 void FillPacketWithTestWaveform() { |
| 87 // Fill the input with a simple pattern, a 125Hz sawtooth waveform. | 86 // Fill the input with a simple pattern, a 125Hz sawtooth waveform. |
| 88 for (size_t i = 0; i < audio_packet_.size(); ++i) | 87 for (size_t i = 0; i < audio_packet_.size(); ++i) |
| 89 audio_packet_[i] = static_cast<uint8>(i); | 88 audio_packet_[i] = static_cast<uint8>(i); |
| 90 } | 89 } |
| 91 | 90 |
| 92 void FillPacketWithNoise() { | 91 void FillPacketWithNoise() { |
| 93 int value = 0; | 92 int value = 0; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 EXPECT_FLOAT_EQ(0.89926866f, volume_); | 389 EXPECT_FLOAT_EQ(0.89926866f, volume_); |
| 391 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); | 390 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); |
| 392 | 391 |
| 393 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); | 392 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); |
| 394 EXPECT_FALSE(recording_complete_); | 393 EXPECT_FALSE(recording_complete_); |
| 395 EXPECT_FALSE(recognition_complete_); | 394 EXPECT_FALSE(recognition_complete_); |
| 396 recognizer_->CancelRecognition(); | 395 recognizer_->CancelRecognition(); |
| 397 } | 396 } |
| 398 | 397 |
| 399 } // namespace speech_input | 398 } // namespace speech_input |
| OLD | NEW |