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. 4 5#ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_ 6#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_ 7 8#include <deque> 9 10#include "base/memory/ref_counted.h" 11#include "chrome/browser/speech/tts_platform.h" 12#include "content/public/test/test_utils.h" 13 14namespace chromeos { 15 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. 19class SpeechMonitor : public TtsPlatformImpl { 20 public: 21 SpeechMonitor(); 22 virtual ~SpeechMonitor(); 23 24 // Blocks until the next utterance is spoken, and returns its text. 25 std::string GetNextUtterance(); 26 27 // Wait for next utterance and return true if next utterance is ChromeVox 28 // enabled message. 29 bool SkipChromeVoxEnabledMessage(); 30 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; 49 50 private: 51 scoped_refptr<content::MessageLoopRunner> loop_runner_; 52 std::deque<std::string> utterance_queue_; 53 54 DISALLOW_COPY_AND_ASSIGN(SpeechMonitor); 55}; 56 57} // namespace chromeos 58 59#endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_ 60