Add test for ChromeVox injection into webview
[chromium-blink-merge.git] / chrome / browser / chromeos / accessibility / speech_monitor.h
blob2575dc3d994b439edb85555a8a2ba6ae493c06cb
1 // Copyright 2014 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 CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_
6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_
8 #include <deque>
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/speech/tts_platform.h"
12 #include "content/public/test/test_utils.h"
14 namespace chromeos {
16 // For testing purpose installs itself as the platform speech synthesis engine,
17 // allowing it to intercept all speech calls, and then provides a method to
18 // block until the next utterance is spoken.
19 class SpeechMonitor : public TtsPlatformImpl {
20 public:
21 SpeechMonitor();
22 virtual ~SpeechMonitor();
24 // Blocks until the next utterance is spoken, and returns its text.
25 std::string GetNextUtterance();
27 // Wait for next utterance and return true if next utterance is ChromeVox
28 // enabled message.
29 bool SkipChromeVoxEnabledMessage();
31 // TtsPlatformImpl implementation.
32 virtual bool PlatformImplAvailable() OVERRIDE;
33 virtual bool Speak(
34 int utterance_id,
35 const std::string& utterance,
36 const std::string& lang,
37 const VoiceData& voice,
38 const UtteranceContinuousParameters& params) OVERRIDE;
39 virtual bool StopSpeaking() OVERRIDE;
40 virtual bool IsSpeaking() OVERRIDE;
41 virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE;
42 virtual void Pause() OVERRIDE {}
43 virtual void Resume() OVERRIDE {}
44 virtual std::string error() OVERRIDE;
45 virtual void clear_error() OVERRIDE {}
46 virtual void set_error(const std::string& error) OVERRIDE {}
47 virtual void WillSpeakUtteranceWithVoice(
48 const Utterance* utterance, const VoiceData& voice_data) OVERRIDE;
50 private:
51 scoped_refptr<content::MessageLoopRunner> loop_runner_;
52 std::deque<std::string> utterance_queue_;
54 DISALLOW_COPY_AND_ASSIGN(SpeechMonitor);
57 } // namespace chromeos
59 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_