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

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

Issue 1075443004: Rename from ERROR_AUDIO to ERROR_AUDIO_CAPTURE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 base::MessageLoop::current()->RunUntilIdle(); 373 base::MessageLoop::current()->RunUntilIdle();
374 TestAudioInputController* controller = 374 TestAudioInputController* controller =
375 audio_input_controller_factory_.controller(); 375 audio_input_controller_factory_.controller();
376 ASSERT_TRUE(controller); 376 ASSERT_TRUE(controller);
377 controller->event_handler()->OnError(controller, 377 controller->event_handler()->OnError(controller,
378 AudioInputController::UNKNOWN_ERROR); 378 AudioInputController::UNKNOWN_ERROR);
379 base::MessageLoop::current()->RunUntilIdle(); 379 base::MessageLoop::current()->RunUntilIdle();
380 EXPECT_TRUE(recognition_started_); 380 EXPECT_TRUE(recognition_started_);
381 EXPECT_FALSE(audio_started_); 381 EXPECT_FALSE(audio_started_);
382 EXPECT_FALSE(result_received_); 382 EXPECT_FALSE(result_received_);
383 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_AUDIO, error_); 383 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_AUDIO_CAPTURE, error_);
384 CheckFinalEventsConsistency(); 384 CheckFinalEventsConsistency();
385 } 385 }
386 386
387 TEST_F(SpeechRecognizerImplTest, AudioControllerErrorWithData) { 387 TEST_F(SpeechRecognizerImplTest, AudioControllerErrorWithData) {
388 // Check if things tear down properly if AudioInputController threw an error 388 // Check if things tear down properly if AudioInputController threw an error
389 // after giving some audio data. 389 // after giving some audio data.
390 recognizer_->StartRecognition(media::AudioManagerBase::kDefaultDeviceId); 390 recognizer_->StartRecognition(media::AudioManagerBase::kDefaultDeviceId);
391 base::MessageLoop::current()->RunUntilIdle(); 391 base::MessageLoop::current()->RunUntilIdle();
392 TestAudioInputController* controller = 392 TestAudioInputController* controller =
393 audio_input_controller_factory_.controller(); 393 audio_input_controller_factory_.controller();
394 ASSERT_TRUE(controller); 394 ASSERT_TRUE(controller);
395 controller->event_handler()->OnData(controller, audio_bus_.get()); 395 controller->event_handler()->OnData(controller, audio_bus_.get());
396 controller->event_handler()->OnError(controller, 396 controller->event_handler()->OnError(controller,
397 AudioInputController::UNKNOWN_ERROR); 397 AudioInputController::UNKNOWN_ERROR);
398 base::MessageLoop::current()->RunUntilIdle(); 398 base::MessageLoop::current()->RunUntilIdle();
399 ASSERT_TRUE(url_fetcher_factory_.GetFetcherByID(0)); 399 ASSERT_TRUE(url_fetcher_factory_.GetFetcherByID(0));
400 EXPECT_TRUE(recognition_started_); 400 EXPECT_TRUE(recognition_started_);
401 EXPECT_TRUE(audio_started_); 401 EXPECT_TRUE(audio_started_);
402 EXPECT_FALSE(result_received_); 402 EXPECT_FALSE(result_received_);
403 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_AUDIO, error_); 403 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_AUDIO_CAPTURE, error_);
404 CheckFinalEventsConsistency(); 404 CheckFinalEventsConsistency();
405 } 405 }
406 406
407 TEST_F(SpeechRecognizerImplTest, NoSpeechCallbackIssued) { 407 TEST_F(SpeechRecognizerImplTest, NoSpeechCallbackIssued) {
408 // Start recording and give a lot of packets with audio samples set to zero. 408 // Start recording and give a lot of packets with audio samples set to zero.
409 // This should trigger the no-speech detector and issue a callback. 409 // This should trigger the no-speech detector and issue a callback.
410 recognizer_->StartRecognition(media::AudioManagerBase::kDefaultDeviceId); 410 recognizer_->StartRecognition(media::AudioManagerBase::kDefaultDeviceId);
411 base::MessageLoop::current()->RunUntilIdle(); 411 base::MessageLoop::current()->RunUntilIdle();
412 TestAudioInputController* controller = 412 TestAudioInputController* controller =
413 audio_input_controller_factory_.controller(); 413 audio_input_controller_factory_.controller();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); 500 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_);
501 EXPECT_FALSE(audio_ended_); 501 EXPECT_FALSE(audio_ended_);
502 EXPECT_FALSE(recognition_ended_); 502 EXPECT_FALSE(recognition_ended_);
503 recognizer_->AbortRecognition(); 503 recognizer_->AbortRecognition();
504 base::MessageLoop::current()->RunUntilIdle(); 504 base::MessageLoop::current()->RunUntilIdle();
505 CheckFinalEventsConsistency(); 505 CheckFinalEventsConsistency();
506 } 506 }
507 507
508 } // namespace content 508 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698