Add createKeyboardId helper method
Change-Id: Ibb356e95e4acd965a0dfbf695de1cebcefc5cd9emain
parent
52e96f1e89
commit
6d3ff0c9e0
|
@ -23,6 +23,7 @@ import android.util.Slog;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
public class SuggestPerformanceTests extends SuggestTestsBase {
|
public class SuggestPerformanceTests extends SuggestTestsBase {
|
||||||
|
@ -37,7 +38,7 @@ public class SuggestPerformanceTests extends SuggestTestsBase {
|
||||||
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
||||||
mHelper = new SuggestHelper(
|
mHelper = new SuggestHelper(
|
||||||
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
||||||
US_KEYBOARD_ID);
|
createKeyboardId(Locale.US));
|
||||||
loadString(R.raw.testtext);
|
loadString(R.raw.testtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ import com.android.inputmethod.latin.tests.R;
|
||||||
|
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class SuggestTests extends SuggestTestsBase {
|
public class SuggestTests extends SuggestTestsBase {
|
||||||
private SuggestHelper mHelper;
|
private SuggestHelper mHelper;
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@ public class SuggestTests extends SuggestTestsBase {
|
||||||
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
||||||
mHelper = new SuggestHelper(
|
mHelper = new SuggestHelper(
|
||||||
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
||||||
US_KEYBOARD_ID);
|
createKeyboardId(Locale.US));
|
||||||
mHelper.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
|
mHelper.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,6 @@ import java.io.InputStream;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class SuggestTestsBase extends AndroidTestCase {
|
public class SuggestTestsBase extends AndroidTestCase {
|
||||||
protected static final KeyboardId US_KEYBOARD_ID = new KeyboardId("en_US qwerty keyboard",
|
|
||||||
com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE,
|
|
||||||
Locale.US, Configuration.ORIENTATION_LANDSCAPE, KeyboardId.MODE_TEXT,
|
|
||||||
new EditorInfo(), false, false, false, false);
|
|
||||||
|
|
||||||
protected File mTestPackageFile;
|
protected File mTestPackageFile;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,6 +38,13 @@ public class SuggestTestsBase extends AndroidTestCase {
|
||||||
mTestPackageFile = new File(getTestContext().getApplicationInfo().sourceDir);
|
mTestPackageFile = new File(getTestContext().getApplicationInfo().sourceDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static KeyboardId createKeyboardId(Locale locale) {
|
||||||
|
return new KeyboardId(locale.toString() + " keyboard",
|
||||||
|
com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE,
|
||||||
|
locale, Configuration.ORIENTATION_LANDSCAPE, KeyboardId.MODE_TEXT,
|
||||||
|
new EditorInfo(), false, false, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
protected InputStream openTestRawResource(int resIdInTest) {
|
protected InputStream openTestRawResource(int resIdInTest) {
|
||||||
return getTestContext().getResources().openRawResource(resIdInTest);
|
return getTestContext().getResources().openRawResource(resIdInTest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class UserBigramSuggestTests extends SuggestTestsBase {
|
||||||
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
||||||
mHelper = new UserBigramSuggestHelper(
|
mHelper = new UserBigramSuggestHelper(
|
||||||
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
||||||
MAX_DATA, DELETE_DATA, US_KEYBOARD_ID);
|
MAX_DATA, DELETE_DATA, createKeyboardId(Locale.US));
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************** Tests ************************/
|
/************************** Tests ************************/
|
||||||
|
|
Loading…
Reference in New Issue