This source file includes following definitions.
- PlatformImplAvailable
- Speak
- IsSpeaking
- StopSpeaking
- Pause
- Resume
- GetVoices
- error
- clear_error
- set_error
- TEST_F
#include "base/values.h"
#include "chrome/browser/speech/tts_controller.h"
#include "chrome/browser/speech/tts_platform.h"
#include "testing/gtest/include/gtest/gtest.h"
class TtsApiControllerTest : public testing::Test {
};
class DummyTtsPlatformImpl : public TtsPlatformImpl {
public:
DummyTtsPlatformImpl() {}
virtual ~DummyTtsPlatformImpl() {}
virtual bool PlatformImplAvailable() OVERRIDE { return true; }
virtual bool Speak(
int utterance_id,
const std::string& utterance,
const std::string& lang,
const VoiceData& voice,
const UtteranceContinuousParameters& params) OVERRIDE {
return true;
}
virtual bool IsSpeaking() OVERRIDE { return false; }
virtual bool StopSpeaking() OVERRIDE { return true; }
virtual void Pause() OVERRIDE {}
virtual void Resume() OVERRIDE {}
virtual void GetVoices(std::vector<VoiceData>* out_voices) OVERRIDE {}
virtual std::string error() OVERRIDE { return std::string(); }
virtual void clear_error() OVERRIDE {}
virtual void set_error(const std::string& error) OVERRIDE {}
};
class TestableTtsController : public TtsController {
public:
TestableTtsController() {}
virtual ~TestableTtsController() {}
};
TEST_F(TtsApiControllerTest, TestTtsControllerShutdown) {
DummyTtsPlatformImpl platform_impl;
TestableTtsController* controller =
new TestableTtsController();
controller->SetPlatformImpl(&platform_impl);
Utterance* utterance1 = new Utterance(NULL);
utterance1->set_can_enqueue(true);
utterance1->set_src_id(1);
controller->SpeakOrEnqueue(utterance1);
Utterance* utterance2 = new Utterance(NULL);
utterance2->set_can_enqueue(true);
utterance2->set_src_id(2);
controller->SpeakOrEnqueue(utterance2);
delete controller;
}