Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Side by Side Diff: content/browser/speech/speech_recognizer_impl_unittest.cc

Issue 1164823002: Remove URLRequestStatus mutators and introduce FromError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <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_impl.h" 9 #include "content/browser/speech/speech_recognizer_impl.h"
10 #include "content/public/browser/speech_recognition_event_listener.h" 10 #include "content/public/browser/speech_recognition_event_listener.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 EXPECT_TRUE(audio_ended_); 254 EXPECT_TRUE(audio_ended_);
255 EXPECT_FALSE(recognition_ended_); 255 EXPECT_FALSE(recognition_ended_);
256 EXPECT_FALSE(result_received_); 256 EXPECT_FALSE(result_received_);
257 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 257 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
258 258
259 // Issue the network callback to complete the process. 259 // Issue the network callback to complete the process.
260 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 260 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
261 ASSERT_TRUE(fetcher); 261 ASSERT_TRUE(fetcher);
262 262
263 fetcher->set_url(fetcher->GetOriginalURL()); 263 fetcher->set_url(fetcher->GetOriginalURL());
264 net::URLRequestStatus status; 264 fetcher->set_status(net::URLRequestStatus());
265 status.set_status(net::URLRequestStatus::SUCCESS);
266 fetcher->set_status(status);
267 fetcher->set_response_code(200); 265 fetcher->set_response_code(200);
268 fetcher->SetResponseString( 266 fetcher->SetResponseString(
269 "{\"status\":0,\"hypotheses\":[{\"utterance\":\"123\"}]}"); 267 "{\"status\":0,\"hypotheses\":[{\"utterance\":\"123\"}]}");
270 fetcher->delegate()->OnURLFetchComplete(fetcher); 268 fetcher->delegate()->OnURLFetchComplete(fetcher);
271 base::MessageLoop::current()->RunUntilIdle(); 269 base::MessageLoop::current()->RunUntilIdle();
272 EXPECT_TRUE(recognition_ended_); 270 EXPECT_TRUE(recognition_ended_);
273 EXPECT_TRUE(result_received_); 271 EXPECT_TRUE(result_received_);
274 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 272 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
275 CheckFinalEventsConsistency(); 273 CheckFinalEventsConsistency();
276 } 274 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 recognizer_->StopAudioCapture(); 308 recognizer_->StopAudioCapture();
311 base::MessageLoop::current()->RunUntilIdle(); 309 base::MessageLoop::current()->RunUntilIdle();
312 EXPECT_TRUE(audio_started_); 310 EXPECT_TRUE(audio_started_);
313 EXPECT_TRUE(audio_ended_); 311 EXPECT_TRUE(audio_ended_);
314 EXPECT_FALSE(recognition_ended_); 312 EXPECT_FALSE(recognition_ended_);
315 EXPECT_FALSE(result_received_); 313 EXPECT_FALSE(result_received_);
316 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 314 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
317 315
318 // Issue the network callback to complete the process. 316 // Issue the network callback to complete the process.
319 fetcher->set_url(fetcher->GetOriginalURL()); 317 fetcher->set_url(fetcher->GetOriginalURL());
320 net::URLRequestStatus status; 318 fetcher->set_status(
321 status.set_status(net::URLRequestStatus::FAILED); 319 net::URLRequestStatus::FromError(net::ERR_CONNECTION_REFUSED));
322 status.set_error(net::ERR_CONNECTION_REFUSED);
323 fetcher->set_status(status);
324 fetcher->set_response_code(0); 320 fetcher->set_response_code(0);
325 fetcher->SetResponseString(std::string()); 321 fetcher->SetResponseString(std::string());
326 fetcher->delegate()->OnURLFetchComplete(fetcher); 322 fetcher->delegate()->OnURLFetchComplete(fetcher);
327 base::MessageLoop::current()->RunUntilIdle(); 323 base::MessageLoop::current()->RunUntilIdle();
328 EXPECT_TRUE(recognition_ended_); 324 EXPECT_TRUE(recognition_ended_);
329 EXPECT_FALSE(result_received_); 325 EXPECT_FALSE(result_received_);
330 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NETWORK, error_); 326 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NETWORK, error_);
331 CheckFinalEventsConsistency(); 327 CheckFinalEventsConsistency();
332 } 328 }
333 329
(...skipping 13 matching lines...) Expand all
347 recognizer_->StopAudioCapture(); 343 recognizer_->StopAudioCapture();
348 base::MessageLoop::current()->RunUntilIdle(); 344 base::MessageLoop::current()->RunUntilIdle();
349 EXPECT_TRUE(audio_started_); 345 EXPECT_TRUE(audio_started_);
350 EXPECT_TRUE(audio_ended_); 346 EXPECT_TRUE(audio_ended_);
351 EXPECT_FALSE(recognition_ended_); 347 EXPECT_FALSE(recognition_ended_);
352 EXPECT_FALSE(result_received_); 348 EXPECT_FALSE(result_received_);
353 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 349 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
354 350
355 // Issue the network callback to complete the process. 351 // Issue the network callback to complete the process.
356 fetcher->set_url(fetcher->GetOriginalURL()); 352 fetcher->set_url(fetcher->GetOriginalURL());
357 net::URLRequestStatus status; 353 fetcher->set_status(net::URLRequestStatus());
358 status.set_status(net::URLRequestStatus::SUCCESS);
359 fetcher->set_status(status);
360 fetcher->set_response_code(500); 354 fetcher->set_response_code(500);
361 fetcher->SetResponseString("Internal Server Error"); 355 fetcher->SetResponseString("Internal Server Error");
362 fetcher->delegate()->OnURLFetchComplete(fetcher); 356 fetcher->delegate()->OnURLFetchComplete(fetcher);
363 base::MessageLoop::current()->RunUntilIdle(); 357 base::MessageLoop::current()->RunUntilIdle();
364 EXPECT_TRUE(recognition_ended_); 358 EXPECT_TRUE(recognition_ended_);
365 EXPECT_FALSE(result_received_); 359 EXPECT_FALSE(result_received_);
366 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NETWORK, error_); 360 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NETWORK, error_);
367 CheckFinalEventsConsistency(); 361 CheckFinalEventsConsistency();
368 } 362 }
369 363
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 493
500 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 494 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
501 EXPECT_FALSE(audio_ended_); 495 EXPECT_FALSE(audio_ended_);
502 EXPECT_FALSE(recognition_ended_); 496 EXPECT_FALSE(recognition_ended_);
503 recognizer_->AbortRecognition(); 497 recognizer_->AbortRecognition();
504 base::MessageLoop::current()->RunUntilIdle(); 498 base::MessageLoop::current()->RunUntilIdle();
505 CheckFinalEventsConsistency(); 499 CheckFinalEventsConsistency();
506 } 500 }
507 501
508 } // namespace content 502 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698