1/*
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;
22import android.util.Log;
23
24import java.util.ArrayList;
25import java.util.logging.Logger;
26
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}
81