diff --git a/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java b/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java index 46e7c297..0e4f8968 100644 --- a/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java +++ b/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java @@ -16,9 +16,11 @@ package com.reecedunn.espeak.test; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Set; import com.reecedunn.espeak.SpeechSynthesis; @@ -103,20 +105,23 @@ public class SpeechSynthesisTest extends TextToSpeechTestCase } }; - private List mVoices = null; + private Map mVoices = null; private Set mAdded = new HashSet(); private Set mRemoved = new HashSet(); - public List getVoices() + public Map getVoices() { if (mVoices == null) { final SpeechSynthesis synth = new SpeechSynthesis(getContext(), mCallback); - mVoices = synth.getAvailableVoices(); + mVoices = new HashMap(); + for (Voice voice : synth.getAvailableVoices()) { + mVoices.put(voice.name, voice); + } assertThat(mVoices, is(notNullValue())); Set voices = new HashSet(); - for (Voice data : mVoices) + for (Voice data : mVoices.values()) { voices.add(data.name); } @@ -148,14 +153,7 @@ public class SpeechSynthesisTest extends TextToSpeechTestCase public Voice getVoice(String name) { - for (Voice voice : getVoices()) - { - if (voice.name.equals(name)) - { - return voice; - } - } - return null; + return getVoices().get(name); } public void testConstruction()