Home | History | Annotate | Download | only in shadows
      1 package org.robolectric.shadows;
      2 
      3 import android.content.Context;
      4 import android.speech.tts.TextToSpeech;
      5 import java.util.HashMap;
      6 import org.robolectric.annotation.Implementation;
      7 import org.robolectric.annotation.Implements;
      8 
      9 @Implements(TextToSpeech.class)
     10 public class ShadowTextToSpeech {
     11   private Context context;
     12   private TextToSpeech.OnInitListener listener;
     13   private String lastSpokenText;
     14   private boolean shutdown = false;
     15   private int queueMode = -1;
     16 
     17   @Implementation
     18   public void __constructor__(Context context, TextToSpeech.OnInitListener listener) {
     19     this.context = context;
     20     this.listener = listener;
     21   }
     22 
     23   @Implementation
     24   public int speak(final String text, final int queueMode, final HashMap<String, String> params) {
     25     lastSpokenText = text;
     26     this.queueMode = queueMode;
     27     return TextToSpeech.SUCCESS;
     28   }
     29 
     30   @Implementation
     31   public void shutdown() {
     32     shutdown = true;
     33   }
     34 
     35   public Context getContext() {
     36     return context;
     37   }
     38 
     39   public TextToSpeech.OnInitListener getOnInitListener() {
     40     return listener;
     41   }
     42 
     43   public String getLastSpokenText() {
     44     return lastSpokenText;
     45   }
     46 
     47   public void clearLastSpokenText() {
     48     lastSpokenText = null;
     49   }
     50 
     51   public boolean isShutdown() {
     52     return shutdown;
     53   }
     54 
     55   public int getQueueMode() {
     56     return queueMode;
     57   }
     58 }
     59