Fix the shared object name for API 8 compatibility, with tests.

This commit is contained in:
Reece H. Dunn
2012-12-18 19:25:09 +00:00
parent dc4f85865d
commit 7dd1d66e4a
3 changed files with 33 additions and 2 deletions
@@ -16,6 +16,7 @@
package com.reecedunn.espeak.test;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -24,6 +25,10 @@ import java.util.Set;
import com.reecedunn.espeak.SpeechSynthesis;
import com.reecedunn.espeak.SpeechSynthesis.Voice;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.media.AudioFormat;
import android.speech.tts.TextToSpeech;
import android.test.AndroidTestCase;
@@ -157,6 +162,32 @@ public class SpeechSynthesisTest extends AndroidTestCase
return null;
}
/**
* This tests that the location of the espeak TTS shared object matches
* the location that Android 2.2 looks for it in.
*/
public void testSharedObjectLocation()
{
Intent intent = new Intent("android.intent.action.START_TTS_ENGINE");
intent.setPackage("com.reecedunn.espeak");
PackageManager pm = getContext().getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0);
assertThat(resolveInfos, is(notNullValue()));
assertThat(resolveInfos.isEmpty(), is(false));
ResolveInfo[] enginesArray = resolveInfos.toArray(new ResolveInfo[0]);
ActivityInfo aInfo = enginesArray[0].activityInfo;
String soFilename = aInfo.name.replace(aInfo.packageName + ".", "") + ".so";
soFilename = soFilename.toLowerCase();
assertThat(soFilename, is("espeak.so"));
soFilename = "/data/data/" + aInfo.packageName + "/lib/libtts" + soFilename;
assertThat(soFilename, is("/data/data/com.reecedunn.espeak/lib/libttsespeak.so"));
File f = new File(soFilename);
assertThat(f.exists(), is(true));
}
public void testConstruction()
{
final SpeechSynthesis synth = new SpeechSynthesis(getContext(), mCallback);
+1 -1
View File
@@ -42,7 +42,7 @@ LOCAL_LDLIBS := \
# Common
LOCAL_MODULE := libespeak
LOCAL_MODULE := libttsespeak
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
@@ -46,7 +46,7 @@ public class SpeechSynthesis {
public static final int GENDER_FEMALE = 2;
static {
System.loadLibrary("espeak");
System.loadLibrary("ttsespeak");
nativeClassInit();
}