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

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

Issue 10539134: TabContentsWrapper -> TabContents, part 57. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: last use Created 8 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/session_history_browsertest.cc ('k') | content/browser/webkit_browsertest.cc » ('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) 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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // events at that coordinate to trigger speech recognition. 195 // events at that coordinate to trigger speech recognition.
196 GURL test_url = testUrl(filename); 196 GURL test_url = testUrl(filename);
197 ui_test_utils::NavigateToURL(browser(), test_url); 197 ui_test_utils::NavigateToURL(browser(), test_url);
198 198
199 WebKit::WebMouseEvent mouse_event; 199 WebKit::WebMouseEvent mouse_event;
200 mouse_event.type = WebKit::WebInputEvent::MouseDown; 200 mouse_event.type = WebKit::WebInputEvent::MouseDown;
201 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 201 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
202 mouse_event.x = 0; 202 mouse_event.x = 0;
203 mouse_event.y = 0; 203 mouse_event.y = 0;
204 mouse_event.clickCount = 1; 204 mouse_event.clickCount = 1;
205 WebContents* web_contents = browser()->GetSelectedWebContents(); 205 WebContents* web_contents = browser()->GetActiveWebContents();
206 206
207 ui_test_utils::WindowedNotificationObserver observer( 207 ui_test_utils::WindowedNotificationObserver observer(
208 content::NOTIFICATION_LOAD_STOP, 208 content::NOTIFICATION_LOAD_STOP,
209 content::Source<NavigationController>(&web_contents->GetController())); 209 content::Source<NavigationController>(&web_contents->GetController()));
210 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 210 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
211 mouse_event.type = WebKit::WebInputEvent::MouseUp; 211 mouse_event.type = WebKit::WebInputEvent::MouseUp;
212 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 212 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
213 fake_speech_recognition_manager_.recognition_started_event().Wait(); 213 fake_speech_recognition_manager_.recognition_started_event().Wait();
214 214
215 // We should wait for a navigation event, raised by the test page JS code 215 // We should wait for a navigation event, raised by the test page JS code
216 // upon the onwebkitspeechchange event, in all cases except when the 216 // upon the onwebkitspeechchange event, in all cases except when the
217 // speech response is inhibited. 217 // speech response is inhibited.
218 if (fake_speech_recognition_manager_.should_send_fake_response()) 218 if (fake_speech_recognition_manager_.should_send_fake_response())
219 observer.Wait(); 219 observer.Wait();
220 } 220 }
221 221
222 void RunSpeechRecognitionTest(const FilePath::CharType* filename) { 222 void RunSpeechRecognitionTest(const FilePath::CharType* filename) {
223 // The fake speech input manager would receive the speech input 223 // The fake speech input manager would receive the speech input
224 // request and return the test string as recognition result. The test page 224 // request and return the test string as recognition result. The test page
225 // then sets the URL fragment as 'pass' if it received the expected string. 225 // then sets the URL fragment as 'pass' if it received the expected string.
226 LoadAndStartSpeechRecognitionTest(filename); 226 LoadAndStartSpeechRecognitionTest(filename);
227 227
228 EXPECT_EQ("pass", browser()->GetSelectedWebContents()->GetURL().ref()); 228 EXPECT_EQ("pass", browser()->GetActiveWebContents()->GetURL().ref());
229 } 229 }
230 230
231 // InProcessBrowserTest methods. 231 // InProcessBrowserTest methods.
232 virtual void SetUpInProcessBrowserTestFixture() { 232 virtual void SetUpInProcessBrowserTestFixture() {
233 fake_speech_recognition_manager_.set_should_send_fake_response(true); 233 fake_speech_recognition_manager_.set_should_send_fake_response(true);
234 speech_recognition_manager_ = &fake_speech_recognition_manager_; 234 speech_recognition_manager_ = &fake_speech_recognition_manager_;
235 235
236 // Inject the fake manager factory so that the test result is returned to 236 // Inject the fake manager factory so that the test result is returned to
237 // the web page. 237 // the web page.
238 InputTagSpeechDispatcherHost::SetManagerForTests( 238 InputTagSpeechDispatcherHost::SetManagerForTests(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 // Make the renderer crash. This should trigger 286 // Make the renderer crash. This should trigger
287 // InputTagSpeechDispatcherHost to cancel all pending sessions. 287 // InputTagSpeechDispatcherHost to cancel all pending sessions.
288 GURL test_url("about:crash"); 288 GURL test_url("about:crash");
289 ui_test_utils::NavigateToURL(browser(), test_url); 289 ui_test_utils::NavigateToURL(browser(), test_url);
290 290
291 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all()); 291 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all());
292 } 292 }
293 293
294 } // namespace speech 294 } // namespace speech
OLDNEW
« no previous file with comments | « content/browser/session_history_browsertest.cc ('k') | content/browser/webkit_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698