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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/test/base/in_process_browser_test.h" 11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/browser/renderer_host/render_view_host.h" 13 #include "content/browser/renderer_host/render_view_host.h"
14 #include "content/browser/speech/speech_input_dispatcher_host.h" 14 #include "content/browser/speech/speech_input_dispatcher_host.h"
15 #include "content/browser/speech/speech_input_manager.h" 15 #include "content/browser/speech/speech_input_manager.h"
16 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
17 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "content/public/common/speech_input_result.h" 19 #include "content/public/common/speech_input_result.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
21 21
22 using content::WebContents;
23
22 namespace speech_input { 24 namespace speech_input {
23 class FakeSpeechInputManager; 25 class FakeSpeechInputManager;
24 } 26 }
25 27
26 namespace speech_input { 28 namespace speech_input {
27 29
28 const char* kTestResult = "Pictures of the moon"; 30 const char* kTestResult = "Pictures of the moon";
29 31
30 class FakeSpeechInputManager : public SpeechInputManager { 32 class FakeSpeechInputManager : public SpeechInputManager {
31 public: 33 public:
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // events at that coordinate to trigger speech recognition. 155 // events at that coordinate to trigger speech recognition.
154 GURL test_url = testUrl(filename); 156 GURL test_url = testUrl(filename);
155 ui_test_utils::NavigateToURL(browser(), test_url); 157 ui_test_utils::NavigateToURL(browser(), test_url);
156 158
157 WebKit::WebMouseEvent mouse_event; 159 WebKit::WebMouseEvent mouse_event;
158 mouse_event.type = WebKit::WebInputEvent::MouseDown; 160 mouse_event.type = WebKit::WebInputEvent::MouseDown;
159 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 161 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
160 mouse_event.x = 0; 162 mouse_event.x = 0;
161 mouse_event.y = 0; 163 mouse_event.y = 0;
162 mouse_event.clickCount = 1; 164 mouse_event.clickCount = 1;
163 TabContents* tab_contents = browser()->GetSelectedTabContents(); 165 WebContents* web_contents = browser()->GetSelectedWebContents();
164 ui_test_utils::WindowedNotificationObserver observer( 166 ui_test_utils::WindowedNotificationObserver observer(
165 content::NOTIFICATION_LOAD_STOP, 167 content::NOTIFICATION_LOAD_STOP,
166 content::Source<NavigationController>(&tab_contents->GetController())); 168 content::Source<NavigationController>(&web_contents->GetController()));
167 tab_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 169 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
168 mouse_event.type = WebKit::WebInputEvent::MouseUp; 170 mouse_event.type = WebKit::WebInputEvent::MouseUp;
169 tab_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 171 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
170 observer.Wait(); 172 observer.Wait();
171 } 173 }
172 174
173 void RunSpeechInputTest(const FilePath::CharType* filename) { 175 void RunSpeechInputTest(const FilePath::CharType* filename) {
174 // The fake speech input manager would receive the speech input 176 // The fake speech input manager would receive the speech input
175 // request and return the test string as recognition result. The test page 177 // request and return the test string as recognition result. The test page
176 // then sets the URL fragment as 'pass' if it received the expected string. 178 // then sets the URL fragment as 'pass' if it received the expected string.
177 LoadAndStartSpeechInputTest(filename); 179 LoadAndStartSpeechInputTest(filename);
178 180
179 EXPECT_EQ("pass", browser()->GetSelectedTabContents()->GetURL().ref()); 181 EXPECT_EQ("pass", browser()->GetSelectedWebContents()->GetURL().ref());
180 } 182 }
181 183
182 // InProcessBrowserTest methods. 184 // InProcessBrowserTest methods.
183 virtual void SetUpInProcessBrowserTestFixture() { 185 virtual void SetUpInProcessBrowserTestFixture() {
184 fake_speech_input_manager_.set_send_fake_response(true); 186 fake_speech_input_manager_.set_send_fake_response(true);
185 speech_input_manager_ = &fake_speech_input_manager_; 187 speech_input_manager_ = &fake_speech_input_manager_;
186 188
187 // Inject the fake manager factory so that the test result is returned to 189 // Inject the fake manager factory so that the test result is returned to
188 // the web page. 190 // the web page.
189 SpeechInputDispatcherHost::set_manager(speech_input_manager_); 191 SpeechInputDispatcherHost::set_manager(speech_input_manager_);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 250
249 // Make the renderer crash. This should trigger SpeechInputDispatcherHost to 251 // Make the renderer crash. This should trigger SpeechInputDispatcherHost to
250 // cancel all pending sessions. 252 // cancel all pending sessions.
251 GURL test_url("about:crash"); 253 GURL test_url("about:crash");
252 ui_test_utils::NavigateToURL(browser(), test_url); 254 ui_test_utils::NavigateToURL(browser(), test_url);
253 255
254 EXPECT_TRUE(fake_speech_input_manager_.did_cancel_all()); 256 EXPECT_TRUE(fake_speech_input_manager_.did_cancel_all());
255 } 257 }
256 258
257 } // namespace speech_input 259 } // namespace speech_input
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host_browsertest.cc ('k') | content/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698