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

Side by Side Diff: chrome/browser/speech/speech_input_extension_apitest.cc

Issue 9433006: Remove GetAudioManager and GetMediaStreamManager from ResourceContext. The reason is the content mo… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments 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
OLDNEW
1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/speech/speech_input_extension_api.h" 10 #include "chrome/browser/speech/speech_input_extension_api.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Used as delay when the corresponding call should not be dispatched. 48 // Used as delay when the corresponding call should not be dispatched.
49 static const int kDontDispatchCall = -1; 49 static const int kDontDispatchCall = -1;
50 50
51 // ExtensionApiTest methods. 51 // ExtensionApiTest methods.
52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
53 ExtensionApiTest::SetUpCommandLine(command_line); 53 ExtensionApiTest::SetUpCommandLine(command_line);
54 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 54 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
55 } 55 }
56 56
57 // SpeechInputExtensionInterface methods. 57 // SpeechInputExtensionInterface methods.
58 virtual bool HasAudioInputDevices( 58 virtual bool HasAudioInputDevices() OVERRIDE {
59 content::ResourceContext* resource_context) OVERRIDE {
60 return recording_devices_available_; 59 return recording_devices_available_;
61 } 60 }
62 61
63 virtual bool IsRecordingInProcess( 62 virtual bool IsRecordingInProcess() OVERRIDE {
64 content::ResourceContext* resource_context) OVERRIDE {
65 // Only the mock recognizer is supposed to be recording during testing. 63 // Only the mock recognizer is supposed to be recording during testing.
66 return HasValidRecognizer(); 64 return HasValidRecognizer();
67 } 65 }
68 66
69 virtual bool HasValidRecognizer() OVERRIDE { 67 virtual bool HasValidRecognizer() OVERRIDE {
70 return recognizer_is_valid_; 68 return recognizer_is_valid_;
71 } 69 }
72 70
73 virtual void StartRecording( 71 virtual void StartRecording(
74 content::SpeechRecognizerDelegate* delegate, 72 content::SpeechRecognizerDelegate* delegate,
75 net::URLRequestContextGetter* context_getter, 73 net::URLRequestContextGetter* context_getter,
76 content::ResourceContext* resource_context,
77 int caller_id, 74 int caller_id,
78 const std::string& language, 75 const std::string& language,
79 const std::string& grammar, 76 const std::string& grammar,
80 bool filter_profanities) OVERRIDE; 77 bool filter_profanities) OVERRIDE;
81 78
82 virtual void StopRecording(bool recognition_failed) OVERRIDE; 79 virtual void StopRecording(bool recognition_failed) OVERRIDE;
83 80
84 SpeechInputExtensionManager* GetManager() { 81 SpeechInputExtensionManager* GetManager() {
85 return SpeechInputExtensionManager::GetForProfile(browser()->profile()); 82 return SpeechInputExtensionManager::GetForProfile(browser()->profile());
86 } 83 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 next_error_(content::SPEECH_INPUT_ERROR_NONE), 116 next_error_(content::SPEECH_INPUT_ERROR_NONE),
120 result_delay_ms_(0) { 117 result_delay_ms_(0) {
121 } 118 }
122 119
123 SpeechInputExtensionApiTest::~SpeechInputExtensionApiTest() { 120 SpeechInputExtensionApiTest::~SpeechInputExtensionApiTest() {
124 } 121 }
125 122
126 void SpeechInputExtensionApiTest::StartRecording( 123 void SpeechInputExtensionApiTest::StartRecording(
127 content::SpeechRecognizerDelegate* delegate, 124 content::SpeechRecognizerDelegate* delegate,
128 net::URLRequestContextGetter* context_getter, 125 net::URLRequestContextGetter* context_getter,
129 content::ResourceContext* resource_context,
130 int caller_id, 126 int caller_id,
131 const std::string& language, 127 const std::string& language,
132 const std::string& grammar, 128 const std::string& grammar,
133 bool filter_profanities) { 129 bool filter_profanities) {
134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 130 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
135 recognizer_is_valid_ = true; 131 recognizer_is_valid_ = true;
136 132
137 // Notify that recording started. 133 // Notify that recording started.
138 MessageLoop::current()->PostDelayedTask(FROM_HERE, 134 MessageLoop::current()->PostDelayedTask(FROM_HERE,
139 base::Bind(&SpeechInputExtensionManager::DidStartReceivingAudio, 135 base::Bind(&SpeechInputExtensionManager::DidStartReceivingAudio,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 SetRecognitionResult(result); 189 SetRecognitionResult(result);
194 ASSERT_TRUE(RunExtensionTest("speech_input/recognition")) << message_; 190 ASSERT_TRUE(RunExtensionTest("speech_input/recognition")) << message_;
195 } 191 }
196 192
197 IN_PROC_BROWSER_TEST_F(SpeechInputExtensionApiTest, RecognitionError) { 193 IN_PROC_BROWSER_TEST_F(SpeechInputExtensionApiTest, RecognitionError) {
198 AutoManagerHook hook(this); 194 AutoManagerHook hook(this);
199 195
200 SetRecognitionError(content::SPEECH_INPUT_ERROR_NETWORK); 196 SetRecognitionError(content::SPEECH_INPUT_ERROR_NETWORK);
201 ASSERT_TRUE(RunExtensionTest("speech_input/recognition_error")) << message_; 197 ASSERT_TRUE(RunExtensionTest("speech_input/recognition_error")) << message_;
202 } 198 }
OLDNEW
« no previous file with comments | « chrome/browser/speech/speech_input_bubble_views.cc ('k') | chrome/browser/speech/speech_input_extension_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698