1 // Copyright 2019 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 #include "content/web_test/browser/web_test_tts_platform.h"
6 
7 #include "content/public/browser/tts_controller.h"
8 
9 // static
GetInstance()10 WebTestTtsPlatform* WebTestTtsPlatform::GetInstance() {
11   return base::Singleton<WebTestTtsPlatform>::get();
12 }
13 
PlatformImplSupported()14 bool WebTestTtsPlatform::PlatformImplSupported() {
15   return true;
16 }
17 
PlatformImplInitialized()18 bool WebTestTtsPlatform::PlatformImplInitialized() {
19   return true;
20 }
21 
LoadBuiltInTtsEngine(content::BrowserContext * browser_context)22 bool WebTestTtsPlatform::LoadBuiltInTtsEngine(
23     content::BrowserContext* browser_context) {
24   return false;
25 }
26 
Speak(int utterance_id,const std::string & utterance,const std::string & lang,const content::VoiceData & voice,const content::UtteranceContinuousParameters & params,base::OnceCallback<void (bool)> on_speak_finished)27 void WebTestTtsPlatform::Speak(
28     int utterance_id,
29     const std::string& utterance,
30     const std::string& lang,
31     const content::VoiceData& voice,
32     const content::UtteranceContinuousParameters& params,
33     base::OnceCallback<void(bool)> on_speak_finished) {
34   std::move(on_speak_finished).Run(true);
35   content::TtsController* controller = content::TtsController::GetInstance();
36   int len = int{utterance.size()};
37   controller->OnTtsEvent(utterance_id, content::TTS_EVENT_START, 0, len,
38                          std::string());
39   controller->OnTtsEvent(utterance_id, content::TTS_EVENT_END, len, 0,
40                          std::string());
41 }
42 
StopSpeaking()43 bool WebTestTtsPlatform::StopSpeaking() {
44   return true;
45 }
46 
IsSpeaking()47 bool WebTestTtsPlatform::IsSpeaking() {
48   return false;
49 }
50 
GetVoices(std::vector<content::VoiceData> * out_voices)51 void WebTestTtsPlatform::GetVoices(
52     std::vector<content::VoiceData>* out_voices) {}
53 
Pause()54 void WebTestTtsPlatform::Pause() {}
55 
Resume()56 void WebTestTtsPlatform::Resume() {}
57 
WillSpeakUtteranceWithVoice(content::TtsUtterance * utterance,const content::VoiceData & voice_data)58 void WebTestTtsPlatform::WillSpeakUtteranceWithVoice(
59     content::TtsUtterance* utterance,
60     const content::VoiceData& voice_data) {}
61 
GetError()62 std::string WebTestTtsPlatform::GetError() {
63   return {};
64 }
65 
ClearError()66 void WebTestTtsPlatform::ClearError() {}
67 
SetError(const std::string & error)68 void WebTestTtsPlatform::SetError(const std::string& error) {}
69 
Shutdown()70 void WebTestTtsPlatform::Shutdown() {}
71 
WebTestTtsPlatform()72 WebTestTtsPlatform::WebTestTtsPlatform() {}
73 
~WebTestTtsPlatform()74 WebTestTtsPlatform::~WebTestTtsPlatform() {}
75