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

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

Issue 1159623009: content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test build fix. Created 5 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <list> 5 #include <list>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/single_thread_task_runner.h"
10 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/thread_task_runner_handle.h"
11 #include "content/browser/speech/google_streaming_remote_engine.h" 14 #include "content/browser/speech/google_streaming_remote_engine.h"
12 #include "content/browser/speech/speech_recognition_manager_impl.h" 15 #include "content/browser/speech/speech_recognition_manager_impl.h"
13 #include "content/browser/speech/speech_recognizer_impl.h" 16 #include "content/browser/speech/speech_recognizer_impl.h"
14 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
17 #include "content/public/test/browser_test_utils.h" 20 #include "content/public/test/browser_test_utils.h"
18 #include "content/public/test/content_browser_test.h" 21 #include "content/public/test/content_browser_test.h"
19 #include "content/public/test/content_browser_test_utils.h" 22 #include "content/public/test/content_browser_test_utils.h"
20 #include "content/public/test/test_utils.h" 23 #include "content/public/test/test_utils.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const size_t buffer_size = audio_params.GetBytesPerBuffer(); 162 const size_t buffer_size = audio_params.GetBytesPerBuffer();
160 const int ms_per_buffer = audio_params.frames_per_buffer() * 1000 / 163 const int ms_per_buffer = audio_params.frames_per_buffer() * 1000 /
161 audio_params.sample_rate(); 164 audio_params.sample_rate();
162 // We can only simulate durations that are integer multiples of the 165 // We can only simulate durations that are integer multiples of the
163 // buffer size. In this regard see 166 // buffer size. In this regard see
164 // SpeechRecognitionEngine::GetDesiredAudioChunkDurationMs(). 167 // SpeechRecognitionEngine::GetDesiredAudioChunkDurationMs().
165 ASSERT_EQ(0, duration_ms % ms_per_buffer); 168 ASSERT_EQ(0, duration_ms % ms_per_buffer);
166 169
167 const int n_buffers = duration_ms / ms_per_buffer; 170 const int n_buffers = duration_ms / ms_per_buffer;
168 for (int i = 0; i < n_buffers; ++i) { 171 for (int i = 0; i < n_buffers; ++i) {
169 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 172 base::ThreadTaskRunnerHandle::Get()->PostTask(
170 &FeedSingleBufferToAudioController, 173 FROM_HERE,
171 scoped_refptr<media::TestAudioInputController>(controller), 174 base::Bind(&FeedSingleBufferToAudioController,
172 buffer_size, 175 scoped_refptr<media::TestAudioInputController>(controller),
173 feed_with_noise)); 176 buffer_size, feed_with_noise));
174 } 177 }
175 } 178 }
176 179
177 SpeechRecognitionResult GetGoodSpeechResult() { 180 SpeechRecognitionResult GetGoodSpeechResult() {
178 SpeechRecognitionResult result; 181 SpeechRecognitionResult result;
179 result.hypotheses.push_back(SpeechRecognitionHypothesis( 182 result.hypotheses.push_back(SpeechRecognitionHypothesis(
180 base::UTF8ToUTF16("Pictures of the moon"), 1.0F)); 183 base::UTF8ToUTF16("Pictures of the moon"), 1.0F));
181 return result; 184 return result;
182 } 185 }
183 186
(...skipping 15 matching lines...) Expand all
199 202
200 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) { 203 IN_PROC_BROWSER_TEST_F(SpeechRecognitionBrowserTest, OneShotRecognition) {
201 NavigateToURLBlockUntilNavigationsComplete( 204 NavigateToURLBlockUntilNavigationsComplete(
202 shell(), GetTestUrlFromFragment("oneshot"), 2); 205 shell(), GetTestUrlFromFragment("oneshot"), 2);
203 206
204 EXPECT_EQ(kClientDisconnected, streaming_server_state()); 207 EXPECT_EQ(kClientDisconnected, streaming_server_state());
205 EXPECT_EQ("goodresult1", GetPageFragment()); 208 EXPECT_EQ("goodresult1", GetPageFragment());
206 } 209 }
207 210
208 } // namespace content 211 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_per_process_browsertest.cc ('k') | content/browser/speech/speech_recognition_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698