am 1641a4a4: Merge "Fix Google spell checker tests"
* commit '1641a4a4576e73bbf0218178c885f448d669b472': Fix Google spell checker testsmain
commit
3ac40c6ae4
|
@ -119,9 +119,6 @@
|
||||||
<!-- Threshold of the normalized score of the best suggestion for the spell checker to declare
|
<!-- Threshold of the normalized score of the best suggestion for the spell checker to declare
|
||||||
a word to be "recommended" -->
|
a word to be "recommended" -->
|
||||||
<string name="spellchecker_recommended_threshold_value" translatable="false">0.11</string>
|
<string name="spellchecker_recommended_threshold_value" translatable="false">0.11</string>
|
||||||
<!-- Threshold of the normalized score of any dictionary lookup to be offered as a suggestion
|
|
||||||
by the spell checker -->
|
|
||||||
<string name="spellchecker_suggestion_threshold_value" translatable="false">0.03</string>
|
|
||||||
<!-- Screen metrics for logging.
|
<!-- Screen metrics for logging.
|
||||||
0 = "mdpi phone screen"
|
0 = "mdpi phone screen"
|
||||||
1 = "hdpi phone screen"
|
1 = "hdpi phone screen"
|
||||||
|
|
|
@ -23,15 +23,19 @@ import com.android.inputmethod.latin.define.JniLibName;
|
||||||
public final class JniUtils {
|
public final class JniUtils {
|
||||||
private static final String TAG = JniUtils.class.getSimpleName();
|
private static final String TAG = JniUtils.class.getSimpleName();
|
||||||
|
|
||||||
private JniUtils() {
|
static {
|
||||||
// This utility class is not publicly instantiable.
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadNativeLibrary() {
|
|
||||||
try {
|
try {
|
||||||
System.loadLibrary(JniLibName.JNI_LIB_NAME);
|
System.loadLibrary(JniLibName.JNI_LIB_NAME);
|
||||||
} catch (UnsatisfiedLinkError ule) {
|
} catch (UnsatisfiedLinkError ule) {
|
||||||
Log.e(TAG, "Could not load native library " + JniLibName.JNI_LIB_NAME, ule);
|
Log.e(TAG, "Could not load native library " + JniLibName.JNI_LIB_NAME, ule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JniUtils() {
|
||||||
|
// This utility class is not publicly instantiable.
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadNativeLibrary() {
|
||||||
|
// Ensures the static initializer is called
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,6 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
CollectionUtils.newSynchronizedTreeMap();
|
CollectionUtils.newSynchronizedTreeMap();
|
||||||
private ContactsBinaryDictionary mContactsDictionary;
|
private ContactsBinaryDictionary mContactsDictionary;
|
||||||
|
|
||||||
// The threshold for a candidate to be offered as a suggestion.
|
|
||||||
private float mSuggestionThreshold;
|
|
||||||
// The threshold for a suggestion to be considered "recommended".
|
// The threshold for a suggestion to be considered "recommended".
|
||||||
private float mRecommendedThreshold;
|
private float mRecommendedThreshold;
|
||||||
// Whether to use the contacts dictionary
|
// Whether to use the contacts dictionary
|
||||||
|
@ -112,8 +110,6 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
|
|
||||||
@Override public void onCreate() {
|
@Override public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
mSuggestionThreshold =
|
|
||||||
Float.parseFloat(getString(R.string.spellchecker_suggestion_threshold_value));
|
|
||||||
mRecommendedThreshold =
|
mRecommendedThreshold =
|
||||||
Float.parseFloat(getString(R.string.spellchecker_recommended_threshold_value));
|
Float.parseFloat(getString(R.string.spellchecker_recommended_threshold_value));
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
@ -198,8 +194,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuggestionsGatherer newSuggestionsGatherer(final String text, int maxLength) {
|
public SuggestionsGatherer newSuggestionsGatherer(final String text, int maxLength) {
|
||||||
return new SuggestionsGatherer(
|
return new SuggestionsGatherer(text, mRecommendedThreshold, maxLength);
|
||||||
text, mSuggestionThreshold, mRecommendedThreshold, maxLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this class and replace it by storage local to the session.
|
// TODO: remove this class and replace it by storage local to the session.
|
||||||
|
@ -217,7 +212,6 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
private final ArrayList<String> mSuggestions;
|
private final ArrayList<String> mSuggestions;
|
||||||
private final int[] mScores;
|
private final int[] mScores;
|
||||||
private final String mOriginalText;
|
private final String mOriginalText;
|
||||||
private final float mSuggestionThreshold;
|
|
||||||
private final float mRecommendedThreshold;
|
private final float mRecommendedThreshold;
|
||||||
private final int mMaxLength;
|
private final int mMaxLength;
|
||||||
private int mLength = 0;
|
private int mLength = 0;
|
||||||
|
@ -227,10 +221,9 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
private String mBestSuggestion = null;
|
private String mBestSuggestion = null;
|
||||||
private int mBestScore = Integer.MIN_VALUE; // As small as possible
|
private int mBestScore = Integer.MIN_VALUE; // As small as possible
|
||||||
|
|
||||||
SuggestionsGatherer(final String originalText, final float suggestionThreshold,
|
SuggestionsGatherer(final String originalText, final float recommendedThreshold,
|
||||||
final float recommendedThreshold, final int maxLength) {
|
final int maxLength) {
|
||||||
mOriginalText = originalText;
|
mOriginalText = originalText;
|
||||||
mSuggestionThreshold = suggestionThreshold;
|
|
||||||
mRecommendedThreshold = recommendedThreshold;
|
mRecommendedThreshold = recommendedThreshold;
|
||||||
mMaxLength = maxLength;
|
mMaxLength = maxLength;
|
||||||
mSuggestions = CollectionUtils.newArrayList(maxLength + 1);
|
mSuggestions = CollectionUtils.newArrayList(maxLength + 1);
|
||||||
|
@ -272,10 +265,6 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
final String wordString = new String(word, wordOffset, wordLength);
|
final String wordString = new String(word, wordOffset, wordLength);
|
||||||
final float normalizedScore =
|
final float normalizedScore =
|
||||||
BinaryDictionary.calcNormalizedScore(mOriginalText, wordString, score);
|
BinaryDictionary.calcNormalizedScore(mOriginalText, wordString, score);
|
||||||
if (normalizedScore < mSuggestionThreshold) {
|
|
||||||
if (DBG) Log.i(TAG, wordString + " does not make the score threshold");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mLength < mMaxLength) {
|
if (mLength < mMaxLength) {
|
||||||
final int copyLen = mLength - insertIndex;
|
final int copyLen = mLength - insertIndex;
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter span = new SpanGetter(mEditText.getText(), SuggestionSpan.class);
|
||||||
assertEquals("show blue underline, span start", EXPECTED_SPAN_START, span.mStart);
|
assertEquals("show blue underline, span start", EXPECTED_SPAN_START, span.mStart);
|
||||||
assertEquals("show blue underline, span end", EXPECTED_SPAN_END, span.mEnd);
|
assertEquals("show blue underline, span end", EXPECTED_SPAN_END, span.mEnd);
|
||||||
assertEquals("show blue underline, span color", true, span.isAutoCorrectionIndicator());
|
assertEquals("show blue underline, span color", true, span.isAutoCorrectionIndicator());
|
||||||
|
@ -47,7 +47,7 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
type(STRING_2_TO_TYPE);
|
type(STRING_2_TO_TYPE);
|
||||||
// We haven't have time to look into the dictionary yet, so the line should still be
|
// We haven't have time to look into the dictionary yet, so the line should still be
|
||||||
// blue to avoid any flicker.
|
// blue to avoid any flicker.
|
||||||
final SpanGetter spanBefore = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter spanBefore = new SpanGetter(mEditText.getText(), SuggestionSpan.class);
|
||||||
assertEquals("extend blue underline, span start", EXPECTED_SPAN_START, spanBefore.mStart);
|
assertEquals("extend blue underline, span start", EXPECTED_SPAN_START, spanBefore.mStart);
|
||||||
assertEquals("extend blue underline, span end", EXPECTED_SPAN_END, spanBefore.mEnd);
|
assertEquals("extend blue underline, span end", EXPECTED_SPAN_END, spanBefore.mEnd);
|
||||||
assertEquals("extend blue underline, span color", true,
|
assertEquals("extend blue underline, span color", true,
|
||||||
|
@ -55,7 +55,7 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
// Now we have been able to re-evaluate the word, there shouldn't be an auto-correction span
|
// Now we have been able to re-evaluate the word, there shouldn't be an auto-correction span
|
||||||
final SpanGetter spanAfter = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter spanAfter = new SpanGetter(mEditText.getText(), SuggestionSpan.class);
|
||||||
assertNull("hide blue underline", spanAfter.mSpan);
|
assertNull("hide blue underline", spanAfter.mSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,10 +76,10 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
final SpanGetter suggestionSpan = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter suggestionSpan = new SpanGetter(mEditText.getText(), SuggestionSpan.class);
|
||||||
assertEquals("show no blue underline after backspace, span start should be -1",
|
assertEquals("show no blue underline after backspace, span start should be -1",
|
||||||
EXPECTED_SUGGESTION_SPAN_START, suggestionSpan.mStart);
|
EXPECTED_SUGGESTION_SPAN_START, suggestionSpan.mStart);
|
||||||
final SpanGetter underlineSpan = new SpanGetter(mTextView.getText(), UnderlineSpan.class);
|
final SpanGetter underlineSpan = new SpanGetter(mEditText.getText(), UnderlineSpan.class);
|
||||||
assertEquals("should be composing, so should have an underline span",
|
assertEquals("should be composing, so should have an underline span",
|
||||||
EXPECTED_UNDERLINE_SPAN_START, underlineSpan.mStart);
|
EXPECTED_UNDERLINE_SPAN_START, underlineSpan.mStart);
|
||||||
assertEquals("should be composing, so should have an underline span",
|
assertEquals("should be composing, so should have an underline span",
|
||||||
|
@ -103,7 +103,7 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter span = new SpanGetter(mEditText.getText(), SuggestionSpan.class);
|
||||||
assertNull("blue underline removed when cursor is moved", span.mSpan);
|
assertNull("blue underline removed when cursor is moved", span.mSpan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
// Here the blue underline has been set. testBlueUnderline() is testing for this already,
|
// Here the blue underline has been set. testBlueUnderline() is testing for this already,
|
||||||
// so let's not test it here again.
|
// so let's not test it here again.
|
||||||
// Now simulate the user moving the cursor.
|
// Now simulate the user moving the cursor.
|
||||||
SpanGetter span = new SpanGetter(mTextView.getText(), UnderlineSpan.class);
|
SpanGetter span = new SpanGetter(mEditText.getText(), UnderlineSpan.class);
|
||||||
assertNull("should not be composing, so should not have an underline span", span.mSpan);
|
assertNull("should not be composing, so should not have an underline span", span.mSpan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
public void testTypeWord() {
|
public void testTypeWord() {
|
||||||
final String WORD_TO_TYPE = "abcd";
|
final String WORD_TO_TYPE = "abcd";
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
assertEquals("type word", WORD_TO_TYPE, mTextView.getText().toString());
|
assertEquals("type word", WORD_TO_TYPE, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPickSuggestionThenBackspace() {
|
public void testPickSuggestionThenBackspace() {
|
||||||
|
@ -35,7 +35,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("press suggestion then backspace", EXPECTED_RESULT,
|
assertEquals("press suggestion then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPickAutoCorrectionThenBackspace() {
|
public void testPickAutoCorrectionThenBackspace() {
|
||||||
|
@ -48,10 +48,10 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD_TO_PICK);
|
pickSuggestionManually(0, WORD_TO_PICK);
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_PICK,
|
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_PICK,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPickTypedWordOverAutoCorrectionThenBackspace() {
|
public void testPickTypedWordOverAutoCorrectionThenBackspace() {
|
||||||
|
@ -63,10 +63,10 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
pickSuggestionManually(1, WORD_TO_TYPE);
|
pickSuggestionManually(1, WORD_TO_TYPE);
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_TYPE,
|
assertEquals("pick typed word over auto-correction then backspace", WORD_TO_TYPE,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPickDifferentSuggestionThenBackspace() {
|
public void testPickDifferentSuggestionThenBackspace() {
|
||||||
|
@ -79,10 +79,10 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
pickSuggestionManually(2, WORD_TO_PICK);
|
pickSuggestionManually(2, WORD_TO_PICK);
|
||||||
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
|
||||||
assertEquals("pick different suggestion then backspace", WORD_TO_PICK,
|
assertEquals("pick different suggestion then backspace", WORD_TO_PICK,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("pick different suggestion then backspace", EXPECTED_RESULT,
|
assertEquals("pick different suggestion then backspace", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteSelection() {
|
public void testDeleteSelection() {
|
||||||
|
@ -102,7 +102,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
SELECTION_START, SELECTION_END, -1, -1);
|
SELECTION_START, SELECTION_END, -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("delete selection", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("delete selection", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteSelectionTwice() {
|
public void testDeleteSelectionTwice() {
|
||||||
|
@ -123,21 +123,21 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
SELECTION_START, SELECTION_END, -1, -1);
|
SELECTION_START, SELECTION_END, -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("delete selection twice", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("delete selection twice", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrect() {
|
public void testAutoCorrect() {
|
||||||
final String STRING_TO_TYPE = "tgis ";
|
final String STRING_TO_TYPE = "tgis ";
|
||||||
final String EXPECTED_RESULT = "this ";
|
final String EXPECTED_RESULT = "this ";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
assertEquals("simple auto-correct", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("simple auto-correct", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectWithPeriod() {
|
public void testAutoCorrectWithPeriod() {
|
||||||
final String STRING_TO_TYPE = "tgis.";
|
final String STRING_TO_TYPE = "tgis.";
|
||||||
final String EXPECTED_RESULT = "this.";
|
final String EXPECTED_RESULT = "this.";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
assertEquals("auto-correct with period", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("auto-correct with period", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectWithPeriodThenRevert() {
|
public void testAutoCorrectWithPeriodThenRevert() {
|
||||||
|
@ -147,7 +147,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto-correct with period then revert", EXPECTED_RESULT,
|
assertEquals("auto-correct with period then revert", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectWithSpaceThenRevert() {
|
public void testAutoCorrectWithSpaceThenRevert() {
|
||||||
|
@ -157,7 +157,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto-correct with space then revert", EXPECTED_RESULT,
|
assertEquals("auto-correct with space then revert", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectToSelfDoesNotRevert() {
|
public void testAutoCorrectToSelfDoesNotRevert() {
|
||||||
|
@ -167,14 +167,14 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto-correct with space does not revert", EXPECTED_RESULT,
|
assertEquals("auto-correct with space does not revert", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDoubleSpace() {
|
public void testDoubleSpace() {
|
||||||
final String STRING_TO_TYPE = "this ";
|
final String STRING_TO_TYPE = "this ";
|
||||||
final String EXPECTED_RESULT = "this. ";
|
final String EXPECTED_RESULT = "this. ";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
assertEquals("double space make a period", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("double space make a period", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCancelDoubleSpace() {
|
public void testCancelDoubleSpace() {
|
||||||
|
@ -182,7 +182,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
final String EXPECTED_RESULT = "this ";
|
final String EXPECTED_RESULT = "this ";
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("double space make a period", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("double space make a period", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBackspaceAtStartAfterAutocorrect() {
|
public void testBackspaceAtStartAfterAutocorrect() {
|
||||||
|
@ -197,7 +197,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto correct then move cursor to start of line then backspace",
|
assertEquals("auto correct then move cursor to start of line then backspace",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectThenMoveCursorThenBackspace() {
|
public void testAutoCorrectThenMoveCursorThenBackspace() {
|
||||||
|
@ -212,7 +212,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
assertEquals("auto correct then move cursor then backspace",
|
assertEquals("auto correct then move cursor then backspace",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNoSpaceAfterManualPick() {
|
public void testNoSpaceAfterManualPick() {
|
||||||
|
@ -221,7 +221,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
assertEquals("no space after manual pick", EXPECTED_RESULT,
|
assertEquals("no space after manual pick", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenType() {
|
public void testManualPickThenType() {
|
||||||
|
@ -231,7 +231,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
type(WORD1_TO_TYPE);
|
type(WORD1_TO_TYPE);
|
||||||
pickSuggestionManually(0, WORD1_TO_TYPE);
|
pickSuggestionManually(0, WORD1_TO_TYPE);
|
||||||
type(WORD2_TO_TYPE);
|
type(WORD2_TO_TYPE);
|
||||||
assertEquals("manual pick then type", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("manual pick then type", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenSeparator() {
|
public void testManualPickThenSeparator() {
|
||||||
|
@ -241,7 +241,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
type(WORD1_TO_TYPE);
|
type(WORD1_TO_TYPE);
|
||||||
pickSuggestionManually(0, WORD1_TO_TYPE);
|
pickSuggestionManually(0, WORD1_TO_TYPE);
|
||||||
type(WORD2_TO_TYPE);
|
type(WORD2_TO_TYPE);
|
||||||
assertEquals("manual pick then separator", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("manual pick then separator", EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenStripperThenPick() {
|
public void testManualPickThenStripperThenPick() {
|
||||||
|
@ -254,7 +254,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
assertEquals("manual pick then \\n then manual pick", EXPECTED_RESULT,
|
assertEquals("manual pick then \\n then manual pick", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenSpaceThenType() {
|
public void testManualPickThenSpaceThenType() {
|
||||||
|
@ -265,7 +265,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD1_TO_TYPE);
|
pickSuggestionManually(0, WORD1_TO_TYPE);
|
||||||
type(WORD2_TO_TYPE);
|
type(WORD2_TO_TYPE);
|
||||||
assertEquals("manual pick then space then type", EXPECTED_RESULT,
|
assertEquals("manual pick then space then type", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenManualPick() {
|
public void testManualPickThenManualPick() {
|
||||||
|
@ -279,7 +279,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
// to actually pass the right string.
|
// to actually pass the right string.
|
||||||
pickSuggestionManually(1, WORD2_TO_PICK);
|
pickSuggestionManually(1, WORD2_TO_PICK);
|
||||||
assertEquals("manual pick then manual pick", EXPECTED_RESULT,
|
assertEquals("manual pick then manual pick", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteWholeComposingWord() {
|
public void testDeleteWholeComposingWord() {
|
||||||
|
@ -288,7 +288,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
for (int i = 0; i < WORD_TO_TYPE.length(); ++i) {
|
for (int i = 0; i < WORD_TO_TYPE.length(); ++i) {
|
||||||
type(Constants.CODE_DELETE);
|
type(Constants.CODE_DELETE);
|
||||||
}
|
}
|
||||||
assertEquals("delete whole composing word", "", mTextView.getText().toString());
|
assertEquals("delete whole composing word", "", mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
// TODO: Add some tests for non-BMP characters
|
// TODO: Add some tests for non-BMP characters
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
|
||||||
changeLanguage("fr");
|
changeLanguage("fr");
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
assertEquals("simple auto-correct for French", EXPECTED_RESULT,
|
assertEquals("simple auto-correct for French", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenSeparatorForFrench() {
|
public void testManualPickThenSeparatorForFrench() {
|
||||||
|
@ -42,7 +42,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD1_TO_TYPE);
|
pickSuggestionManually(0, WORD1_TO_TYPE);
|
||||||
type(WORD2_TO_TYPE);
|
type(WORD2_TO_TYPE);
|
||||||
assertEquals("manual pick then separator for French", EXPECTED_RESULT,
|
assertEquals("manual pick then separator for French", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWordThenSpaceThenPunctuationFromStripTwiceForFrench() {
|
public void testWordThenSpaceThenPunctuationFromStripTwiceForFrench() {
|
||||||
|
@ -64,7 +64,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
|
||||||
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
||||||
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
||||||
assertEquals("type word then type space then punctuation from strip twice for French",
|
assertEquals("type word then type space then punctuation from strip twice for French",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
} finally {
|
} finally {
|
||||||
setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
|
setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
|
||||||
defaultNextWordPredictionOption);
|
defaultNextWordPredictionOption);
|
||||||
|
@ -98,7 +98,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
|
||||||
changeLanguage("de");
|
changeLanguage("de");
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
assertEquals("simple auto-correct for German", EXPECTED_RESULT,
|
assertEquals("simple auto-correct for German", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectWithUmlautForGerman() {
|
public void testAutoCorrectWithUmlautForGerman() {
|
||||||
|
@ -107,6 +107,6 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
|
||||||
changeLanguage("de");
|
changeLanguage("de");
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
assertEquals("auto-correct with umlaut for German", EXPECTED_RESULT,
|
assertEquals("auto-correct with umlaut for German", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package com.android.inputmethod.latin;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.MessageQueue;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.test.ServiceTestCase;
|
import android.test.ServiceTestCase;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
@ -31,8 +30,8 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
|
@ -49,7 +48,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
|
|
||||||
protected LatinIME mLatinIME;
|
protected LatinIME mLatinIME;
|
||||||
protected Keyboard mKeyboard;
|
protected Keyboard mKeyboard;
|
||||||
protected MyTextView mTextView;
|
protected MyEditText mEditText;
|
||||||
protected View mInputView;
|
protected View mInputView;
|
||||||
protected InputConnection mInputConnection;
|
protected InputConnection mInputConnection;
|
||||||
|
|
||||||
|
@ -88,22 +87,31 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A helper class to increase control over the TextView
|
// A helper class to increase control over the EditText
|
||||||
public static class MyTextView extends TextView {
|
public static class MyEditText extends EditText {
|
||||||
public Locale mCurrentLocale;
|
public Locale mCurrentLocale;
|
||||||
public MyTextView(final Context c) {
|
public MyEditText(final Context c) {
|
||||||
super(c);
|
super(c);
|
||||||
}
|
}
|
||||||
public void onAttachedToWindow() {
|
|
||||||
super.onAttachedToWindow();
|
// overriding hidden API in EditText
|
||||||
}
|
|
||||||
public Locale getTextServicesLocale() {
|
public Locale getTextServicesLocale() {
|
||||||
// This method is necessary because TextView is asking this method for the language
|
// This method is necessary because EditText is asking this method for the language
|
||||||
// to check the spell in. If we don't override this, the spell checker will run in
|
// 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
|
// whatever language the keyboard is currently set on the test device, ignoring any
|
||||||
// settings we do inside the tests.
|
// settings we do inside the tests.
|
||||||
return mCurrentLocale;
|
return mCurrentLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// overriding hidden API in EditText
|
||||||
|
public Locale getSpellCheckerLocale() {
|
||||||
|
// This method is necessary because EditText 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() {
|
||||||
|
@ -130,18 +138,18 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
mTextView = new MyTextView(getContext());
|
mEditText = new MyEditText(getContext());
|
||||||
final int inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
|
final int inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
|
||||||
| InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
| InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
||||||
mTextView.setInputType(inputType);
|
mEditText.setInputType(inputType);
|
||||||
mTextView.setEnabled(true);
|
mEditText.setEnabled(true);
|
||||||
setupService();
|
setupService();
|
||||||
mLatinIME = getService();
|
mLatinIME = getService();
|
||||||
final boolean previousDebugSetting = setDebugMode(true);
|
final boolean previousDebugSetting = setDebugMode(true);
|
||||||
mLatinIME.onCreate();
|
mLatinIME.onCreate();
|
||||||
setDebugMode(previousDebugSetting);
|
setDebugMode(previousDebugSetting);
|
||||||
final EditorInfo ei = new EditorInfo();
|
final EditorInfo ei = new EditorInfo();
|
||||||
final InputConnection ic = mTextView.onCreateInputConnection(ei);
|
final InputConnection ic = mEditText.onCreateInputConnection(ei);
|
||||||
final LayoutInflater inflater =
|
final LayoutInflater inflater =
|
||||||
(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
final ViewGroup vg = new FrameLayout(getContext());
|
final ViewGroup vg = new FrameLayout(getContext());
|
||||||
|
@ -225,8 +233,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void changeLanguage(final String locale) {
|
protected void changeLanguage(final String locale) {
|
||||||
mTextView.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
|
mEditText.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
|
||||||
SubtypeSwitcher.getInstance().forceLocale(mTextView.mCurrentLocale);
|
SubtypeSwitcher.getInstance().forceLocale(mEditText.mCurrentLocale);
|
||||||
mLatinIME.loadKeyboard();
|
mLatinIME.loadKeyboard();
|
||||||
mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
|
mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
|
||||||
waitForDictionaryToBeLoaded();
|
waitForDictionaryToBeLoaded();
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
||||||
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
||||||
assertEquals("type word then type space then punctuation from strip twice",
|
assertEquals("type word then type space then punctuation from strip twice",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
} finally {
|
} finally {
|
||||||
setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
|
setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
|
||||||
defaultNextWordPredictionOption);
|
defaultNextWordPredictionOption);
|
||||||
|
@ -56,7 +56,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
final String EXPECTED_RESULT = "this !!";
|
final String EXPECTED_RESULT = "this !!";
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
assertEquals("manual pick then space then punctuation from keyboard twice", EXPECTED_RESULT,
|
assertEquals("manual pick then space then punctuation from keyboard twice", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenPunctuationFromStripTwiceThenType() {
|
public void testManualPickThenPunctuationFromStripTwiceThenType() {
|
||||||
|
@ -70,7 +70,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
||||||
type(WORD2_TO_TYPE);
|
type(WORD2_TO_TYPE);
|
||||||
assertEquals("pick word then pick punctuation twice then type", EXPECTED_RESULT,
|
assertEquals("pick word then pick punctuation twice then type", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManualPickThenManualPickWithPunctAtStart() {
|
public void testManualPickThenManualPickWithPunctAtStart() {
|
||||||
|
@ -81,7 +81,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD1_TO_TYPE);
|
pickSuggestionManually(0, WORD1_TO_TYPE);
|
||||||
pickSuggestionManually(1, WORD2_TO_PICK);
|
pickSuggestionManually(1, WORD2_TO_PICK);
|
||||||
assertEquals("manual pick then manual pick a word with punct at start", EXPECTED_RESULT,
|
assertEquals("manual pick then manual pick a word with punct at start", EXPECTED_RESULT,
|
||||||
mTextView.getText().toString());
|
mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManuallyPickedWordThenColon() {
|
public void testManuallyPickedWordThenColon() {
|
||||||
|
@ -92,7 +92,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
type(PUNCTUATION);
|
type(PUNCTUATION);
|
||||||
assertEquals("manually pick word then colon",
|
assertEquals("manually pick word then colon",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManuallyPickedWordThenOpenParen() {
|
public void testManuallyPickedWordThenOpenParen() {
|
||||||
|
@ -103,7 +103,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
type(PUNCTUATION);
|
type(PUNCTUATION);
|
||||||
assertEquals("manually pick word then open paren",
|
assertEquals("manually pick word then open paren",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManuallyPickedWordThenCloseParen() {
|
public void testManuallyPickedWordThenCloseParen() {
|
||||||
|
@ -114,7 +114,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
type(PUNCTUATION);
|
type(PUNCTUATION);
|
||||||
assertEquals("manually pick word then close paren",
|
assertEquals("manually pick word then close paren",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManuallyPickedWordThenSmiley() {
|
public void testManuallyPickedWordThenSmiley() {
|
||||||
|
@ -125,7 +125,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
mLatinIME.onTextInput(SPECIAL_KEY);
|
mLatinIME.onTextInput(SPECIAL_KEY);
|
||||||
assertEquals("manually pick word then press the smiley key",
|
assertEquals("manually pick word then press the smiley key",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManuallyPickedWordThenDotCom() {
|
public void testManuallyPickedWordThenDotCom() {
|
||||||
|
@ -136,7 +136,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
pickSuggestionManually(0, WORD_TO_TYPE);
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
mLatinIME.onTextInput(SPECIAL_KEY);
|
mLatinIME.onTextInput(SPECIAL_KEY);
|
||||||
assertEquals("manually pick word then press the .com key",
|
assertEquals("manually pick word then press the .com key",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTypeWordTypeDotThenPressDotCom() {
|
public void testTypeWordTypeDotThenPressDotCom() {
|
||||||
|
@ -146,7 +146,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
mLatinIME.onTextInput(SPECIAL_KEY);
|
mLatinIME.onTextInput(SPECIAL_KEY);
|
||||||
assertEquals("type word type dot then press the .com key",
|
assertEquals("type word type dot then press the .com key",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectionWithSingleQuoteInside() {
|
public void testAutoCorrectionWithSingleQuoteInside() {
|
||||||
|
@ -154,7 +154,7 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
final String EXPECTED_RESULT = "you'd ";
|
final String EXPECTED_RESULT = "you'd ";
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
assertEquals("auto-correction with single quote inside",
|
assertEquals("auto-correction with single quote inside",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectionWithSingleQuotesAround() {
|
public void testAutoCorrectionWithSingleQuotesAround() {
|
||||||
|
@ -162,6 +162,6 @@ public class PunctuationTests extends InputTestsBase {
|
||||||
final String EXPECTED_RESULT = "'this' ";
|
final String EXPECTED_RESULT = "'this' ";
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
assertEquals("auto-correction with single quotes around",
|
assertEquals("auto-correction with single quotes around",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mEditText.getText().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,15 @@ import com.android.inputmethod.latin.InputTestsBase;
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class AndroidSpellCheckerServiceTest extends InputTestsBase {
|
public class AndroidSpellCheckerServiceTest extends InputTestsBase {
|
||||||
public void testSpellchecker() {
|
public void testSpellchecker() {
|
||||||
mTextView.onAttachedToWindow();
|
changeLanguage("en_US");
|
||||||
mTextView.setText("tgis");
|
mEditText.setText("tgis ");
|
||||||
type(" ");
|
mEditText.setSelection(mEditText.getText().length());
|
||||||
|
mEditText.onAttachedToWindow();
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
runMessages();
|
runMessages();
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
|
|
||||||
final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter span = new SpanGetter(mEditText.getText(), SuggestionSpan.class);
|
||||||
// If no span, the following will crash
|
// If no span, the following will crash
|
||||||
final String[] suggestions = span.getSuggestions();
|
final String[] suggestions = span.getSuggestions();
|
||||||
// For this test we consider "tgis" should yield at least 2 suggestions (at this moment
|
// For this test we consider "tgis" should yield at least 2 suggestions (at this moment
|
||||||
|
@ -43,14 +44,15 @@ public class AndroidSpellCheckerServiceTest extends InputTestsBase {
|
||||||
|
|
||||||
public void testRussianSpellchecker() {
|
public void testRussianSpellchecker() {
|
||||||
changeLanguage("ru");
|
changeLanguage("ru");
|
||||||
mTextView.onAttachedToWindow();
|
mEditText.onAttachedToWindow();
|
||||||
mTextView.setText("годп");
|
mEditText.setText("годп ");
|
||||||
type(" ");
|
mEditText.setSelection(mEditText.getText().length());
|
||||||
|
mEditText.onAttachedToWindow();
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
runMessages();
|
runMessages();
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
|
|
||||||
final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter span = new SpanGetter(mEditText.getText(), SuggestionSpan.class);
|
||||||
// If no span, the following will crash
|
// If no span, the following will crash
|
||||||
final String[] suggestions = span.getSuggestions();
|
final String[] suggestions = span.getSuggestions();
|
||||||
// For this test we consider "годп" should yield at least 2 suggestions (at this moment
|
// For this test we consider "годп" should yield at least 2 suggestions (at this moment
|
||||||
|
|
Loading…
Reference in New Issue