blob: 06fbcdc87a7550656d31e25e0ecf29b117241fc8 [file] [log] [blame]
Narayan Kamathc60aad22011-12-06 16:40:03 +00001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.speech.tts;
18
19import android.speech.tts.SynthesisCallback;
20import android.speech.tts.SynthesisRequest;
21import android.speech.tts.TextToSpeechService;
Przemyslaw Szczepaniak4b738672014-11-19 17:36:57 +000022import android.util.Log;
Narayan Kamathc60aad22011-12-06 16:40:03 +000023
24import java.util.ArrayList;
Przemyslaw Szczepaniak4b738672014-11-19 17:36:57 +000025import java.util.logging.Logger;
Narayan Kamathc60aad22011-12-06 16:40:03 +000026
27public class MockableTextToSpeechService extends TextToSpeechService {
28
29 private static IDelegate sDelegate;
30
31 public static void setMocker(IDelegate delegate) {
32 sDelegate = delegate;
33 }
34
35 static IDelegate getMocker() {
36 return sDelegate;
37 }
38
39 @Override
40 protected int onIsLanguageAvailable(String lang, String country, String variant) {
41 return sDelegate.onIsLanguageAvailable(lang, country, variant);
42 }
43
44 @Override
45 protected String[] onGetLanguage() {
46 return sDelegate.onGetLanguage();
47 }
48
49 @Override
50 protected int onLoadLanguage(String lang, String country, String variant) {
51 return sDelegate.onLoadLanguage(lang, country, variant);
52 }
53
54 @Override
55 protected void onStop() {
56 sDelegate.onStop();
57 }
58
59 @Override
60 protected void onSynthesizeText(SynthesisRequest request, SynthesisCallback callback) {
61 sDelegate.onSynthesizeText(request, callback);
62 }
63
64 public static interface IDelegate {
65 int onIsLanguageAvailable(String lang, String country, String variant);
66
67 String[] onGetLanguage();
68
69 int onLoadLanguage(String lang, String country, String variant);
70
71 void onStop();
72
73 void onSynthesizeText(SynthesisRequest request, SynthesisCallback callback);
74
75 ArrayList<String> getAvailableVoices();
76
77 ArrayList<String> getUnavailableVoices();
78 }
79
80}