OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 const int channels = | 84 const int channels = |
85 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout); | 85 ChannelLayoutToChannelCount(SpeechRecognizerImpl::kChannelLayout); |
86 bytes_per_sample_ = SpeechRecognizerImpl::kNumBitsPerAudioSample / 8; | 86 bytes_per_sample_ = SpeechRecognizerImpl::kNumBitsPerAudioSample / 8; |
87 const int frames = audio_packet_length_bytes / channels / bytes_per_sample_; | 87 const int frames = audio_packet_length_bytes / channels / bytes_per_sample_; |
88 audio_bus_ = media::AudioBus::Create(channels, frames); | 88 audio_bus_ = media::AudioBus::Create(channels, frames); |
89 audio_bus_->Zero(); | 89 audio_bus_->Zero(); |
90 } | 90 } |
91 | 91 |
92 ~SpeechRecognizerImplTest() override { | 92 ~SpeechRecognizerImplTest() override { |
93 // Deleting |audio_manager_| on audio thread. | 93 // Deleting |audio_manager_| on audio thread. |
| 94 audio_system_.reset(); |
94 audio_manager_.reset(); | 95 audio_manager_.reset(); |
95 audio_thread_.Stop(); | 96 audio_thread_.Stop(); |
96 } | 97 } |
97 | 98 |
98 void CheckEventsConsistency() { | 99 void CheckEventsConsistency() { |
99 // Note: "!x || y" == "x implies y". | 100 // Note: "!x || y" == "x implies y". |
100 EXPECT_TRUE(!recognition_ended_ || recognition_started_); | 101 EXPECT_TRUE(!recognition_ended_ || recognition_started_); |
101 EXPECT_TRUE(!audio_ended_ || audio_started_); | 102 EXPECT_TRUE(!audio_ended_ || audio_started_); |
102 EXPECT_TRUE(!sound_ended_ || sound_started_); | 103 EXPECT_TRUE(!sound_ended_ || sound_started_); |
103 EXPECT_TRUE(!audio_started_ || recognition_started_); | 104 EXPECT_TRUE(!audio_started_ || recognition_started_); |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 | 649 |
649 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); | 650 EXPECT_EQ(SPEECH_RECOGNITION_ERROR_NONE, error_); |
650 EXPECT_FALSE(audio_ended_); | 651 EXPECT_FALSE(audio_ended_); |
651 EXPECT_FALSE(recognition_ended_); | 652 EXPECT_FALSE(recognition_ended_); |
652 recognizer_->AbortRecognition(); | 653 recognizer_->AbortRecognition(); |
653 base::RunLoop().RunUntilIdle(); | 654 base::RunLoop().RunUntilIdle(); |
654 CheckFinalEventsConsistency(); | 655 CheckFinalEventsConsistency(); |
655 } | 656 } |
656 | 657 |
657 } // namespace content | 658 } // namespace content |
OLD | NEW |