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

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

Issue 9390007: Move SpeechRecognizer delegate into its own header file and put it in the content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: jam review - update interface comment 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
9 #include "content/test/test_url_fetcher_factory.h" 10 #include "content/test/test_url_fetcher_factory.h"
10 #include "media/audio/audio_manager.h" 11 #include "media/audio/audio_manager.h"
11 #include "media/audio/test_audio_input_controller_factory.h" 12 #include "media/audio/test_audio_input_controller_factory.h"
12 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
13 #include "net/url_request/url_request_status.h" 14 #include "net/url_request/url_request_status.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 using content::BrowserThread; 17 using content::BrowserThread;
17 using content::BrowserThreadImpl; 18 using content::BrowserThreadImpl;
18 using media::AudioInputController; 19 using media::AudioInputController;
19 using media::TestAudioInputController; 20 using media::TestAudioInputController;
20 using media::TestAudioInputControllerFactory; 21 using media::TestAudioInputControllerFactory;
21 22
22 namespace speech_input { 23 namespace speech_input {
23 24
24 class SpeechRecognizerTest : public SpeechRecognizerDelegate, 25 class SpeechRecognizerTest : public content::SpeechRecognizerDelegate,
25 public testing::Test { 26 public testing::Test {
26 public: 27 public:
27 SpeechRecognizerTest() 28 SpeechRecognizerTest()
28 : io_thread_(BrowserThread::IO, &message_loop_), 29 : io_thread_(BrowserThread::IO, &message_loop_),
29 audio_manager_(AudioManager::Create()), 30 audio_manager_(AudioManager::Create()),
30 recording_complete_(false), 31 recording_complete_(false),
31 recognition_complete_(false), 32 recognition_complete_(false),
32 result_received_(false), 33 result_received_(false),
33 audio_received_(false), 34 audio_received_(false),
34 error_(content::SPEECH_INPUT_ERROR_NONE), 35 error_(content::SPEECH_INPUT_ERROR_NONE),
35 volume_(-1.0f) { 36 volume_(-1.0f) {
36 recognizer_ = new SpeechRecognizer(this, 1, std::string(), std::string(), 37 recognizer_ = new SpeechRecognizer(this, 1, std::string(), std::string(),
37 NULL, audio_manager_, false, 38 NULL, audio_manager_, false,
38 std::string(), std::string()); 39 std::string(), std::string());
39 int audio_packet_length_bytes = 40 int audio_packet_length_bytes =
40 (SpeechRecognizer::kAudioSampleRate * 41 (SpeechRecognizer::kAudioSampleRate *
41 SpeechRecognizer::kAudioPacketIntervalMs * 42 SpeechRecognizer::kAudioPacketIntervalMs *
42 ChannelLayoutToChannelCount(SpeechRecognizer::kChannelLayout) * 43 ChannelLayoutToChannelCount(SpeechRecognizer::kChannelLayout) *
43 SpeechRecognizer::kNumBitsPerAudioSample) / (8 * 1000); 44 SpeechRecognizer::kNumBitsPerAudioSample) / (8 * 1000);
44 audio_packet_.resize(audio_packet_length_bytes); 45 audio_packet_.resize(audio_packet_length_bytes);
45 } 46 }
46 47
47 // SpeechRecognizer::Delegate methods. 48 // Overridden from content::SpeechRecognizerDelegate:
48 virtual void SetRecognitionResult( 49 virtual void SetRecognitionResult(
49 int caller_id, 50 int caller_id,
50 const content::SpeechInputResult& result) OVERRIDE { 51 const content::SpeechInputResult& result) OVERRIDE {
51 result_received_ = true; 52 result_received_ = true;
52 } 53 }
53 54
54 virtual void DidCompleteRecording(int caller_id) OVERRIDE { 55 virtual void DidCompleteRecording(int caller_id) OVERRIDE {
55 recording_complete_ = true; 56 recording_complete_ = true;
56 } 57 }
57 58
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 EXPECT_FLOAT_EQ(0.89926866f, volume_); 414 EXPECT_FLOAT_EQ(0.89926866f, volume_);
414 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_); 415 EXPECT_FLOAT_EQ(0.75071919f, noise_volume_);
415 416
416 EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_); 417 EXPECT_EQ(content::SPEECH_INPUT_ERROR_NONE, error_);
417 EXPECT_FALSE(recording_complete_); 418 EXPECT_FALSE(recording_complete_);
418 EXPECT_FALSE(recognition_complete_); 419 EXPECT_FALSE(recognition_complete_);
419 recognizer_->CancelRecognition(); 420 recognizer_->CancelRecognition();
420 } 421 }
421 422
422 } // namespace speech_input 423 } // 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