| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 virtual void CancelAllRequestsWithDelegate(Delegate* delegate) { | 86 virtual void CancelAllRequestsWithDelegate(Delegate* delegate) { |
| 87 VLOG(1) << "CancelAllRequestsWithDelegate invoked."; | 87 VLOG(1) << "CancelAllRequestsWithDelegate invoked."; |
| 88 // delegate_ is set to NULL if a fake result was received (see below), so | 88 // delegate_ is set to NULL if a fake result was received (see below), so |
| 89 // check that delegate_ matches the incoming parameter only when there is | 89 // check that delegate_ matches the incoming parameter only when there is |
| 90 // no fake result sent. | 90 // no fake result sent. |
| 91 EXPECT_TRUE(send_fake_response_ || delegate_ == delegate); | 91 EXPECT_TRUE(send_fake_response_ || delegate_ == delegate); |
| 92 did_cancel_all_ = true; | 92 did_cancel_all_ = true; |
| 93 } | 93 } |
| 94 | 94 |
| 95 protected: |
| 96 virtual void GetRequestInfo(bool* can_report_metrics, |
| 97 std::string* request_info) {} |
| 98 virtual void ShowRecognitionRequested(int caller_id, |
| 99 int render_process_id, |
| 100 int render_view_id, |
| 101 const gfx::Rect& element_rect) {} |
| 102 virtual void ShowWarmUp(int caller_id) {} |
| 103 virtual void ShowRecognizing(int caller_id) {} |
| 104 virtual void ShowRecording(int caller_id) {} |
| 105 virtual void ShowInputVolume(int caller_id, |
| 106 float volume, |
| 107 float noise_volume) {} |
| 108 virtual void ShowNoMicError(int caller_id) {} |
| 109 virtual void ShowRecognizerError(int caller_id, |
| 110 SpeechRecognizer::ErrorCode error) {} |
| 111 virtual void DoClose(int caller_id) {} |
| 112 |
| 95 private: | 113 private: |
| 96 void SetFakeRecognitionResult() { | 114 void SetFakeRecognitionResult() { |
| 97 if (caller_id_) { // Do a check in case we were cancelled.. | 115 if (caller_id_) { // Do a check in case we were cancelled.. |
| 98 VLOG(1) << "Setting fake recognition result."; | 116 VLOG(1) << "Setting fake recognition result."; |
| 99 delegate_->DidCompleteRecording(caller_id_); | 117 delegate_->DidCompleteRecording(caller_id_); |
| 100 SpeechInputResultArray results; | 118 SpeechInputResultArray results; |
| 101 results.push_back(SpeechInputResultItem(ASCIIToUTF16(kTestResult), 1.0)); | 119 results.push_back(SpeechInputResultItem(ASCIIToUTF16(kTestResult), 1.0)); |
| 102 delegate_->SetRecognitionResult(caller_id_, results); | 120 delegate_->SetRecognitionResult(caller_id_, results); |
| 103 delegate_->DidCompleteRecognition(caller_id_); | 121 delegate_->DidCompleteRecognition(caller_id_); |
| 104 caller_id_ = 0; | 122 caller_id_ = 0; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 246 |
| 229 // Make the renderer crash. This should trigger SpeechInputDispatcherHost to | 247 // Make the renderer crash. This should trigger SpeechInputDispatcherHost to |
| 230 // cancel all pending sessions. | 248 // cancel all pending sessions. |
| 231 GURL test_url("about:crash"); | 249 GURL test_url("about:crash"); |
| 232 ui_test_utils::NavigateToURL(browser(), test_url); | 250 ui_test_utils::NavigateToURL(browser(), test_url); |
| 233 | 251 |
| 234 EXPECT_TRUE(fake_speech_input_manager_.did_cancel_all()); | 252 EXPECT_TRUE(fake_speech_input_manager_.did_cancel_all()); |
| 235 } | 253 } |
| 236 | 254 |
| 237 } // namespace speech_input | 255 } // namespace speech_input |
| OLD | NEW |