IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / public / test / fake_speech_recognition_manager.h
blobc76340ade8b5265313ca85802f7b6554cfed5a22
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_
6 #define CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_
8 #include "base/callback_forward.h"
9 #include "content/public/browser/speech_recognition_manager.h"
10 #include "content/public/browser/speech_recognition_session_config.h"
11 #include "content/public/browser/speech_recognition_session_context.h"
13 namespace content {
15 // Fake SpeechRecognitionManager class that can be used for tests.
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
18 // SetFakeResult().
19 class FakeSpeechRecognitionManager : public SpeechRecognitionManager {
20 public:
21 FakeSpeechRecognitionManager();
22 virtual ~FakeSpeechRecognitionManager();
24 const std::string& grammar() const {
25 return grammar_;
28 bool did_cancel_all() {
29 return did_cancel_all_;
32 void set_should_send_fake_response(bool send) {
33 should_send_fake_response_ = send;
36 bool should_send_fake_response() {
37 return should_send_fake_response_;
40 void WaitForRecognitionStarted();
42 void SetFakeResult(const std::string& result);
44 // SpeechRecognitionManager methods.
45 virtual int CreateSession(
46 const SpeechRecognitionSessionConfig& config) OVERRIDE;
47 virtual void StartSession(int session_id) OVERRIDE;
48 virtual void AbortSession(int session_id) OVERRIDE;
49 virtual void StopAudioCaptureForSession(int session_id) OVERRIDE;
50 virtual void AbortAllSessionsForListener(
51 SpeechRecognitionEventListener* listener) OVERRIDE;
52 virtual void AbortAllSessionsForRenderView(int render_process_id,
53 int render_view_id) OVERRIDE;
54 virtual bool HasAudioInputDevices() OVERRIDE;
55 virtual base::string16 GetAudioInputDeviceModel() OVERRIDE;
56 virtual void ShowAudioInputSettings() OVERRIDE {}
57 virtual int GetSession(int render_process_id,
58 int render_view_id,
59 int request_id) const OVERRIDE;
60 virtual const SpeechRecognitionSessionConfig& GetSessionConfig(
61 int session_id) const OVERRIDE;
62 virtual SpeechRecognitionSessionContext GetSessionContext(
63 int session_id) const OVERRIDE;
65 private:
66 void SetFakeRecognitionResult();
68 int session_id_;
69 SpeechRecognitionEventListener* listener_;
70 SpeechRecognitionSessionConfig session_config_;
71 SpeechRecognitionSessionContext session_ctx_;
72 std::string fake_result_;
73 std::string grammar_;
74 bool did_cancel_all_;
75 bool should_send_fake_response_;
76 base::Closure recognition_started_closure_;
78 DISALLOW_COPY_AND_ASSIGN(FakeSpeechRecognitionManager);
81 } // namespace content
83 #endif // CONTENT_PUBLIC_TEST_FAKE_SPEECH_RECOGNTION_MANAGER_H_