@Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { Log.d(TAG, "TTS init success"); initConfig(); setupOnCompleteListener(); isTtsInitSuccess = true; } else { String message = "TTS init failed, status: " + status; Log.w(TAG, message); Toast.makeText(LNReaderApplication.getInstance(), message, Toast.LENGTH_LONG).show(); isTtsInitSuccess = false; } if (listener != null) { listener.onInit(status); } }
@Test public void shouldStopPlaying() throws Exception { init(); shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.SUCCESS); speakerbox.play("Hello"); speakerbox.stop(); assertThat(shadowTextToSpeech.isStopped()).isTrue(); }
@Before public void setUp() throws Exception { init(); shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.SUCCESS); }
@Test public void shouldUpdateQueueMode() throws Exception { init(); shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.SUCCESS); speakerbox.setQueueMode(TextToSpeech.QUEUE_ADD); speakerbox.play("Yo"); assertThat(shadowTextToSpeech.getQueueMode()).isEqualTo(TextToSpeech.QUEUE_ADD); }
@Test public void checkIfTextIgnored() throws Exception { init(); shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.SUCCESS); speakerbox.dontPlayIfContains("Continue on for"); speakerbox.play("Yo"); speakerbox.play("Continue on for 12 feet"); assertThat(shadowTextToSpeech.getLastSpokenText()).isEqualTo("Yo"); }
@Override public void onInit(int arg0) { if (this.onInitListener != null) { this.onInitListener.onInit(arg0); } }
@Test public void shouldUseDefaultQueueMode() throws Exception { init(); shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.SUCCESS); speakerbox.play("Yo"); assertThat(shadowTextToSpeech.getQueueMode()).isEqualTo(TextToSpeech.QUEUE_FLUSH); }
@Test public void shouldLogInitializationError() throws Exception { shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.ERROR); assertThat(ShadowLog.getLogs().get(0).tag).isEqualTo(Speakerbox.TAG); assertThat(ShadowLog.getLogs().get(0).msg).isEqualTo("Initialization failed."); }
@Test public void shouldNotRemixSavedTextAgain() throws Exception { init(); speakerbox.remix("Hi", "Hi Hi"); speakerbox.play("Hi"); shadowTextToSpeech.clearLastSpokenText(); shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.SUCCESS); assertThat(shadowTextToSpeech.getLastSpokenText()).isEqualTo("Hi Hi"); }
@Test public void shouldPlayLastSavedTextOnInit() throws Exception { init(); speakerbox.play("Hello"); shadowTextToSpeech.clearLastSpokenText(); shadowTextToSpeech.getOnInitListener().onInit(TextToSpeech.SUCCESS); assertThat(shadowTextToSpeech.getLastSpokenText()).isEqualTo("Hello"); }