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

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

Issue 9387023: Revert 121810 - Move SpeechRecognizer delegate into its own header file and put it in the content... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/speech/speech_recognizer.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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/browser_thread_impl.h"
8 #include "content/browser/speech/speech_recognizer.h" 8 #include "content/browser/speech/speech_recognizer.h"
9 #include "content/public/browser/speech_recognizer_delegate.h"
10 #include "content/test/test_url_fetcher_factory.h" 9 #include "content/test/test_url_fetcher_factory.h"
11 #include "media/audio/audio_manager.h" 10 #include "media/audio/audio_manager.h"
12 #include "media/audio/test_audio_input_controller_factory.h" 11 #include "media/audio/test_audio_input_controller_factory.h"
13 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
14 #include "net/url_request/url_request_status.h" 13 #include "net/url_request/url_request_status.h"
15 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
16 15
17 using content::BrowserThread; 16 using content::BrowserThread;
18 using content::BrowserThreadImpl; 17 using content::BrowserThreadImpl;
19 using media::AudioInputController; 18 using media::AudioInputController;
20 using media::TestAudioInputController; 19 using media::TestAudioInputController;
21 using media::TestAudioInputControllerFactory; 20 using media::TestAudioInputControllerFactory;
22 21
23 namespace speech_input { 22 namespace speech_input {
24 23
25 class SpeechRecognizerTest : public content::SpeechRecognizerDelegate, 24 class SpeechRecognizerTest : public SpeechRecognizerDelegate,
26 public testing::Test { 25 public testing::Test {
27 public: 26 public:
28 SpeechRecognizerTest() 27 SpeechRecognizerTest()
29 : io_thread_(BrowserThread::IO, &message_loop_), 28 : io_thread_(BrowserThread::IO, &message_loop_),
30 audio_manager_(AudioManager::Create()), 29 audio_manager_(AudioManager::Create()),
31 recording_complete_(false), 30 recording_complete_(false),
32 recognition_complete_(false), 31 recognition_complete_(false),
33 result_received_(false), 32 result_received_(false),
34 audio_received_(false), 33 audio_received_(false),
35 error_(content::SPEECH_INPUT_ERROR_NONE), 34 error_(content::SPEECH_INPUT_ERROR_NONE),
36 volume_(-1.0f) { 35 volume_(-1.0f) {
37 recognizer_ = new SpeechRecognizer(this, 1, std::string(), std::string(), 36 recognizer_ = new SpeechRecognizer(this, 1, std::string(), std::string(),
38 NULL, audio_manager_, false, 37 NULL, audio_manager_, false,
39 std::string(), std::string()); 38 std::string(), std::string());
40 int audio_packet_length_bytes = 39 int audio_packet_length_bytes =
41 (SpeechRecognizer::kAudioSampleRate * 40 (SpeechRecognizer::kAudioSampleRate *
42 SpeechRecognizer::kAudioPacketIntervalMs * 41 SpeechRecognizer::kAudioPacketIntervalMs *
43 ChannelLayoutToChannelCount(SpeechRecognizer::kChannelLayout) * 42 ChannelLayoutToChannelCount(SpeechRecognizer::kChannelLayout) *
44 SpeechRecognizer::kNumBitsPerAudioSample) / (8 * 1000); 43 SpeechRecognizer::kNumBitsPerAudioSample) / (8 * 1000);
45 audio_packet_.resize(audio_packet_length_bytes); 44 audio_packet_.resize(audio_packet_length_bytes);
46 } 45 }
47 46
48 // Overridden from content::SpeechRecognizerDelegate: 47 // SpeechRecognizer::Delegate methods.
49 virtual void SetRecognitionResult( 48 virtual void SetRecognitionResult(
50 int caller_id, 49 int caller_id,
51 const content::SpeechInputResult& result) OVERRIDE { 50 const content::SpeechInputResult& result) OVERRIDE {
52 result_received_ = true; 51 result_received_ = true;
53 } 52 }
54 53
55 virtual void DidCompleteRecording(int caller_id) OVERRIDE { 54 virtual void DidCompleteRecording(int caller_id) OVERRIDE {
56 recording_complete_ = true; 55 recording_complete_ = true;
57 } 56 }
58 57
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 EXPECT_FLOAT_EQ(0.89926866f, volume_); 413 EXPECT_FLOAT_EQ(0.89926866f, volume_);
415 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); 414 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_);
416 415
417 EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); 416 EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_);
418 EXPECT_FALSE(recording_complete_); 417 EXPECT_FALSE(recording_complete_);
419 EXPECT_FALSE(recognition_complete_); 418 EXPECT_FALSE(recognition_complete_);
420 recognizer_->CancelRecognition(); 419 recognizer_->CancelRecognition();
421 } 420 }
422 421
423 } // namespace speech_input 422 } // namespace speech_input
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognizer.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698