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_impl.h" |
7 #include "content/browser/speech/speech_recognizer.h" | 8 #include "content/browser/speech/speech_recognizer.h" |
8 #include "content/test/test_browser_thread.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" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/url_request/url_request_status.h" | 12 #include "net/url_request/url_request_status.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
| 15 using content::BrowserThreadImpl; |
| 16 |
15 using media::AudioInputController; | 17 using media::AudioInputController; |
16 using media::TestAudioInputController; | 18 using media::TestAudioInputController; |
17 using media::TestAudioInputControllerFactory; | 19 using media::TestAudioInputControllerFactory; |
18 | 20 |
19 namespace speech_input { | 21 namespace speech_input { |
20 | 22 |
21 class SpeechRecognizerTest : public SpeechRecognizerDelegate, | 23 class SpeechRecognizerTest : public SpeechRecognizerDelegate, |
22 public testing::Test { | 24 public testing::Test { |
23 public: | 25 public: |
24 SpeechRecognizerTest() | 26 SpeechRecognizerTest() |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 int value = 0; | 101 int value = 0; |
100 int factor = 175; | 102 int factor = 175; |
101 for (size_t i = 0; i < audio_packet_.size(); ++i) { | 103 for (size_t i = 0; i < audio_packet_.size(); ++i) { |
102 value += factor; | 104 value += factor; |
103 audio_packet_[i] = value % 100; | 105 audio_packet_[i] = value % 100; |
104 } | 106 } |
105 } | 107 } |
106 | 108 |
107 protected: | 109 protected: |
108 MessageLoopForIO message_loop_; | 110 MessageLoopForIO message_loop_; |
109 content::TestBrowserThread io_thread_; | 111 BrowserThreadImpl io_thread_; |
110 scoped_refptr<SpeechRecognizer> recognizer_; | 112 scoped_refptr<SpeechRecognizer> recognizer_; |
111 bool recording_complete_; | 113 bool recording_complete_; |
112 bool recognition_complete_; | 114 bool recognition_complete_; |
113 bool result_received_; | 115 bool result_received_; |
114 bool audio_received_; | 116 bool audio_received_; |
115 SpeechInputError error_; | 117 SpeechInputError error_; |
116 TestURLFetcherFactory url_fetcher_factory_; | 118 TestURLFetcherFactory url_fetcher_factory_; |
117 TestAudioInputControllerFactory audio_input_controller_factory_; | 119 TestAudioInputControllerFactory audio_input_controller_factory_; |
118 std::vector<uint8> audio_packet_; | 120 std::vector<uint8> audio_packet_; |
119 float volume_; | 121 float volume_; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 EXPECT_FLOAT_EQ(0.89926866f, volume_); | 410 EXPECT_FLOAT_EQ(0.89926866f, volume_); |
409 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); | 411 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); |
410 | 412 |
411 EXPECT_EQ(kErrorNone, error_); | 413 EXPECT_EQ(kErrorNone, error_); |
412 EXPECT_FALSE(recording_complete_); | 414 EXPECT_FALSE(recording_complete_); |
413 EXPECT_FALSE(recognition_complete_); | 415 EXPECT_FALSE(recognition_complete_); |
414 recognizer_->CancelRecognition(); | 416 recognizer_->CancelRecognition(); |
415 } | 417 } |
416 | 418 |
417 } // namespace speech_input | 419 } // namespace speech_input |
OLD | NEW |