| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 recognizer_->StopRecording(); | 214 recognizer_->StopRecording(); |
| 215 EXPECT_TRUE(audio_received_); | 215 EXPECT_TRUE(audio_received_); |
| 216 EXPECT_TRUE(recording_complete_); | 216 EXPECT_TRUE(recording_complete_); |
| 217 EXPECT_FALSE(recognition_complete_); | 217 EXPECT_FALSE(recognition_complete_); |
| 218 EXPECT_FALSE(result_received_); | 218 EXPECT_FALSE(result_received_); |
| 219 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); | 219 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); |
| 220 | 220 |
| 221 // Issue the network callback to complete the process. | 221 // Issue the network callback to complete the process. |
| 222 net::URLRequestStatus status; | 222 net::URLRequestStatus status; |
| 223 status.set_status(net::URLRequestStatus::FAILED); | 223 status.set_status(net::URLRequestStatus::FAILED); |
| 224 status.set_os_error(net::ERR_CONNECTION_REFUSED); | 224 status.set_error(net::ERR_CONNECTION_REFUSED); |
| 225 fetcher->delegate()->OnURLFetchComplete( | 225 fetcher->delegate()->OnURLFetchComplete( |
| 226 fetcher, fetcher->original_url(), status, 0, net::ResponseCookies(), ""); | 226 fetcher, fetcher->original_url(), status, 0, net::ResponseCookies(), ""); |
| 227 EXPECT_FALSE(recognition_complete_); | 227 EXPECT_FALSE(recognition_complete_); |
| 228 EXPECT_FALSE(result_received_); | 228 EXPECT_FALSE(result_received_); |
| 229 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_ERROR_NETWORK, error_); | 229 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_ERROR_NETWORK, error_); |
| 230 } | 230 } |
| 231 | 231 |
| 232 TEST_F(SpeechRecognizerTest, ServerError) { | 232 TEST_F(SpeechRecognizerTest, ServerError) { |
| 233 // Start recording, give some data and then stop. Issue the network callback | 233 // Start recording, give some data and then stop. Issue the network callback |
| 234 // with a 500 error and verify that the recognizer bubbles the error up | 234 // with a 500 error and verify that the recognizer bubbles the error up |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 EXPECT_FLOAT_EQ(0.89926866f, volume_); | 390 EXPECT_FLOAT_EQ(0.89926866f, volume_); |
| 391 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); | 391 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); |
| 392 | 392 |
| 393 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); | 393 EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); |
| 394 EXPECT_FALSE(recording_complete_); | 394 EXPECT_FALSE(recording_complete_); |
| 395 EXPECT_FALSE(recognition_complete_); | 395 EXPECT_FALSE(recognition_complete_); |
| 396 recognizer_->CancelRecognition(); | 396 recognizer_->CancelRecognition(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace speech_input | 399 } // namespace speech_input |
| OLD | NEW |