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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
16 #include "content/browser/speech/input_tag_speech_dispatcher_host.h" 17 #include "content/browser/speech/input_tag_speech_dispatcher_host.h"
17 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
18 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/speech_recognition_manager.h" 20 #include "content/public/browser/speech_recognition_manager.h"
20 #include "content/public/browser/speech_recognition_session_config.h" 21 #include "content/public/browser/speech_recognition_session_config.h"
21 #include "content/public/browser/speech_recognition_session_context.h" 22 #include "content/public/browser/speech_recognition_session_context.h"
22 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // events at that coordinate to trigger speech recognition. 196 // events at that coordinate to trigger speech recognition.
196 GURL test_url = testUrl(filename); 197 GURL test_url = testUrl(filename);
197 ui_test_utils::NavigateToURL(browser(), test_url); 198 ui_test_utils::NavigateToURL(browser(), test_url);
198 199
199 WebKit::WebMouseEvent mouse_event; 200 WebKit::WebMouseEvent mouse_event;
200 mouse_event.type = WebKit::WebInputEvent::MouseDown; 201 mouse_event.type = WebKit::WebInputEvent::MouseDown;
201 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 202 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
202 mouse_event.x = 0; 203 mouse_event.x = 0;
203 mouse_event.y = 0; 204 mouse_event.y = 0;
204 mouse_event.clickCount = 1; 205 mouse_event.clickCount = 1;
205 WebContents* web_contents = browser()->GetActiveWebContents(); 206 WebContents* web_contents = chrome::GetActiveWebContents(browser());
206 207
207 ui_test_utils::WindowedNotificationObserver observer( 208 ui_test_utils::WindowedNotificationObserver observer(
208 content::NOTIFICATION_LOAD_STOP, 209 content::NOTIFICATION_LOAD_STOP,
209 content::Source<NavigationController>(&web_contents->GetController())); 210 content::Source<NavigationController>(&web_contents->GetController()));
210 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 211 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
211 mouse_event.type = WebKit::WebInputEvent::MouseUp; 212 mouse_event.type = WebKit::WebInputEvent::MouseUp;
212 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 213 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
213 fake_speech_recognition_manager_.recognition_started_event().Wait(); 214 fake_speech_recognition_manager_.recognition_started_event().Wait();
214 215
215 // We should wait for a navigation event, raised by the test page JS code 216 // 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 217 // upon the onwebkitspeechchange event, in all cases except when the
217 // speech response is inhibited. 218 // speech response is inhibited.
218 if (fake_speech_recognition_manager_.should_send_fake_response()) 219 if (fake_speech_recognition_manager_.should_send_fake_response())
219 observer.Wait(); 220 observer.Wait();
220 } 221 }
221 222
222 void RunSpeechRecognitionTest(const FilePath::CharType* filename) { 223 void RunSpeechRecognitionTest(const FilePath::CharType* filename) {
223 // The fake speech input manager would receive the speech input 224 // The fake speech input manager would receive the speech input
224 // request and return the test string as recognition result. The test page 225 // 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. 226 // then sets the URL fragment as 'pass' if it received the expected string.
226 LoadAndStartSpeechRecognitionTest(filename); 227 LoadAndStartSpeechRecognitionTest(filename);
227 228
228 EXPECT_EQ("pass", browser()->GetActiveWebContents()->GetURL().ref()); 229 EXPECT_EQ("pass", chrome::GetActiveWebContents(browser())->GetURL().ref());
229 } 230 }
230 231
231 // InProcessBrowserTest methods. 232 // InProcessBrowserTest methods.
232 virtual void SetUpInProcessBrowserTestFixture() { 233 virtual void SetUpInProcessBrowserTestFixture() {
233 fake_speech_recognition_manager_.set_should_send_fake_response(true); 234 fake_speech_recognition_manager_.set_should_send_fake_response(true);
234 speech_recognition_manager_ = &fake_speech_recognition_manager_; 235 speech_recognition_manager_ = &fake_speech_recognition_manager_;
235 236
236 // Inject the fake manager factory so that the test result is returned to 237 // Inject the fake manager factory so that the test result is returned to
237 // the web page. 238 // the web page.
238 InputTagSpeechDispatcherHost::SetManagerForTests( 239 InputTagSpeechDispatcherHost::SetManagerForTests(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 286
286 // Make the renderer crash. This should trigger 287 // Make the renderer crash. This should trigger
287 // InputTagSpeechDispatcherHost to cancel all pending sessions. 288 // InputTagSpeechDispatcherHost to cancel all pending sessions.
288 GURL test_url("about:crash"); 289 GURL test_url("about:crash");
289 ui_test_utils::NavigateToURL(browser(), test_url); 290 ui_test_utils::NavigateToURL(browser(), test_url);
290 291
291 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all()); 292 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all());
292 } 293 }
293 294
294 } // namespace speech 295 } // 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