diff options
24 files changed, 237 insertions, 119 deletions
diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java index d97989d9c..25afef1e6 100644 --- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java +++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java @@ -131,16 +131,11 @@ public class SuggestionSpanUtils { sameAsTyped = true; } } - // TODO: Share the implementation for checking typed word validity between the IME - // and the spell checker. - final int flag = (sameAsTyped && !suggestedWords.mTypedWordValid) - ? (OBJ_FLAG_EASY_CORRECT | OBJ_FLAG_MISSPELLED) - : 0; // TODO: We should avoid adding suggestion span candidates that came from the bigram // prediction. final Object[] args = - { context, null, suggestionsList.toArray(new String[suggestionsList.size()]), flag, + { context, null, suggestionsList.toArray(new String[suggestionsList.size()]), 0, (Class<?>) SuggestionSpanPickedNotificationReceiver.class }; final Object ss = CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan, args); if (ss == null) { diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 2d958e17d..f4c8e61ed 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -135,11 +135,12 @@ public class BinaryDictionary extends Dictionary { } } - // proximityInfo may not be null. + // proximityInfo and/or prevWordForBigrams may not be null. @Override - public void getWords(final WordComposer codes, final WordCallback callback, - final ProximityInfo proximityInfo) { - final int count = getSuggestions(codes, proximityInfo, mOutputChars, mScores); + public void getWords(final WordComposer codes, final CharSequence prevWordForBigrams, + final WordCallback callback, final ProximityInfo proximityInfo) { + final int count = getSuggestions(codes, prevWordForBigrams, proximityInfo, mOutputChars, + mScores); for (int j = 0; j < count; ++j) { if (mScores[j] < 1) break; @@ -161,7 +162,8 @@ public class BinaryDictionary extends Dictionary { // proximityInfo may not be null. /* package for test */ int getSuggestions(final WordComposer codes, - final ProximityInfo proximityInfo, char[] outputChars, int[] scores) { + final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo, + char[] outputChars, int[] scores) { if (!isValidDictionary()) return -1; final int codesSize = codes.size(); @@ -175,6 +177,7 @@ public class BinaryDictionary extends Dictionary { Arrays.fill(outputChars, (char) 0); Arrays.fill(scores, 0); + // TODO: pass the previous word to native code return getSuggestionsNative( mNativeDict, proximityInfo.getNativeProximityInfo(), codes.getXCoordinates(), codes.getYCoordinates(), mInputCodes, codesSize, diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java index 9d26a2343..a405aa409 100644 --- a/java/src/com/android/inputmethod/latin/Dictionary.java +++ b/java/src/com/android/inputmethod/latin/Dictionary.java @@ -61,11 +61,13 @@ public abstract class Dictionary { * Searches for words in the dictionary that match the characters in the composer. Matched * words are added through the callback object. * @param composer the key sequence to match + * @param prevWordForBigrams the previous word, or null if none * @param callback the callback object to send matched words to as possible candidates * @param proximityInfo the object for key proximity. May be ignored by some implementations. * @see WordCallback#addWord(char[], int, int, int, int, int) */ - abstract public void getWords(final WordComposer composer, final WordCallback callback, + abstract public void getWords(final WordComposer composer, + final CharSequence prevWordForBigrams, final WordCallback callback, final ProximityInfo proximityInfo); /** diff --git a/java/src/com/android/inputmethod/latin/DictionaryCollection.java b/java/src/com/android/inputmethod/latin/DictionaryCollection.java index 5de770a4a..37deb0c5d 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryCollection.java +++ b/java/src/com/android/inputmethod/latin/DictionaryCollection.java @@ -50,10 +50,10 @@ public class DictionaryCollection extends Dictionary { } @Override - public void getWords(final WordComposer composer, final WordCallback callback, - final ProximityInfo proximityInfo) { + public void getWords(final WordComposer composer, final CharSequence prevWordForBigrams, + final WordCallback callback, final ProximityInfo proximityInfo) { for (final Dictionary dict : mDictionaries) - dict.getWords(composer, callback, proximityInfo); + dict.getWords(composer, prevWordForBigrams, callback, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 53e8b74de..7d2ccdf5f 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -173,20 +173,21 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { } @Override - public void getWords(final WordComposer codes, final WordCallback callback, - final ProximityInfo proximityInfo) { + public void getWords(final WordComposer codes, final CharSequence prevWordForBigrams, + final WordCallback callback, final ProximityInfo proximityInfo) { asyncReloadDictionaryIfRequired(); - getWordsInner(codes, callback, proximityInfo); + getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); } - protected final void getWordsInner(final WordComposer codes, final WordCallback callback, + protected final void getWordsInner(final WordComposer codes, + final CharSequence prevWordForBigrams, final WordCallback callback, final ProximityInfo proximityInfo) { // Ensure that there are no concurrent calls to getWords. If there are, do nothing and // return. if (mLocalDictionaryController.tryLock()) { try { if (mBinaryDictionary != null) { - mBinaryDictionary.getWords(codes, callback, proximityInfo); + mBinaryDictionary.getWords(codes, prevWordForBigrams, callback, proximityInfo); } } finally { mLocalDictionaryController.unlock(); diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java index 46d11fa37..fe21ebe87 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -192,8 +192,8 @@ public class ExpandableDictionary extends Dictionary { } @Override - public void getWords(final WordComposer codes, final WordCallback callback, - final ProximityInfo proximityInfo) { + public void getWords(final WordComposer codes, final CharSequence prevWordForBigrams, + final WordCallback callback, final ProximityInfo proximityInfo) { synchronized (mUpdatingLock) { // If we need to update, start off a background task if (mRequiresReload) startDictionaryLoadingTaskLocked(); @@ -203,10 +203,11 @@ public class ExpandableDictionary extends Dictionary { if (codes.size() >= BinaryDictionary.MAX_WORD_LENGTH) { return; } - getWordsInner(codes, callback, proximityInfo); + getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); } - protected final void getWordsInner(final WordComposer codes, final WordCallback callback, + protected final void getWordsInner(final WordComposer codes, + final CharSequence prevWordForBigrams, final WordCallback callback, @SuppressWarnings("unused") final ProximityInfo proximityInfo) { mInputLength = codes.size(); if (mCodes.length < mInputLength) mCodes = new int[mInputLength][]; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index caa7f9312..b30d1e35c 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1817,7 +1817,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } @Override - public void pickSuggestionManually(final int index, final CharSequence suggestion) { + public void pickSuggestionManually(final int index, final CharSequence suggestion, + int x, int y) { final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions(); if (SPACE_STATE_PHANTOM == mSpaceState && suggestion.length() > 0) { @@ -1840,6 +1841,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (ic != null) { final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index]; ic.commitCompletion(completionInfo); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_pickApplicationSpecifiedCompletion(index, + completionInfo.getText(), x, y); + } } return; } @@ -1850,6 +1855,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // So, LatinImeLogger logs "" as a user's input. LatinImeLogger.logOnManualSuggestion("", suggestion.toString(), index, suggestedWords); // Rely on onCodeInput to do the complicated swapping/stripping logic consistently. + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_punctuationSuggestion(index, suggestion, x, y); + } final int primaryCode = suggestion.charAt(0); onCodeInput(primaryCode, KeyboardActionListener.SUGGESTION_STRIP_COORDINATE, @@ -1858,8 +1866,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } // We need to log before we commit, because the word composer will store away the user // typed word. - LatinImeLogger.logOnManualSuggestion(mWordComposer.getTypedWord().toString(), + final String replacedWord = mWordComposer.getTypedWord().toString(); + LatinImeLogger.logOnManualSuggestion(replacedWord, suggestion.toString(), index, suggestedWords); + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_pickSuggestionManually(replacedWord, index, suggestion, x, y); + } mExpectingUpdateSelection = true; commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK, LastComposedWord.NOT_A_SEPARATOR); diff --git a/java/src/com/android/inputmethod/latin/ResearchLogger.java b/java/src/com/android/inputmethod/latin/ResearchLogger.java index 4e90dd624..27f2e2a59 100644 --- a/java/src/com/android/inputmethod/latin/ResearchLogger.java +++ b/java/src/com/android/inputmethod/latin/ResearchLogger.java @@ -375,6 +375,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private static final boolean SUDDENJUMPINGTOUCHEVENTHANDLER_ONTOUCHEVENT_ENABLED = DEFAULT_ENABLED; private static final boolean SUGGESTIONSVIEW_SETSUGGESTIONS_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_PICKAPPLICATIONSPECIFIEDCOMPLETION_ENABLED + = DEFAULT_ENABLED; + private static final boolean LATINIME_PICKPUNCTUATIONSUGGESTION_ENABLED = DEFAULT_ENABLED; + private static final boolean LATINIME_PICKSUGGESTIONMANUALLY_ENABLED = DEFAULT_ENABLED; } public static void logUnstructured(String logGroup, final String details) { @@ -633,6 +637,30 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } } + public static void latinIME_pickApplicationSpecifiedCompletion(final int index, + final CharSequence text, int x, int y) { + if (UnsLogGroup.LATINIME_PICKAPPLICATIONSPECIFIEDCOMPLETION_ENABLED) { + final String s = String.valueOf(index) + '\t' + text + '\t' + x + '\t' + y; + logUnstructured("latinIME_pickApplicationSpecifiedCompletion", s); + } + } + + public static void latinIME_pickSuggestionManually(final String replacedWord, + final int index, CharSequence suggestion, int x, int y) { + if (UnsLogGroup.LATINIME_PICKSUGGESTIONMANUALLY_ENABLED) { + final String s = String.valueOf(index) + '\t' + suggestion + '\t' + x + '\t' + y; + logUnstructured("latinIME_pickSuggestionManually", s); + } + } + + public static void latinIME_punctuationSuggestion(final int index, + final CharSequence suggestion, int x, int y) { + if (UnsLogGroup.LATINIME_PICKPUNCTUATIONSUGGESTION_ENABLED) { + final String s = String.valueOf(index) + '\t' + suggestion + '\t' + x + '\t' + y; + logUnstructured("latinIME_pickPunctuationSuggestion", s); + } + } + public static void latinIME_switchToKeyboardView() { if (UnsLogGroup.LATINIME_SWITCHTOKEYBOARDVIEW_ENABLED) { final String s = "Switch to keyboard view."; diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java index 37da5e846..03780419e 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java +++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java @@ -68,14 +68,14 @@ public class SubtypeLocale { } if (isNoLanguage(subtype)) { - return getKeyboardLayoutSetName(subtype).toUpperCase(); + return getKeyboardLayoutSetDisplayName(subtype); } final Locale locale = getSubtypeLocale(subtype); final String language = StringUtils.toTitleCase(locale.getDisplayLanguage(locale), locale); if (AdditionalSubtype.isAdditionalSubtype(subtype)) { return String.format("%s (%s)", - language, getKeyboardLayoutSetName(subtype).toUpperCase()); + language, getKeyboardLayoutSetDisplayName(subtype)); } return StringUtils.toTitleCase(locale.getDisplayName(locale), locale); } @@ -83,7 +83,7 @@ public class SubtypeLocale { // Get InputMethodSubtype's middle display name in its locale. public static String getMiddleDisplayName(InputMethodSubtype subtype) { if (isNoLanguage(subtype)) { - return getKeyboardLayoutSetName(subtype).toUpperCase(); + return getKeyboardLayoutSetDisplayName(subtype); } final Locale locale = getSubtypeLocale(subtype); return StringUtils.toTitleCase(locale.getDisplayLanguage(locale), locale); @@ -108,6 +108,10 @@ public class SubtypeLocale { return LocaleUtils.constructLocaleFromString(localeString); } + public static String getKeyboardLayoutSetDisplayName(InputMethodSubtype subtype) { + return getKeyboardLayoutSetName(subtype).toUpperCase(); + } + public static String getKeyboardLayoutSetName(InputMethodSubtype subtype) { final String keyboardLayoutSet = subtype.getExtraValueOf( LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LAYOUT_SET); diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 51ebfdad6..86753e2cc 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -340,7 +340,7 @@ public class Suggest implements Dictionary.WordCallback { if (key.equals(DICT_KEY_USER_HISTORY_UNIGRAM) || key.equals(DICT_KEY_WHITELIST)) continue; final Dictionary dictionary = mUnigramDictionaries.get(key); - dictionary.getWords(wordComposerForLookup, this, proximityInfo); + dictionary.getWords(wordComposerForLookup, prevWordForBigram, this, proximityInfo); } } diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java index 80825a887..188259ff8 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java @@ -30,10 +30,11 @@ public class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryD } @Override - public synchronized void getWords(final WordComposer codes, final WordCallback callback, + public synchronized void getWords(final WordComposer codes, + final CharSequence prevWordForBigrams, final WordCallback callback, final ProximityInfo proximityInfo) { syncReloadDictionaryIfRequired(); - getWordsInner(codes, callback, proximityInfo); + getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsDictionary.java index 444c7f5f0..a8b871cdf 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsDictionary.java @@ -29,10 +29,11 @@ public class SynchronouslyLoadedContactsDictionary extends ContactsDictionary { } @Override - public synchronized void getWords(final WordComposer codes, final WordCallback callback, + public synchronized void getWords(final WordComposer codes, + final CharSequence prevWordForBigrams, final WordCallback callback, final ProximityInfo proximityInfo) { blockingReloadDictionaryIfRequired(); - getWordsInner(codes, callback, proximityInfo); + getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserDictionary.java index e52b46ac0..50e8b249e 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserDictionary.java @@ -32,10 +32,11 @@ public class SynchronouslyLoadedUserDictionary extends UserDictionary { } @Override - public synchronized void getWords(final WordComposer codes, final WordCallback callback, + public synchronized void getWords(final WordComposer codes, + final CharSequence prevWordForBigrams, final WordCallback callback, final ProximityInfo proximityInfo) { blockingReloadDictionaryIfRequired(); - getWordsInner(codes, callback, proximityInfo); + getWordsInner(codes, prevWordForBigrams, callback, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java index 51b993343..6beeaace9 100644 --- a/java/src/com/android/inputmethod/latin/UserDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserDictionary.java @@ -174,9 +174,10 @@ public class UserDictionary extends ExpandableDictionary { } @Override - public synchronized void getWords(final WordComposer codes, final WordCallback callback, + public synchronized void getWords(final WordComposer codes, + final CharSequence prevWordForBigrams, final WordCallback callback, final ProximityInfo proximityInfo) { - super.getWords(codes, callback, proximityInfo); + super.getWords(codes, prevWordForBigrams, callback, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 44dac30d7..aa25faef5 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -18,11 +18,11 @@ package com.android.inputmethod.latin.spellcheck; import android.content.Intent; import android.content.SharedPreferences; -import android.content.res.Resources; import android.preference.PreferenceManager; import android.service.textservice.SpellCheckerService; import android.text.TextUtils; import android.util.Log; +import android.util.LruCache; import android.view.textservice.SuggestionsInfo; import android.view.textservice.TextInfo; @@ -455,6 +455,35 @@ public class AndroidSpellCheckerService extends SpellCheckerService private final AndroidSpellCheckerService mService; + private final SuggestionsCache mSuggestionsCache = new SuggestionsCache(); + + private static class SuggestionsParams { + public final String[] mSuggestions; + public final int mFlags; + public SuggestionsParams(String[] suggestions, int flags) { + mSuggestions = suggestions; + mFlags = flags; + } + } + + private static class SuggestionsCache { + private static final int MAX_CACHE_SIZE = 50; + // TODO: support bigram + private final LruCache<String, SuggestionsParams> mUnigramSuggestionsInfoCache = + new LruCache<String, SuggestionsParams>(MAX_CACHE_SIZE); + + public SuggestionsParams getSuggestionsFromCache(String query) { + return mUnigramSuggestionsInfoCache.get(query); + } + + public void putSuggestionsToCache(String query, String[] suggestions, int flags) { + if (suggestions == null || TextUtils.isEmpty(query)) { + return; + } + mUnigramSuggestionsInfoCache.put(query, new SuggestionsParams(suggestions, flags)); + } + } + AndroidSpellCheckerSession(final AndroidSpellCheckerService service) { mService = service; } @@ -546,6 +575,15 @@ public class AndroidSpellCheckerService extends SpellCheckerService final int suggestionsLimit) { try { final String text = textInfo.getText(); + final SuggestionsParams cachedSuggestionsParams = + mSuggestionsCache.getSuggestionsFromCache(text); + if (cachedSuggestionsParams != null) { + if (DBG) { + Log.d(TAG, "Cache hit: " + text + ", " + cachedSuggestionsParams.mFlags); + } + return new SuggestionsInfo( + cachedSuggestionsParams.mFlags, cachedSuggestionsParams.mSuggestions); + } if (shouldFilterOut(text, mScript)) { DictAndProximity dictInfo = null; @@ -588,7 +626,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService try { dictInfo = mDictionaryPool.takeOrGetNull(); if (null == dictInfo) return getNotInDictEmptySuggestions(); - dictInfo.mDictionary.getWords(composer, suggestionsGatherer, + dictInfo.mDictionary.getWords(composer, null, suggestionsGatherer, dictInfo.mProximityInfo); isInDict = dictInfo.mDictionary.isValidWord(text); if (!isInDict && CAPITALIZE_NONE != capitalizeType) { @@ -628,7 +666,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService ? SuggestionsInfoCompatUtils .getValueOf_RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS() : 0); - return new SuggestionsInfo(flags, result.mSuggestions); + final SuggestionsInfo retval = new SuggestionsInfo(flags, result.mSuggestions); + mSuggestionsCache.putSuggestionsToCache(text, result.mSuggestions, flags); + return retval; } catch (RuntimeException e) { // Don't kill the keyboard if there is a bug in the spell checker if (DBG) { diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java index 01d51d463..4e1410415 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java @@ -72,7 +72,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, OnLongClickListener { public interface Listener { public boolean addWordToDictionary(String word); - public void pickSuggestionManually(int index, CharSequence word); + public void pickSuggestionManually(int index, CharSequence word, int x, int y); } // The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}. @@ -717,7 +717,9 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, public boolean onCustomRequest(int requestCode) { final int index = requestCode; final CharSequence word = mSuggestedWords.getWord(index); - mListener.pickSuggestionManually(index, word); + // TODO: change caller path so coordinates are passed through here + mListener.pickSuggestionManually(index, word, NOT_A_TOUCH_COORDINATE, + NOT_A_TOUCH_COORDINATE); dismissMoreSuggestions(); return true; } @@ -867,7 +869,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, return; final CharSequence word = mSuggestedWords.getWord(index); - mListener.pickSuggestionManually(index, word); + mListener.pickSuggestionManually(index, word, mLastX, mLastY); } @Override diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp index f3dd2062f..613fbc480 100644 --- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp +++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp @@ -132,23 +132,18 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jobject object, Dictionary *dictionary = (Dictionary*)dict; if (!dictionary) return 0; ProximityInfo *pInfo = (ProximityInfo*)proximityInfo; - int *xCoordinates = env->GetIntArrayElements(xCoordinatesArray, 0); int *yCoordinates = env->GetIntArrayElements(yCoordinatesArray, 0); - int *frequencies = env->GetIntArrayElements(frequencyArray, 0); int *inputCodes = env->GetIntArrayElements(inputArray, 0); jchar *outputChars = env->GetCharArrayElements(outputArray, 0); - int count = dictionary->getSuggestions(pInfo, xCoordinates, yCoordinates, inputCodes, arraySize, useFullEditDistance, (unsigned short*) outputChars, frequencies); - - env->ReleaseIntArrayElements(frequencyArray, frequencies, 0); + env->ReleaseCharArrayElements(outputArray, outputChars, 0); env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); - env->ReleaseIntArrayElements(xCoordinatesArray, xCoordinates, 0); + env->ReleaseIntArrayElements(frequencyArray, frequencies, 0); env->ReleaseIntArrayElements(yCoordinatesArray, yCoordinates, 0); - env->ReleaseCharArrayElements(outputArray, outputChars, 0); - + env->ReleaseIntArrayElements(xCoordinatesArray, xCoordinates, 0); return count; } @@ -157,20 +152,16 @@ static int latinime_BinaryDictionary_getBigrams(JNIEnv *env, jobject object, jlo jcharArray outputArray, jintArray frequencyArray, jint maxWordLength, jint maxBigrams) { Dictionary *dictionary = (Dictionary*)dict; if (!dictionary) return 0; - jchar *prevWord = env->GetCharArrayElements(prevWordArray, 0); int *inputCodes = env->GetIntArrayElements(inputArray, 0); jchar *outputChars = env->GetCharArrayElements(outputArray, 0); int *frequencies = env->GetIntArrayElements(frequencyArray, 0); - int count = dictionary->getBigrams((unsigned short*) prevWord, prevWordLength, inputCodes, inputArraySize, (unsigned short*) outputChars, frequencies, maxWordLength, maxBigrams); - - env->ReleaseCharArrayElements(prevWordArray, prevWord, JNI_ABORT); - env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); - env->ReleaseCharArrayElements(outputArray, outputChars, 0); env->ReleaseIntArrayElements(frequencyArray, frequencies, 0); - + env->ReleaseCharArrayElements(outputArray, outputChars, 0); + env->ReleaseIntArrayElements(inputArray, inputCodes, JNI_ABORT); + env->ReleaseCharArrayElements(prevWordArray, prevWord, JNI_ABORT); return count; } @@ -178,11 +169,9 @@ static jboolean latinime_BinaryDictionary_isValidWord(JNIEnv *env, jobject objec jcharArray wordArray, jint wordLength) { Dictionary *dictionary = (Dictionary*)dict; if (!dictionary) return (jboolean) false; - jchar *word = env->GetCharArrayElements(wordArray, 0); jboolean result = dictionary->isValidWord((unsigned short*) word, wordLength); env->ReleaseCharArrayElements(wordArray, word, JNI_ABORT); - return result; } @@ -190,11 +179,10 @@ static jdouble latinime_BinaryDictionary_calcNormalizedScore(JNIEnv *env, jobjec jcharArray before, jint beforeLength, jcharArray after, jint afterLength, jint score) { jchar *beforeChars = env->GetCharArrayElements(before, 0); jchar *afterChars = env->GetCharArrayElements(after, 0); - jdouble result = Correction::RankingAlgorithm::calcNormalizedScore( - (unsigned short*)beforeChars, beforeLength, (unsigned short*)afterChars, afterLength, - score); - env->ReleaseCharArrayElements(before, beforeChars, JNI_ABORT); + jdouble result = Correction::RankingAlgorithm::calcNormalizedScore((unsigned short*)beforeChars, + beforeLength, (unsigned short*)afterChars, afterLength, score); env->ReleaseCharArrayElements(after, afterChars, JNI_ABORT); + env->ReleaseCharArrayElements(before, beforeChars, JNI_ABORT); return result; } @@ -204,8 +192,8 @@ static jint latinime_BinaryDictionary_editDistance(JNIEnv *env, jobject object, jchar *afterChars = env->GetCharArrayElements(after, 0); jint result = Correction::RankingAlgorithm::editDistance( (unsigned short*)beforeChars, beforeLength, (unsigned short*)afterChars, afterLength); - env->ReleaseCharArrayElements(before, beforeChars, JNI_ABORT); env->ReleaseCharArrayElements(after, afterChars, JNI_ABORT); + env->ReleaseCharArrayElements(before, beforeChars, JNI_ABORT); return result; } diff --git a/native/jni/src/bigram_dictionary.cpp b/native/jni/src/bigram_dictionary.cpp index 926a0d44e..320b0af68 100644 --- a/native/jni/src/bigram_dictionary.cpp +++ b/native/jni/src/bigram_dictionary.cpp @@ -30,7 +30,6 @@ BigramDictionary::BigramDictionary(const unsigned char *dict, int maxWordLength, : DICT(dict), MAX_WORD_LENGTH(maxWordLength), mParentDictionary(parentDictionary) { if (DEBUG_DICT) { AKLOGI("BigramDictionary - constructor"); - AKLOGI("Has Bigram : %d", hasBigram); } } @@ -108,19 +107,9 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i mMaxBigrams = maxBigrams; const uint8_t* const root = DICT; - int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); - - if (NOT_VALID_WORD == pos) return 0; - const int flags = BinaryFormat::getFlagsAndForwardPointer(root, &pos); - if (0 == (flags & UnigramDictionary::FLAG_HAS_BIGRAMS)) return 0; - if (0 == (flags & UnigramDictionary::FLAG_HAS_MULTIPLE_CHARS)) { - BinaryFormat::getCharCodeAndForwardPointer(root, &pos); - } else { - pos = BinaryFormat::skipOtherCharacters(root, pos); - } - pos = BinaryFormat::skipChildrenPosition(flags, pos); - pos = BinaryFormat::skipFrequency(flags, pos); - pos = BinaryFormat::skipShortcuts(root, flags, pos); + int pos = getBigramListForWord(root, prevWord, prevWordLength); + // getBigramListForWord returns 0 if this word is not in the dictionary or has no bigrams + if (0 == pos) return 0; int bigramFlags; int bigramCount = 0; do { @@ -142,6 +131,26 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i return bigramCount; } +// Returns a pointer to the start of the bigram list. +// If the word is not found or has no bigrams, this function returns 0. +int BigramDictionary::getBigramListForWord(const uint8_t* const root, + const unsigned short *prevWord, const int prevWordLength) { + int pos = BinaryFormat::getTerminalPosition(root, prevWord, prevWordLength); + + if (NOT_VALID_WORD == pos) return 0; + const int flags = BinaryFormat::getFlagsAndForwardPointer(root, &pos); + if (0 == (flags & UnigramDictionary::FLAG_HAS_BIGRAMS)) return 0; + if (0 == (flags & UnigramDictionary::FLAG_HAS_MULTIPLE_CHARS)) { + BinaryFormat::getCharCodeAndForwardPointer(root, &pos); + } else { + pos = BinaryFormat::skipOtherCharacters(root, pos); + } + pos = BinaryFormat::skipChildrenPosition(flags, pos); + pos = BinaryFormat::skipFrequency(flags, pos); + pos = BinaryFormat::skipShortcuts(root, flags, pos); + return pos; +} + bool BigramDictionary::checkFirstCharacter(unsigned short *word) { // Checks whether this word starts with same character or neighboring characters of // what user typed. diff --git a/native/jni/src/bigram_dictionary.h b/native/jni/src/bigram_dictionary.h index af89e3255..1612131c4 100644 --- a/native/jni/src/bigram_dictionary.h +++ b/native/jni/src/bigram_dictionary.h @@ -17,6 +17,8 @@ #ifndef LATINIME_BIGRAM_DICTIONARY_H #define LATINIME_BIGRAM_DICTIONARY_H +#include <stdint.h> + namespace latinime { class Dictionary; @@ -25,6 +27,8 @@ class BigramDictionary { BigramDictionary(const unsigned char *dict, int maxWordLength, Dictionary *parentDictionary); int getBigrams(unsigned short *word, int length, int *codes, int codesSize, unsigned short *outWords, int *frequencies, int maxWordLength, int maxBigrams); + int getBigramListForWord(const uint8_t* const root, + const unsigned short *prevWord, const int prevWordLength); ~BigramDictionary(); private: bool addWordBigram(unsigned short *word, int length, int frequency); diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h index 5638bbf8c..66a5c2150 100644 --- a/native/jni/src/dictionary.h +++ b/native/jni/src/dictionary.h @@ -58,8 +58,6 @@ class Dictionary { static int wideStrLen(unsigned short *str); private: - bool hasBigram(); - const unsigned char *mDict; // Used only for the mmap version of dictionary loading, but we use these as dummy variables diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index 11eb6ab19..6c3cb16c7 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -30,7 +30,7 @@ public class InputLogicTests extends InputTestsBase { final String WORD_TO_TYPE = "this"; final String EXPECTED_RESULT = "this"; type(WORD_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + pickSuggestionManually(0, WORD_TO_TYPE); mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1); type(Keyboard.CODE_DELETE); assertEquals("press suggestion then backspace", EXPECTED_RESULT, @@ -44,7 +44,7 @@ public class InputLogicTests extends InputTestsBase { type(WORD_TO_TYPE); // Choose the auto-correction, which is always in position 0. For "tgis", the // auto-correction should be "this". - mLatinIME.pickSuggestionManually(0, WORD_TO_PICK); + pickSuggestionManually(0, WORD_TO_PICK); 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, mTextView.getText().toString()); @@ -59,7 +59,7 @@ public class InputLogicTests extends InputTestsBase { type(WORD_TO_TYPE); // Choose the typed word, which should be in position 1 (because position 0 should // be occupied by the "this" auto-correction, as checked by testAutoCorrect()) - mLatinIME.pickSuggestionManually(1, WORD_TO_TYPE); + pickSuggestionManually(1, WORD_TO_TYPE); 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, mTextView.getText().toString()); @@ -75,7 +75,7 @@ public class InputLogicTests extends InputTestsBase { type(WORD_TO_TYPE); // Choose the second suggestion, which should be in position 2 and should be "thus" // when "tgis is typed. - mLatinIME.pickSuggestionManually(2, WORD_TO_PICK); + pickSuggestionManually(2, WORD_TO_PICK); mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1); assertEquals("pick different suggestion then backspace", WORD_TO_PICK, mTextView.getText().toString()); @@ -171,7 +171,7 @@ public class InputLogicTests extends InputTestsBase { final String WORD_TO_TYPE = "this"; final String EXPECTED_RESULT = WORD_TO_TYPE; type(WORD_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + pickSuggestionManually(0, WORD_TO_TYPE); assertEquals("no space after manual pick", EXPECTED_RESULT, mTextView.getText().toString()); } @@ -181,7 +181,7 @@ public class InputLogicTests extends InputTestsBase { final String WORD2_TO_TYPE = "is"; final String EXPECTED_RESULT = "this is"; type(WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + pickSuggestionManually(0, WORD1_TO_TYPE); type(WORD2_TO_TYPE); assertEquals("manual pick then type", EXPECTED_RESULT, mTextView.getText().toString()); } @@ -191,7 +191,7 @@ public class InputLogicTests extends InputTestsBase { final String WORD2_TO_TYPE = "!"; final String EXPECTED_RESULT = "this!"; type(WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + pickSuggestionManually(0, WORD1_TO_TYPE); type(WORD2_TO_TYPE); assertEquals("manual pick then separator", EXPECTED_RESULT, mTextView.getText().toString()); } @@ -201,7 +201,7 @@ public class InputLogicTests extends InputTestsBase { final String WORD2_TO_TYPE = " is"; final String EXPECTED_RESULT = "this is"; type(WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + pickSuggestionManually(0, WORD1_TO_TYPE); type(WORD2_TO_TYPE); assertEquals("manual pick then space then type", EXPECTED_RESULT, mTextView.getText().toString()); @@ -212,11 +212,11 @@ public class InputLogicTests extends InputTestsBase { final String WORD2_TO_PICK = "is"; final String EXPECTED_RESULT = "this is"; type(WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + pickSuggestionManually(0, WORD1_TO_TYPE); // Here we fake picking a word through bigram prediction. This test is taking // advantage of the fact that Latin IME blindly trusts the caller of #pickSuggestionManually // to actually pass the right string. - mLatinIME.pickSuggestionManually(1, WORD2_TO_PICK); + pickSuggestionManually(1, WORD2_TO_PICK); assertEquals("manual pick then manual pick", EXPECTED_RESULT, mTextView.getText().toString()); } diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java index b2b9601b6..78143ac5b 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java @@ -33,7 +33,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase { final String EXPECTED_RESULT = "test !"; changeLanguage("fr"); type(WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + pickSuggestionManually(0, WORD1_TO_TYPE); type(WORD2_TO_TYPE); assertEquals("manual pick then separator for French", EXPECTED_RESULT, mTextView.getText().toString()); @@ -49,8 +49,8 @@ public class InputLogicTestsNonEnglish extends InputTestsBase { runMessages(); assertTrue("type word then type space should display punctuation strip", mLatinIME.isShowingPunctuationList()); - mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); - mLatinIME.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", EXPECTED_RESULT, mTextView.getText().toString()); } diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index 9276b40df..838effe2c 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -90,14 +90,21 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> { super(LatinIME.class); } - // returns the previous setting value - protected boolean setDebugMode(final boolean mode) { + // TODO: Isn't there a way to make this generic somehow? We can take a <T> and return a <T> + // but we'd have to dispatch types on editor.put...() functions + protected boolean setBooleanPreference(final String key, final boolean value, + final boolean defaultValue) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME); - final boolean previousDebugSetting = prefs.getBoolean(PREF_DEBUG_MODE, false); + final boolean previousSetting = prefs.getBoolean(key, defaultValue); final SharedPreferences.Editor editor = prefs.edit(); - editor.putBoolean(PREF_DEBUG_MODE, mode); + editor.putBoolean(key, value); editor.commit(); - return previousDebugSetting; + return previousSetting; + } + + // returns the previous setting value + protected boolean setDebugMode(final boolean value) { + return setBooleanPreference(PREF_DEBUG_MODE, value, false); } // overload this to configure preferences in a way specific to a subclass's tests @@ -271,6 +278,11 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> { waitForDictionaryToBeLoaded(); } + protected void pickSuggestionManually(final int index, final CharSequence suggestion) { + mLatinIME.pickSuggestionManually(index, suggestion, + KeyboardActionListener.NOT_A_TOUCH_COORDINATE, + KeyboardActionListener.NOT_A_TOUCH_COORDINATE); + } // Helper to avoid writing the try{}catch block each time protected static void sleep(final int milliseconds) { diff --git a/tests/src/com/android/inputmethod/latin/PunctuationTests.java b/tests/src/com/android/inputmethod/latin/PunctuationTests.java index 1b5b72ff8..e1d4c46f8 100644 --- a/tests/src/com/android/inputmethod/latin/PunctuationTests.java +++ b/tests/src/com/android/inputmethod/latin/PunctuationTests.java @@ -16,21 +16,36 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.latin.R; + public class PunctuationTests extends InputTestsBase { + final String NEXT_WORD_PREDICTION_OPTION = "next_word_prediction"; + public void testWordThenSpaceThenPunctuationFromStripTwice() { final String WORD_TO_TYPE = "this "; final String PUNCTUATION_FROM_STRIP = "!"; final String EXPECTED_RESULT = "this!! "; - type(WORD_TO_TYPE); - sleep(DELAY_TO_WAIT_FOR_UNDERLINE); - runMessages(); - assertTrue("type word then type space should display punctuation strip", - mLatinIME.isShowingPunctuationList()); - mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); - mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); - assertEquals("type word then type space then punctuation from strip twice", EXPECTED_RESULT, - mTextView.getText().toString()); + final boolean defaultNextWordPredictionOption = + mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_suggestions); + final boolean previousNextWordPredictionOption = + setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false, + defaultNextWordPredictionOption); + try { + mLatinIME.loadSettings(); + type(WORD_TO_TYPE); + sleep(DELAY_TO_WAIT_FOR_UNDERLINE); + runMessages(); + assertTrue("type word then type space should display punctuation strip", + mLatinIME.isShowingPunctuationList()); + pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + assertEquals("type word then type space then punctuation from strip twice", + EXPECTED_RESULT, mTextView.getText().toString()); + } finally { + setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption, + defaultNextWordPredictionOption); + } } public void testWordThenSpaceThenPunctuationFromKeyboardTwice() { @@ -47,9 +62,9 @@ public class PunctuationTests extends InputTestsBase { final String PUNCTUATION_FROM_STRIP = "!"; final String EXPECTED_RESULT = "this!! is"; type(WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); - mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + pickSuggestionManually(0, WORD1_TO_TYPE); + pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); type(WORD2_TO_TYPE); assertEquals("pick word then pick punctuation twice then type", EXPECTED_RESULT, mTextView.getText().toString()); @@ -60,8 +75,8 @@ public class PunctuationTests extends InputTestsBase { final String WORD2_TO_PICK = "!is"; final String EXPECTED_RESULT = "this!is"; type(WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); - mLatinIME.pickSuggestionManually(1, WORD2_TO_PICK); + pickSuggestionManually(0, WORD1_TO_TYPE); + pickSuggestionManually(1, WORD2_TO_PICK); assertEquals("manual pick then manual pick a word with punct at start", EXPECTED_RESULT, mTextView.getText().toString()); } @@ -71,7 +86,7 @@ public class PunctuationTests extends InputTestsBase { final String PUNCTUATION = ":"; final String EXPECTED_RESULT = "this:"; type(WORD_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + pickSuggestionManually(0, WORD_TO_TYPE); type(PUNCTUATION); assertEquals("manually pick word then colon", EXPECTED_RESULT, mTextView.getText().toString()); @@ -82,7 +97,7 @@ public class PunctuationTests extends InputTestsBase { final String PUNCTUATION = "("; final String EXPECTED_RESULT = "this ("; type(WORD_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + pickSuggestionManually(0, WORD_TO_TYPE); type(PUNCTUATION); assertEquals("manually pick word then open paren", EXPECTED_RESULT, mTextView.getText().toString()); @@ -93,7 +108,7 @@ public class PunctuationTests extends InputTestsBase { final String PUNCTUATION = ")"; final String EXPECTED_RESULT = "this)"; type(WORD_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + pickSuggestionManually(0, WORD_TO_TYPE); type(PUNCTUATION); assertEquals("manually pick word then close paren", EXPECTED_RESULT, mTextView.getText().toString()); @@ -104,7 +119,7 @@ public class PunctuationTests extends InputTestsBase { final String SPECIAL_KEY = ":-)"; final String EXPECTED_RESULT = "this :-)"; type(WORD_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + pickSuggestionManually(0, WORD_TO_TYPE); mLatinIME.onTextInput(SPECIAL_KEY); assertEquals("manually pick word then press the smiley key", EXPECTED_RESULT, mTextView.getText().toString()); @@ -115,7 +130,7 @@ public class PunctuationTests extends InputTestsBase { final String SPECIAL_KEY = ".com"; final String EXPECTED_RESULT = "this.com"; type(WORD_TO_TYPE); - mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + pickSuggestionManually(0, WORD_TO_TYPE); mLatinIME.onTextInput(SPECIAL_KEY); assertEquals("manually pick word then press the .com key", EXPECTED_RESULT, mTextView.getText().toString()); |