| OLD | NEW |
| 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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 int session_id) const OVERRIDE { | 146 int session_id) const OVERRIDE { |
| 147 EXPECT_EQ(session_id, session_id_); | 147 EXPECT_EQ(session_id, session_id_); |
| 148 return session_ctx_; | 148 return session_ctx_; |
| 149 } | 149 } |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 void SetFakeRecognitionResult() { | 152 void SetFakeRecognitionResult() { |
| 153 if (session_id_) { // Do a check in case we were cancelled.. | 153 if (session_id_) { // Do a check in case we were cancelled.. |
| 154 VLOG(1) << "Setting fake recognition result."; | 154 VLOG(1) << "Setting fake recognition result."; |
| 155 listener_->OnAudioEnd(session_id_); | 155 listener_->OnAudioEnd(session_id_); |
| 156 SpeechRecognitionResult results; | 156 SpeechRecognitionResult result; |
| 157 results.hypotheses.push_back(SpeechRecognitionHypothesis( | 157 result.hypotheses.push_back(SpeechRecognitionHypothesis( |
| 158 ASCIIToUTF16(kTestResult), 1.0)); | 158 ASCIIToUTF16(kTestResult), 1.0)); |
| 159 listener_->OnRecognitionResult(session_id_, results); | 159 SpeechRecognitionResults results; |
| 160 results.push_back(result); |
| 161 listener_->OnRecognitionResults(session_id_, results); |
| 160 listener_->OnRecognitionEnd(session_id_); | 162 listener_->OnRecognitionEnd(session_id_); |
| 161 session_id_ = 0; | 163 session_id_ = 0; |
| 162 listener_ = NULL; | 164 listener_ = NULL; |
| 163 VLOG(1) << "Finished setting fake recognition result."; | 165 VLOG(1) << "Finished setting fake recognition result."; |
| 164 } | 166 } |
| 165 } | 167 } |
| 166 | 168 |
| 167 int session_id_; | 169 int session_id_; |
| 168 SpeechRecognitionEventListener* listener_; | 170 SpeechRecognitionEventListener* listener_; |
| 169 SpeechRecognitionSessionConfig session_config_; | 171 SpeechRecognitionSessionConfig session_config_; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 LoadAndStartSpeechRecognitionTest("basic_recognition.html"); | 279 LoadAndStartSpeechRecognitionTest("basic_recognition.html"); |
| 278 | 280 |
| 279 // Make the renderer crash. This should trigger | 281 // Make the renderer crash. This should trigger |
| 280 // InputTagSpeechDispatcherHost to cancel all pending sessions. | 282 // InputTagSpeechDispatcherHost to cancel all pending sessions. |
| 281 NavigateToURL(shell(), GURL(chrome::kChromeUICrashURL)); | 283 NavigateToURL(shell(), GURL(chrome::kChromeUICrashURL)); |
| 282 | 284 |
| 283 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all()); | 285 EXPECT_TRUE(fake_speech_recognition_manager_.did_cancel_all()); |
| 284 } | 286 } |
| 285 | 287 |
| 286 } // namespace content | 288 } // namespace content |
| OLD | NEW |