Browse Source

SpeechSynthesisTest: test for added and removed voices to make it easier to maintain and update the VoiceData.voices list.

master
Reece H. Dunn 12 years ago
parent
commit
ea623385d6

+ 54
- 2
android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java View File



package com.reecedunn.espeak.test; package com.reecedunn.espeak.test;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set;


import com.reecedunn.espeak.SpeechSynthesis; import com.reecedunn.espeak.SpeechSynthesis;
import com.reecedunn.espeak.SpeechSynthesis.Voice; import com.reecedunn.espeak.SpeechSynthesis.Voice;
final SpeechSynthesis synth = new SpeechSynthesis(getContext(), mCallback); final SpeechSynthesis synth = new SpeechSynthesis(getContext(), mCallback);
mVoices = synth.getAvailableVoices(); mVoices = synth.getAvailableVoices();
assertThat(mVoices, is(notNullValue())); assertThat(mVoices, is(notNullValue()));
assertThat(mVoices.size(), is(VoiceData.voices.length));
} }
return mVoices; return mVoices;
} }
assertThat(synth.getBufferSizeInBytes(), is(22050)); assertThat(synth.getBufferSizeInBytes(), is(22050));
} }


public void testAvailableVoices()
public void testAddedVoices()
{
Set<String> voices = new HashSet<String>();
for (Voice data : getVoices())
{
voices.add(data.name);
}

Set<String> expected = new HashSet<String>();
for (VoiceData.Voice data : VoiceData.voices)
{
expected.add(data.name);
}

Set<String> added = new HashSet<String>();
for (String voice : voices)
{
if (!expected.contains(voice))
{
added.add(voice);
}
}
assertThat(added.toString(), is("[]"));
}

public void testRemovedVoices()
{
Set<String> voices = new HashSet<String>();
for (Voice data : getVoices())
{
voices.add(data.name);
}

Set<String> expected = new HashSet<String>();
for (VoiceData.Voice data : VoiceData.voices)
{
expected.add(data.name);
}

Set<String> removed = new HashSet<String>();
for (String voice : expected)
{
if (!voices.contains(voice))
{
removed.add(voice);
}
}
assertThat(removed.toString(), is("[]"));
}

public void testVoiceData()
{ {
for (VoiceData.Voice data : VoiceData.voices) for (VoiceData.Voice data : VoiceData.voices)
{ {

Loading…
Cancel
Save