| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_ |
| 6 #define CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_ | 6 #define CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "content/public/browser/speech_recognition_manager.h" | 9 #include "content/public/browser/speech_recognition_manager.h" |
| 10 #include "content/public/browser/speech_recognition_session_config.h" | 10 #include "content/public/browser/speech_recognition_session_config.h" |
| 11 #include "content/public/browser/speech_recognition_session_context.h" | 11 #include "content/public/browser/speech_recognition_session_context.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 // Fake SpeechRecognitionManager class that can be used for tests. | 15 // Fake SpeechRecognitionManager class that can be used for tests. |
| 16 // By default the recognition manager will respond with "Pictures of the moon" | 16 // By default the recognition manager will respond with "Pictures of the moon" |
| 17 // as recognized result from speech. This result can be overridden by calling | 17 // as recognized result from speech. This result can be overridden by calling |
| 18 // SetFakeResult(). | 18 // SetFakeResult(). |
| 19 class FakeSpeechRecognitionManager : public SpeechRecognitionManager { | 19 class FakeSpeechRecognitionManager : public SpeechRecognitionManager { |
| 20 public: | 20 public: |
| 21 FakeSpeechRecognitionManager(); | 21 FakeSpeechRecognitionManager(); |
| 22 virtual ~FakeSpeechRecognitionManager(); | 22 ~FakeSpeechRecognitionManager() override; |
| 23 | 23 |
| 24 const std::string& grammar() const { | 24 const std::string& grammar() const { |
| 25 return grammar_; | 25 return grammar_; |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool did_cancel_all() { | 28 bool did_cancel_all() { |
| 29 return did_cancel_all_; | 29 return did_cancel_all_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void set_should_send_fake_response(bool send) { | 32 void set_should_send_fake_response(bool send) { |
| 33 should_send_fake_response_ = send; | 33 should_send_fake_response_ = send; |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool should_send_fake_response() { | 36 bool should_send_fake_response() { |
| 37 return should_send_fake_response_; | 37 return should_send_fake_response_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void WaitForRecognitionStarted(); | 40 void WaitForRecognitionStarted(); |
| 41 | 41 |
| 42 void SetFakeResult(const std::string& result); | 42 void SetFakeResult(const std::string& result); |
| 43 | 43 |
| 44 // SpeechRecognitionManager methods. | 44 // SpeechRecognitionManager methods. |
| 45 virtual int CreateSession( | 45 int CreateSession(const SpeechRecognitionSessionConfig& config) override; |
| 46 const SpeechRecognitionSessionConfig& config) override; | 46 void StartSession(int session_id) override; |
| 47 virtual void StartSession(int session_id) override; | 47 void AbortSession(int session_id) override; |
| 48 virtual void AbortSession(int session_id) override; | 48 void StopAudioCaptureForSession(int session_id) override; |
| 49 virtual void StopAudioCaptureForSession(int session_id) override; | 49 void AbortAllSessionsForRenderProcess(int render_process_id) override; |
| 50 virtual void AbortAllSessionsForRenderProcess(int render_process_id) override; | 50 void AbortAllSessionsForRenderView(int render_process_id, |
| 51 virtual void AbortAllSessionsForRenderView(int render_process_id, | 51 int render_view_id) override; |
| 52 int render_view_id) override; | 52 bool HasAudioInputDevices() override; |
| 53 virtual bool HasAudioInputDevices() override; | 53 base::string16 GetAudioInputDeviceModel() override; |
| 54 virtual base::string16 GetAudioInputDeviceModel() override; | 54 void ShowAudioInputSettings() override {} |
| 55 virtual void ShowAudioInputSettings() override {} | 55 int GetSession(int render_process_id, |
| 56 virtual int GetSession(int render_process_id, | 56 int render_view_id, |
| 57 int render_view_id, | 57 int request_id) const override; |
| 58 int request_id) const override; | 58 const SpeechRecognitionSessionConfig& GetSessionConfig( |
| 59 virtual const SpeechRecognitionSessionConfig& GetSessionConfig( | |
| 60 int session_id) const override; | 59 int session_id) const override; |
| 61 virtual SpeechRecognitionSessionContext GetSessionContext( | 60 SpeechRecognitionSessionContext GetSessionContext( |
| 62 int session_id) const override; | 61 int session_id) const override; |
| 63 | 62 |
| 64 private: | 63 private: |
| 65 void SetFakeRecognitionResult(); | 64 void SetFakeRecognitionResult(); |
| 66 | 65 |
| 67 int session_id_; | 66 int session_id_; |
| 68 SpeechRecognitionEventListener* listener_; | 67 SpeechRecognitionEventListener* listener_; |
| 69 SpeechRecognitionSessionConfig session_config_; | 68 SpeechRecognitionSessionConfig session_config_; |
| 70 SpeechRecognitionSessionContext session_ctx_; | 69 SpeechRecognitionSessionContext session_ctx_; |
| 71 std::string fake_result_; | 70 std::string fake_result_; |
| 72 std::string grammar_; | 71 std::string grammar_; |
| 73 bool did_cancel_all_; | 72 bool did_cancel_all_; |
| 74 bool should_send_fake_response_; | 73 bool should_send_fake_response_; |
| 75 base::Closure recognition_started_closure_; | 74 base::Closure recognition_started_closure_; |
| 76 | 75 |
| 77 DISALLOW_COPY_AND_ASSIGN(FakeSpeechRecognitionManager); | 76 DISALLOW_COPY_AND_ASSIGN(FakeSpeechRecognitionManager); |
| 78 }; | 77 }; |
| 79 | 78 |
| 80 } // namespace content | 79 } // namespace content |
| 81 | 80 |
| 82 #endif // CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_ | 81 #endif // CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_ |
| OLD | NEW |