Browse Source

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

master
Reece H. Dunn 12 years ago
parent
commit
7dd1d66e4a

+ 31
- 0
android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java View File

@@ -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
android/jni/Android.mk View File

@@ -42,7 +42,7 @@ LOCAL_LDLIBS := \

# Common

LOCAL_MODULE := libespeak
LOCAL_MODULE := libttsespeak
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false


+ 1
- 1
android/src/com/reecedunn/espeak/SpeechSynthesis.java View File

@@ -46,7 +46,7 @@ public class SpeechSynthesis {
public static final int GENDER_FEMALE = 2;

static {
System.loadLibrary("espeak");
System.loadLibrary("ttsespeak");

nativeClassInit();
}

Loading…
Cancel
Save