Merge "Fix a layout problem for pre-MR2"
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml
index 2273394..4a8b955 100644
--- a/java/AndroidManifest.xml
+++ b/java/AndroidManifest.xml
@@ -20,14 +20,16 @@
 
     <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
 
-    <uses-permission android:name="android.permission.VIBRATE" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-    <uses-permission android:name="android.permission.READ_USER_DICTIONARY" />
-    <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
-    <uses-permission android:name="android.permission.READ_CONTACTS" />
-    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.READ_PROFILE" />
+    <uses-permission android:name="android.permission.READ_USER_DICTIONARY" />
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" />
 
     <application android:label="@string/english_ime_name"
             android:icon="@mipmap/ic_ime_settings"
diff --git a/java/res/layout/setup_welcome_video.xml b/java/res/layout/setup_welcome_video.xml
index 3cc5f21..8c04e63 100644
--- a/java/res/layout/setup_welcome_video.xml
+++ b/java/res/layout/setup_welcome_video.xml
@@ -35,6 +35,12 @@
             android:layout_weight="@integer/setup_welcome_video_weight_in_screen"
             android:layout_width="0dp"
             android:layout_height="wrap_content" />
+        <ImageView
+            android:id="@+id/setup_welcome_image"
+            android:visibility="gone"
+            android:layout_weight="@integer/setup_welcome_video_weight_in_screen"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content" />
         <View
             android:layout_weight="@integer/setup_welcome_video_right_padding_weight_in_screen"
             android:layout_width="0dp"
diff --git a/java/res/raw/setup_welcome_image.png b/java/res/raw/setup_welcome_image.png
new file mode 100644
index 0000000..17e3111
--- /dev/null
+++ b/java/res/raw/setup_welcome_image.png
Binary files differ
diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index 5b11e07..33e6a86 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -119,9 +119,6 @@
     <!-- Threshold of the normalized score of the best suggestion for the spell checker to declare
          a word to be "recommended" -->
     <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.
             0 = "mdpi phone screen"
             1 = "hdpi phone screen"
diff --git a/java/src/com/android/inputmethod/latin/JniUtils.java b/java/src/com/android/inputmethod/latin/JniUtils.java
index f930599..8aedee5 100644
--- a/java/src/com/android/inputmethod/latin/JniUtils.java
+++ b/java/src/com/android/inputmethod/latin/JniUtils.java
@@ -23,15 +23,19 @@
 public final class JniUtils {
     private static final String TAG = JniUtils.class.getSimpleName();
 
-    private JniUtils() {
-        // This utility class is not publicly instantiable.
-    }
-
-    public static void loadNativeLibrary() {
+    static {
         try {
             System.loadLibrary(JniLibName.JNI_LIB_NAME);
         } catch (UnsatisfiedLinkError 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
+    }
 }
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
index 044180b..bf24b11 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
@@ -30,6 +30,7 @@
 import android.view.View;
 import android.view.inputmethod.InputMethodInfo;
 import android.view.inputmethod.InputMethodManager;
+import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.VideoView;
 
@@ -201,11 +202,14 @@
                 mWelcomeVideoView.setBackgroundResource(0);
             }
         });
+        final ImageView welcomeImageView = (ImageView)findViewById(R.id.setup_welcome_image);
         mWelcomeVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
             @Override
             public boolean onError(final MediaPlayer mp, final int what, final int extra) {
                 Log.e(TAG, "Playing welcome video causes error: what=" + what + " extra=" + extra);
                 mWelcomeVideoView.setVisibility(View.GONE);
+                welcomeImageView.setImageResource(R.raw.setup_welcome_image);
+                welcomeImageView.setVisibility(View.VISIBLE);
                 return true;
             }
         });
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java b/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
index ca974f6..974dfdd 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
@@ -51,11 +51,32 @@
             mIndicatorView = indicatorView;
         }
 
+        // TODO: Once we stop supporting ICS, uncomment {@link #setPressed(boolean)} method and
+        // remove this method.
         @Override
-        public void setPressed(final boolean pressed) {
-            super.setPressed(pressed);
+        protected void drawableStateChanged() {
+            super.drawableStateChanged();
+            for (final int state : getDrawableState()) {
+                if (state == android.R.attr.state_pressed) {
+                    updateIndicatorView(true /* pressed */);
+                    return;
+                }
+            }
+            updateIndicatorView(false /* pressed */);
+        }
+
+        // TODO: Once we stop supporting ICS, uncomment this method and remove
+        // {@link #drawableStateChanged()} method.
+//        @Override
+//        public void setPressed(final boolean pressed) {
+//            super.setPressed(pressed);
+//            updateIndicatorView(pressed);
+//        }
+
+        private void updateIndicatorView(final boolean pressed) {
             if (mIndicatorView != null) {
                 mIndicatorView.setPressed(pressed);
+                mIndicatorView.invalidate();
             }
         }
     }
@@ -73,12 +94,6 @@
         }
 
         @Override
-        public void setPressed(final boolean pressed) {
-            super.setPressed(pressed);
-            invalidate();
-        }
-
-        @Override
         protected void onDraw(final Canvas canvas) {
             super.onDraw(canvas);
             final int layoutDirection = ViewCompatUtils.getLayoutDirection(this);
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 2d0a89b..9e36e4b 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -64,8 +64,6 @@
             CollectionUtils.newSynchronizedTreeMap();
     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".
     private float mRecommendedThreshold;
     // Whether to use the contacts dictionary
@@ -112,8 +110,6 @@
 
     @Override public void onCreate() {
         super.onCreate();
-        mSuggestionThreshold =
-                Float.parseFloat(getString(R.string.spellchecker_suggestion_threshold_value));
         mRecommendedThreshold =
                 Float.parseFloat(getString(R.string.spellchecker_recommended_threshold_value));
         final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
@@ -198,8 +194,7 @@
     }
 
     public SuggestionsGatherer newSuggestionsGatherer(final String text, int maxLength) {
-        return new SuggestionsGatherer(
-                text, mSuggestionThreshold, mRecommendedThreshold, maxLength);
+        return new SuggestionsGatherer(text, mRecommendedThreshold, maxLength);
     }
 
     // TODO: remove this class and replace it by storage local to the session.
@@ -217,7 +212,6 @@
         private final ArrayList<String> mSuggestions;
         private final int[] mScores;
         private final String mOriginalText;
-        private final float mSuggestionThreshold;
         private final float mRecommendedThreshold;
         private final int mMaxLength;
         private int mLength = 0;
@@ -227,10 +221,9 @@
         private String mBestSuggestion = null;
         private int mBestScore = Integer.MIN_VALUE; // As small as possible
 
-        SuggestionsGatherer(final String originalText, final float suggestionThreshold,
-                final float recommendedThreshold, final int maxLength) {
+        SuggestionsGatherer(final String originalText, final float recommendedThreshold,
+                final int maxLength) {
             mOriginalText = originalText;
-            mSuggestionThreshold = suggestionThreshold;
             mRecommendedThreshold = recommendedThreshold;
             mMaxLength = maxLength;
             mSuggestions = CollectionUtils.newArrayList(maxLength + 1);
@@ -272,10 +265,6 @@
             final String wordString = new String(word, wordOffset, wordLength);
             final float normalizedScore =
                     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) {
                 final int copyLen = mLength - insertIndex;
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
index 3037669..09f81d4 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
@@ -23,19 +23,28 @@
 
 import com.android.inputmethod.keyboard.Key;
 import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.KeyboardActionListener;
 import com.android.inputmethod.keyboard.TypefaceUtils;
 import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
 import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
 import com.android.inputmethod.keyboard.internal.KeyboardParams;
 import com.android.inputmethod.latin.R;
 import com.android.inputmethod.latin.SuggestedWords;
+import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
 import com.android.inputmethod.latin.Utils;
 
 public final class MoreSuggestions extends Keyboard {
     public static final int SUGGESTION_CODE_BASE = 1024;
 
-    MoreSuggestions(final MoreSuggestionsParam params) {
+    public final SuggestedWords mSuggestedWords;
+
+    public static abstract class MoreSuggestionsListener extends KeyboardActionListener.Adapter {
+        public abstract void onSuggestionSelected(final int index, final SuggestedWordInfo info);
+    }
+
+    MoreSuggestions(final MoreSuggestionsParam params, final SuggestedWords suggestedWords) {
         super(params);
+        mSuggestedWords = suggestedWords;
     }
 
     private static final class MoreSuggestionsParam extends KeyboardParams {
@@ -52,8 +61,9 @@
             super();
         }
 
-        public int layout(final SuggestedWords suggestions, final int fromPos, final int maxWidth,
-                final int minWidth, final int maxRow, final Paint paint, final Resources res) {
+        public int layout(final SuggestedWords suggestedWords, final int fromPos,
+                final int maxWidth, final int minWidth, final int maxRow, final Paint paint,
+                final Resources res) {
             clearKeys();
             mDivider = res.getDrawable(R.drawable.more_suggestions_divider);
             mDividerWidth = mDivider.getIntrinsicWidth();
@@ -61,9 +71,9 @@
 
             int row = 0;
             int pos = fromPos, rowStartPos = fromPos;
-            final int size = Math.min(suggestions.size(), SuggestionStripView.MAX_SUGGESTIONS);
+            final int size = Math.min(suggestedWords.size(), SuggestionStripView.MAX_SUGGESTIONS);
             while (pos < size) {
-                final String word = suggestions.getWord(pos);
+                final String word = suggestedWords.getWord(pos);
                 // TODO: Should take care of text x-scaling.
                 mWidths[pos] = (int)(TypefaceUtils.getLabelWidth(word, paint) + padding);
                 final int numColumn = pos - rowStartPos + 1;
@@ -163,7 +173,7 @@
 
     public static final class Builder extends KeyboardBuilder<MoreSuggestionsParam> {
         private final MoreSuggestionsView mPaneView;
-        private SuggestedWords mSuggestions;
+        private SuggestedWords mSuggestedWords;
         private int mFromPos;
         private int mToPos;
 
@@ -172,7 +182,7 @@
             mPaneView = paneView;
         }
 
-        public Builder layout(final SuggestedWords suggestions, final int fromPos,
+        public Builder layout(final SuggestedWords suggestedWords, final int fromPos,
                 final int maxWidth, final int minWidth, final int maxRow,
                 final Keyboard parentKeyboard) {
             final int xmlId = R.xml.kbd_suggestions_pane_template;
@@ -180,11 +190,11 @@
             mParams.mVerticalGap = mParams.mTopPadding = parentKeyboard.mVerticalGap / 2;
 
             mPaneView.updateKeyboardGeometry(mParams.mDefaultRowHeight);
-            final int count = mParams.layout(suggestions, fromPos, maxWidth, minWidth, maxRow,
+            final int count = mParams.layout(suggestedWords, fromPos, maxWidth, minWidth, maxRow,
                     mPaneView.newLabelPaint(null /* key */), mResources);
             mFromPos = fromPos;
             mToPos = fromPos + count;
-            mSuggestions = suggestions;
+            mSuggestedWords = suggestedWords;
             return this;
         }
 
@@ -195,8 +205,8 @@
                 final int x = params.getX(pos);
                 final int y = params.getY(pos);
                 final int width = params.getWidth(pos);
-                final String word = mSuggestions.getWord(pos).toString();
-                final String info = Utils.getDebugInfo(mSuggestions, pos);
+                final String word = mSuggestedWords.getWord(pos);
+                final String info = Utils.getDebugInfo(mSuggestedWords, pos);
                 final int index = pos + SUGGESTION_CODE_BASE;
                 final Key key = new Key(
                         params, word, info, KeyboardIconsSet.ICON_UNDEFINED, index, null, x, y,
@@ -211,7 +221,7 @@
                     params.onAddKey(divider);
                 }
             }
-            return new MoreSuggestions(params);
+            return new MoreSuggestions(params, mSuggestedWords);
         }
     }
 
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
index 6509f39..d585b5c 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestionsView.java
@@ -18,15 +18,21 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.util.Log;
 
+import com.android.inputmethod.keyboard.Keyboard;
 import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
 import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.SuggestedWords;
+import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
 
 /**
  * A view that renders a virtual {@link MoreSuggestions}. It handles rendering of keys and detecting
  * key presses and touch movements.
  */
 public final class MoreSuggestionsView extends MoreKeysKeyboardView {
+    private static final String TAG = MoreSuggestionsView.class.getSimpleName();
+
     public MoreSuggestionsView(final Context context, final AttributeSet attrs) {
         this(context, attrs, R.attr.moreSuggestionsViewStyle);
     }
@@ -54,9 +60,24 @@
 
     @Override
     public void onCodeInput(final int code, final int x, final int y) {
-        final int index = code - MoreSuggestions.SUGGESTION_CODE_BASE;
-        if (index >= 0 && index < SuggestionStripView.MAX_SUGGESTIONS) {
-            mListener.onCustomRequest(index);
+        final Keyboard keyboard = getKeyboard();
+        if (!(keyboard instanceof MoreSuggestions)) {
+            Log.e(TAG, "Expected keyboard is MoreSuggestions, but found "
+                    + keyboard.getClass().getName());
+            return;
         }
+        final SuggestedWords suggestedWords = ((MoreSuggestions)keyboard).mSuggestedWords;
+        final int index = code - MoreSuggestions.SUGGESTION_CODE_BASE;
+        if (index < 0 || index >= suggestedWords.size()) {
+            Log.e(TAG, "Selected suggestion has an illegal index: " + index);
+            return;
+        }
+        if (!(mListener instanceof MoreSuggestionsListener)) {
+            Log.e(TAG, "Expected mListener is MoreSuggestionsListener, but found "
+                    + mListener.getClass().getName());
+            return;
+        }
+        ((MoreSuggestionsListener)mListener).onSuggestionSelected(
+                index, suggestedWords.getInfo(index));
     }
 }
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 2a21ec2..ad350a0 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -50,7 +50,6 @@
 import android.widget.TextView;
 
 import com.android.inputmethod.keyboard.Keyboard;
-import com.android.inputmethod.keyboard.KeyboardActionListener;
 import com.android.inputmethod.keyboard.KeyboardSwitcher;
 import com.android.inputmethod.keyboard.MainKeyboardView;
 import com.android.inputmethod.keyboard.MoreKeysPanel;
@@ -65,6 +64,7 @@
 import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
 import com.android.inputmethod.latin.Utils;
 import com.android.inputmethod.latin.define.ProductionFlag;
+import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
 import com.android.inputmethod.research.ResearchLogger;
 
 import java.util.ArrayList;
@@ -93,7 +93,7 @@
     private final ArrayList<View> mDividers = CollectionUtils.newArrayList();
 
     Listener mListener;
-    SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
+    private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
 
     private final SuggestionStripViewParams mParams;
     private static final float MIN_TEXT_XSCALE = 0.70f;
@@ -652,15 +652,11 @@
         dismissMoreSuggestions();
     }
 
-    private final KeyboardActionListener mMoreSuggestionsListener =
-            new KeyboardActionListener.Adapter() {
+    private final MoreSuggestionsListener mMoreSuggestionsListener = new MoreSuggestionsListener() {
         @Override
-        public boolean onCustomRequest(final int requestCode) {
-            final int index = requestCode;
-            final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index);
+        public void onSuggestionSelected(final int index, final SuggestedWordInfo wordInfo) {
             mListener.pickSuggestionManually(index, wordInfo);
             dismissMoreSuggestions();
-            return true;
         }
 
         @Override
diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp
index 3221dee..0ff7454 100644
--- a/native/jni/src/suggest/core/suggest.cpp
+++ b/native/jni/src/suggest/core/suggest.cpp
@@ -164,8 +164,8 @@
         const bool isPossiblyOffensiveWord = terminalDicNode->getProbability() <= 0;
         const bool isExactMatch = terminalDicNode->isExactMatch();
         const int outputTypeFlags =
-                isPossiblyOffensiveWord ? Dictionary::KIND_FLAG_POSSIBLY_OFFENSIVE : 0
-                | isExactMatch ? Dictionary::KIND_FLAG_EXACT_MATCH : 0;
+                (isPossiblyOffensiveWord ? Dictionary::KIND_FLAG_POSSIBLY_OFFENSIVE : 0)
+                        | (isExactMatch ? Dictionary::KIND_FLAG_EXACT_MATCH : 0);
 
         // Entries that are blacklisted or do not represent a word should not be output.
         const bool isValidWord = !terminalAttributes.isBlacklistedOrNotAWord();
diff --git a/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java b/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java
index 7275d3a..c4fd5a0 100644
--- a/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java
+++ b/tests/src/com/android/inputmethod/latin/BlueUnderlineTests.java
@@ -30,7 +30,7 @@
         type(STRING_TO_TYPE);
         sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
         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 end", EXPECTED_SPAN_END, span.mEnd);
         assertEquals("show blue underline, span color", true, span.isAutoCorrectionIndicator());
@@ -47,7 +47,7 @@
         type(STRING_2_TO_TYPE);
         // We haven't have time to look into the dictionary yet, so the line should still be
         // 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 end", EXPECTED_SPAN_END, spanBefore.mEnd);
         assertEquals("extend blue underline, span color", true,
@@ -55,7 +55,7 @@
         sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
         runMessages();
         // 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);
     }
 
@@ -76,10 +76,10 @@
         type(Constants.CODE_DELETE);
         sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
         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",
                 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",
                 EXPECTED_UNDERLINE_SPAN_START, underlineSpan.mStart);
         assertEquals("should be composing, so should have an underline span",
@@ -103,7 +103,7 @@
                 NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
         sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
         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);
     }
 
@@ -117,7 +117,7 @@
         // Here the blue underline has been set. testBlueUnderline() is testing for this already,
         // so let's not test it here again.
         // 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);
     }
 }
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index 72c8d9c..9140197 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -24,7 +24,7 @@
     public void testTypeWord() {
         final String WORD_TO_TYPE = "abcd";
         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() {
@@ -35,7 +35,7 @@
         mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
         type(Constants.CODE_DELETE);
         assertEquals("press suggestion then backspace", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testPickAutoCorrectionThenBackspace() {
@@ -48,10 +48,10 @@
         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());
+                mEditText.getText().toString());
         type(Constants.CODE_DELETE);
         assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testPickTypedWordOverAutoCorrectionThenBackspace() {
@@ -63,10 +63,10 @@
         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());
+                mEditText.getText().toString());
         type(Constants.CODE_DELETE);
         assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testPickDifferentSuggestionThenBackspace() {
@@ -79,10 +79,10 @@
         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());
+                mEditText.getText().toString());
         type(Constants.CODE_DELETE);
         assertEquals("pick different suggestion then backspace", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testDeleteSelection() {
@@ -102,7 +102,7 @@
         mLatinIME.onUpdateSelection(typedLength, typedLength,
                 SELECTION_START, SELECTION_END, -1, -1);
         type(Constants.CODE_DELETE);
-        assertEquals("delete selection", EXPECTED_RESULT, mTextView.getText().toString());
+        assertEquals("delete selection", EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testDeleteSelectionTwice() {
@@ -123,21 +123,21 @@
                 SELECTION_START, SELECTION_END, -1, -1);
         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() {
         final String STRING_TO_TYPE = "tgis ";
         final String EXPECTED_RESULT = "this ";
         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() {
         final String STRING_TO_TYPE = "tgis.";
         final String EXPECTED_RESULT = "this.";
         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() {
@@ -147,7 +147,7 @@
         mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
         type(Constants.CODE_DELETE);
         assertEquals("auto-correct with period then revert", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testAutoCorrectWithSpaceThenRevert() {
@@ -157,7 +157,7 @@
         mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
         type(Constants.CODE_DELETE);
         assertEquals("auto-correct with space then revert", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testAutoCorrectToSelfDoesNotRevert() {
@@ -167,14 +167,14 @@
         mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
         type(Constants.CODE_DELETE);
         assertEquals("auto-correct with space does not revert", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testDoubleSpace() {
         final String STRING_TO_TYPE = "this  ";
         final String EXPECTED_RESULT = "this. ";
         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() {
@@ -182,7 +182,7 @@
         final String EXPECTED_RESULT = "this  ";
         type(STRING_TO_TYPE);
         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() {
@@ -197,7 +197,7 @@
                 NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
         type(Constants.CODE_DELETE);
         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() {
@@ -212,7 +212,7 @@
                 NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
         type(Constants.CODE_DELETE);
         assertEquals("auto correct then move cursor then backspace",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testNoSpaceAfterManualPick() {
@@ -221,7 +221,7 @@
         type(WORD_TO_TYPE);
         pickSuggestionManually(0, WORD_TO_TYPE);
         assertEquals("no space after manual pick", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testManualPickThenType() {
@@ -231,7 +231,7 @@
         type(WORD1_TO_TYPE);
         pickSuggestionManually(0, WORD1_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() {
@@ -241,7 +241,7 @@
         type(WORD1_TO_TYPE);
         pickSuggestionManually(0, WORD1_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() {
@@ -254,7 +254,7 @@
         type(WORD_TO_TYPE);
         pickSuggestionManually(0, WORD_TO_TYPE);
         assertEquals("manual pick then \\n then manual pick", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testManualPickThenSpaceThenType() {
@@ -265,7 +265,7 @@
         pickSuggestionManually(0, WORD1_TO_TYPE);
         type(WORD2_TO_TYPE);
         assertEquals("manual pick then space then type", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testManualPickThenManualPick() {
@@ -279,7 +279,7 @@
         // to actually pass the right string.
         pickSuggestionManually(1, WORD2_TO_PICK);
         assertEquals("manual pick then manual pick", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testDeleteWholeComposingWord() {
@@ -288,7 +288,7 @@
         for (int i = 0; i < WORD_TO_TYPE.length(); ++i) {
             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
 }
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
index 333b602..2d736e3 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
@@ -30,7 +30,7 @@
         changeLanguage("fr");
         type(STRING_TO_TYPE);
         assertEquals("simple auto-correct for French", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testManualPickThenSeparatorForFrench() {
@@ -42,7 +42,7 @@
         pickSuggestionManually(0, WORD1_TO_TYPE);
         type(WORD2_TO_TYPE);
         assertEquals("manual pick then separator for French", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testWordThenSpaceThenPunctuationFromStripTwiceForFrench() {
@@ -64,7 +64,7 @@
             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());
+                    EXPECTED_RESULT, mEditText.getText().toString());
         } finally {
             setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
                     defaultNextWordPredictionOption);
@@ -98,7 +98,7 @@
         changeLanguage("de");
         type(STRING_TO_TYPE);
         assertEquals("simple auto-correct for German", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testAutoCorrectWithUmlautForGerman() {
@@ -107,6 +107,6 @@
         changeLanguage("de");
         type(STRING_TO_TYPE);
         assertEquals("auto-correct with umlaut for German", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 }
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index 9e107a4..28da74b 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -19,7 +19,6 @@
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.os.Looper;
-import android.os.MessageQueue;
 import android.preference.PreferenceManager;
 import android.test.ServiceTestCase;
 import android.text.InputType;
@@ -31,8 +30,8 @@
 import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
+import android.widget.EditText;
 import android.widget.FrameLayout;
-import android.widget.TextView;
 
 import com.android.inputmethod.keyboard.Key;
 import com.android.inputmethod.keyboard.Keyboard;
@@ -49,7 +48,7 @@
 
     protected LatinIME mLatinIME;
     protected Keyboard mKeyboard;
-    protected MyTextView mTextView;
+    protected MyEditText mEditText;
     protected View mInputView;
     protected InputConnection mInputConnection;
 
@@ -88,22 +87,31 @@
         }
     }
 
-    // A helper class to increase control over the TextView
-    public static class MyTextView extends TextView {
+    // A helper class to increase control over the EditText
+    public static class MyEditText extends EditText {
         public Locale mCurrentLocale;
-        public MyTextView(final Context c) {
+        public MyEditText(final Context c) {
             super(c);
         }
-        public void onAttachedToWindow() {
-            super.onAttachedToWindow();
-        }
+
+        // overriding hidden API in EditText
         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
             // whatever language the keyboard is currently set on the test device, ignoring any
             // settings we do inside the tests.
             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() {
@@ -130,18 +138,18 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        mTextView = new MyTextView(getContext());
+        mEditText = new MyEditText(getContext());
         final int inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
                 | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
-        mTextView.setInputType(inputType);
-        mTextView.setEnabled(true);
+        mEditText.setInputType(inputType);
+        mEditText.setEnabled(true);
         setupService();
         mLatinIME = getService();
         final boolean previousDebugSetting = setDebugMode(true);
         mLatinIME.onCreate();
         setDebugMode(previousDebugSetting);
         final EditorInfo ei = new EditorInfo();
-        final InputConnection ic = mTextView.onCreateInputConnection(ei);
+        final InputConnection ic = mEditText.onCreateInputConnection(ei);
         final LayoutInflater inflater =
                 (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         final ViewGroup vg = new FrameLayout(getContext());
@@ -225,8 +233,8 @@
     }
 
     protected void changeLanguage(final String locale) {
-        mTextView.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
-        SubtypeSwitcher.getInstance().forceLocale(mTextView.mCurrentLocale);
+        mEditText.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
+        SubtypeSwitcher.getInstance().forceLocale(mEditText.mCurrentLocale);
         mLatinIME.loadKeyboard();
         mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
         waitForDictionaryToBeLoaded();
diff --git a/tests/src/com/android/inputmethod/latin/PunctuationTests.java b/tests/src/com/android/inputmethod/latin/PunctuationTests.java
index 1b2f0e6..84ff6b30 100644
--- a/tests/src/com/android/inputmethod/latin/PunctuationTests.java
+++ b/tests/src/com/android/inputmethod/latin/PunctuationTests.java
@@ -44,7 +44,7 @@
             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());
+                    EXPECTED_RESULT, mEditText.getText().toString());
         } finally {
             setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
                     defaultNextWordPredictionOption);
@@ -56,7 +56,7 @@
         final String EXPECTED_RESULT = "this !!";
         type(WORD_TO_TYPE);
         assertEquals("manual pick then space then punctuation from keyboard twice", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testManualPickThenPunctuationFromStripTwiceThenType() {
@@ -70,7 +70,7 @@
         pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
         type(WORD2_TO_TYPE);
         assertEquals("pick word then pick punctuation twice then type", EXPECTED_RESULT,
-                mTextView.getText().toString());
+                mEditText.getText().toString());
     }
 
     public void testManualPickThenManualPickWithPunctAtStart() {
@@ -81,7 +81,7 @@
         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());
+                mEditText.getText().toString());
     }
 
     public void testManuallyPickedWordThenColon() {
@@ -92,7 +92,7 @@
         pickSuggestionManually(0, WORD_TO_TYPE);
         type(PUNCTUATION);
         assertEquals("manually pick word then colon",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testManuallyPickedWordThenOpenParen() {
@@ -103,7 +103,7 @@
         pickSuggestionManually(0, WORD_TO_TYPE);
         type(PUNCTUATION);
         assertEquals("manually pick word then open paren",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testManuallyPickedWordThenCloseParen() {
@@ -114,7 +114,7 @@
         pickSuggestionManually(0, WORD_TO_TYPE);
         type(PUNCTUATION);
         assertEquals("manually pick word then close paren",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testManuallyPickedWordThenSmiley() {
@@ -125,7 +125,7 @@
         pickSuggestionManually(0, WORD_TO_TYPE);
         mLatinIME.onTextInput(SPECIAL_KEY);
         assertEquals("manually pick word then press the smiley key",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testManuallyPickedWordThenDotCom() {
@@ -136,7 +136,7 @@
         pickSuggestionManually(0, WORD_TO_TYPE);
         mLatinIME.onTextInput(SPECIAL_KEY);
         assertEquals("manually pick word then press the .com key",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testTypeWordTypeDotThenPressDotCom() {
@@ -146,7 +146,7 @@
         type(WORD_TO_TYPE);
         mLatinIME.onTextInput(SPECIAL_KEY);
         assertEquals("type word type dot then press the .com key",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testAutoCorrectionWithSingleQuoteInside() {
@@ -154,7 +154,7 @@
         final String EXPECTED_RESULT = "you'd ";
         type(WORD_TO_TYPE);
         assertEquals("auto-correction with single quote inside",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 
     public void testAutoCorrectionWithSingleQuotesAround() {
@@ -162,6 +162,6 @@
         final String EXPECTED_RESULT = "'this' ";
         type(WORD_TO_TYPE);
         assertEquals("auto-correction with single quotes around",
-                EXPECTED_RESULT, mTextView.getText().toString());
+                EXPECTED_RESULT, mEditText.getText().toString());
     }
 }
diff --git a/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java b/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java
index 879cc46..995d7f0 100644
--- a/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java
+++ b/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java
@@ -24,14 +24,15 @@
 @LargeTest
 public class AndroidSpellCheckerServiceTest extends InputTestsBase {
     public void testSpellchecker() {
-        mTextView.onAttachedToWindow();
-        mTextView.setText("tgis");
-        type(" ");
+        changeLanguage("en_US");
+        mEditText.setText("tgis ");
+        mEditText.setSelection(mEditText.getText().length());
+        mEditText.onAttachedToWindow();
         sleep(1000);
         runMessages();
         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
         final String[] suggestions = span.getSuggestions();
         // For this test we consider "tgis" should yield at least 2 suggestions (at this moment
@@ -43,14 +44,15 @@
 
     public void testRussianSpellchecker() {
         changeLanguage("ru");
-        mTextView.onAttachedToWindow();
-        mTextView.setText("годп");
-        type(" ");
+        mEditText.onAttachedToWindow();
+        mEditText.setText("годп ");
+        mEditText.setSelection(mEditText.getText().length());
+        mEditText.onAttachedToWindow();
         sleep(1000);
         runMessages();
         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
         final String[] suggestions = span.getSuggestions();
         // For this test we consider "годп" should yield at least 2 suggestions (at this moment