OLD | NEW |
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::NavigationController; |
22 using content::WebContents; | 23 using content::WebContents; |
23 | 24 |
24 namespace speech_input { | 25 namespace speech_input { |
25 class FakeSpeechInputManager; | 26 class FakeSpeechInputManager; |
26 } | 27 } |
27 | 28 |
28 namespace speech_input { | 29 namespace speech_input { |
29 | 30 |
30 const char* kTestResult = "Pictures of the moon"; | 31 const char* kTestResult = "Pictures of the moon"; |
31 | 32 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 159 |
159 WebKit::WebMouseEvent mouse_event; | 160 WebKit::WebMouseEvent mouse_event; |
160 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 161 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
161 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 162 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
162 mouse_event.x = 0; | 163 mouse_event.x = 0; |
163 mouse_event.y = 0; | 164 mouse_event.y = 0; |
164 mouse_event.clickCount = 1; | 165 mouse_event.clickCount = 1; |
165 WebContents* web_contents = browser()->GetSelectedWebContents(); | 166 WebContents* web_contents = browser()->GetSelectedWebContents(); |
166 ui_test_utils::WindowedNotificationObserver observer( | 167 ui_test_utils::WindowedNotificationObserver observer( |
167 content::NOTIFICATION_LOAD_STOP, | 168 content::NOTIFICATION_LOAD_STOP, |
168 content::Source<content::NavigationController>( | 169 content::Source<NavigationController>(&web_contents->GetController())); |
169 &web_contents->GetController())); | |
170 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 170 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
171 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 171 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
172 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 172 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
173 observer.Wait(); | 173 observer.Wait(); |
174 } | 174 } |
175 | 175 |
176 void RunSpeechInputTest(const FilePath::CharType* filename) { | 176 void RunSpeechInputTest(const FilePath::CharType* filename) { |
177 // The fake speech input manager would receive the speech input | 177 // The fake speech input manager would receive the speech input |
178 // request and return the test string as recognition result. The test page | 178 // request and return the test string as recognition result. The test page |
179 // then sets the URL fragment as 'pass' if it received the expected string. | 179 // then sets the URL fragment as 'pass' if it received the expected string. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 // Make the renderer crash. This should trigger SpeechInputDispatcherHost to | 252 // Make the renderer crash. This should trigger SpeechInputDispatcherHost to |
253 // cancel all pending sessions. | 253 // cancel all pending sessions. |
254 GURL test_url("about:crash"); | 254 GURL test_url("about:crash"); |
255 ui_test_utils::NavigateToURL(browser(), test_url); | 255 ui_test_utils::NavigateToURL(browser(), test_url); |
256 | 256 |
257 EXPECT_TRUE(fake_speech_input_manager_.did_cancel_all()); | 257 EXPECT_TRUE(fake_speech_input_manager_.did_cancel_all()); |
258 } | 258 } |
259 | 259 |
260 } // namespace speech_input | 260 } // namespace speech_input |
OLD | NEW |