am 49894284: Merge "Add a preliminary test for basic Russian spell check" into jb-mr1-dev
* commit '49894284bdbe36b6248e2fd0ba984e4709438f50': Add a preliminary test for basic Russian spell checkmain
commit
8561000d19
|
@ -41,6 +41,7 @@ import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
|
|
||||||
|
@ -93,12 +94,20 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
|
|
||||||
// A helper class to increase control over the TextView
|
// A helper class to increase control over the TextView
|
||||||
public static class MyTextView extends TextView {
|
public static class MyTextView extends TextView {
|
||||||
|
public Locale mCurrentLocale;
|
||||||
public MyTextView(final Context c) {
|
public MyTextView(final Context c) {
|
||||||
super(c);
|
super(c);
|
||||||
}
|
}
|
||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
}
|
}
|
||||||
|
public Locale getTextServicesLocale() {
|
||||||
|
// This method is necessary because TextView is asking this method for the language
|
||||||
|
// to check the spell in. If we don't override this, the spell checker will run in
|
||||||
|
// whatever language the keyboard is currently set on the test device, ignoring any
|
||||||
|
// settings we do inside the tests.
|
||||||
|
return mCurrentLocale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputTestsBase() {
|
public InputTestsBase() {
|
||||||
|
@ -261,6 +270,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
|
|
||||||
protected void changeLanguage(final String locale) {
|
protected void changeLanguage(final String locale) {
|
||||||
final InputMethodSubtype subtype = mSubtypeMap.get(locale);
|
final InputMethodSubtype subtype = mSubtypeMap.get(locale);
|
||||||
|
mTextView.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
|
||||||
if (subtype == null) {
|
if (subtype == null) {
|
||||||
fail("InputMethodSubtype for locale " + locale + " is not enabled");
|
fail("InputMethodSubtype for locale " + locale + " is not enabled");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,4 +40,24 @@ public class AndroidSpellCheckerServiceTest extends InputTestsBase {
|
||||||
// We also assume the top suggestion should be "this".
|
// We also assume the top suggestion should be "this".
|
||||||
assertEquals("", "this", suggestions[0]);
|
assertEquals("", "this", suggestions[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRussianSpellchecker() {
|
||||||
|
changeLanguage("ru");
|
||||||
|
mTextView.onAttachedToWindow();
|
||||||
|
mTextView.setText("годп");
|
||||||
|
type(" ");
|
||||||
|
sleep(1000);
|
||||||
|
runMessages();
|
||||||
|
sleep(1000);
|
||||||
|
|
||||||
|
final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
||||||
|
// If no span, the following will crash
|
||||||
|
final String[] suggestions = span.getSuggestions();
|
||||||
|
// For this test we consider "годп" should yield at least 2 suggestions (at this moment
|
||||||
|
// it yields 5).
|
||||||
|
assertTrue(suggestions.length >= 2);
|
||||||
|
// We also assume the top suggestion should be "года", which is the top word in the
|
||||||
|
// Russian dictionary.
|
||||||
|
assertEquals("", "года", suggestions[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue