OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 9 #include "content/browser/speech/speech_recognizer.h" |
10 #include "content/public/browser/speech_recognition_event_listener.h" | 10 #include "content/public/browser/speech_recognition_event_listener.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 EXPECT_FALSE(result_received_); | 298 EXPECT_FALSE(result_received_); |
299 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); | 299 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); |
300 | 300 |
301 // Issue the network callback to complete the process. | 301 // Issue the network callback to complete the process. |
302 fetcher->set_url(fetcher->GetOriginalURL()); | 302 fetcher->set_url(fetcher->GetOriginalURL()); |
303 net::URLRequestStatus status; | 303 net::URLRequestStatus status; |
304 status.set_status(net::URLRequestStatus::FAILED); | 304 status.set_status(net::URLRequestStatus::FAILED); |
305 status.set_error(net::ERR_CONNECTION_REFUSED); | 305 status.set_error(net::ERR_CONNECTION_REFUSED); |
306 fetcher->set_status(status); | 306 fetcher->set_status(status); |
307 fetcher->set_response_code(0); | 307 fetcher->set_response_code(0); |
308 fetcher->SetResponseString(""); | 308 fetcher->SetResponseString(std::string()); |
309 fetcher->delegate()->OnURLFetchComplete(fetcher); | 309 fetcher->delegate()->OnURLFetchComplete(fetcher); |
310 MessageLoop::current()->RunUntilIdle(); | 310 MessageLoop::current()->RunUntilIdle(); |
311 EXPECT_TRUE(recognition_ended_); | 311 EXPECT_TRUE(recognition_ended_); |
312 EXPECT_FALSE(result_received_); | 312 EXPECT_FALSE(result_received_); |
313 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NETWORK, error_); | 313 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NETWORK, error_); |
314 CheckFinalEventsConsistency(); | 314 CheckFinalEventsConsistency(); |
315 } | 315 } |
316 | 316 |
317 TEST_F(SpeechRecognizerTest, ServerError) { | 317 TEST_F(SpeechRecognizerTest, ServerError) { |
318 // Start recording, give some data and then stop. Issue the network callback | 318 // Start recording, give some data and then stop. Issue the network callback |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 488 |
489 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); | 489 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); |
490 EXPECT_FALSE(audio_ended_); | 490 EXPECT_FALSE(audio_ended_); |
491 EXPECT_FALSE(recognition_ended_); | 491 EXPECT_FALSE(recognition_ended_); |
492 recognizer_->AbortRecognition(); | 492 recognizer_->AbortRecognition(); |
493 MessageLoop::current()->RunUntilIdle(); | 493 MessageLoop::current()->RunUntilIdle(); |
494 CheckFinalEventsConsistency(); | 494 CheckFinalEventsConsistency(); |
495 } | 495 } |
496 | 496 |
497 } // namespace content | 497 } // namespace content |
OLD | NEW |