Fix failing tests.
Most of the failures can be ascribed to the tests not passing the correct old position of the cursor on a second call to onUpdateSelection() to LatinIME. Bug: 7276565 Bug: 7276805 Bug: 7276195 Change-Id: I3f1b52cdcc783ea18838408bed50699b7254eaf4main
parent
3873d36128
commit
2752287c42
|
@ -88,17 +88,19 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
|
|
||||||
public void testBlueUnderlineDisappearsWhenCursorMoved() {
|
public void testBlueUnderlineDisappearsWhenCursorMoved() {
|
||||||
final String STRING_TO_TYPE = "tgis";
|
final String STRING_TO_TYPE = "tgis";
|
||||||
|
final int typedLength = STRING_TO_TYPE.length();
|
||||||
final int NEW_CURSOR_POSITION = 0;
|
final int NEW_CURSOR_POSITION = 0;
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
// Simulate the onUpdateSelection() event
|
// Simulate the onUpdateSelection() event
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, typedLength, typedLength, -1, -1);
|
||||||
runMessages();
|
runMessages();
|
||||||
// Here the blue underline has been set. testBlueUnderline() is testing for this already,
|
// Here the blue underline has been set. testBlueUnderline() is testing for this already,
|
||||||
// so let's not test it here again.
|
// so let's not test it here again.
|
||||||
// Now simulate the user moving the cursor.
|
// Now simulate the user moving the cursor.
|
||||||
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
||||||
mLatinIME.onUpdateSelection(0, 0, NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
final SpanGetter span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
||||||
|
|
|
@ -86,6 +86,7 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
|
|
||||||
public void testDeleteSelection() {
|
public void testDeleteSelection() {
|
||||||
final String STRING_TO_TYPE = "some text delete me some text";
|
final String STRING_TO_TYPE = "some text delete me some text";
|
||||||
|
final int typedLength = STRING_TO_TYPE.length();
|
||||||
final int SELECTION_START = 10;
|
final int SELECTION_START = 10;
|
||||||
final int SELECTION_END = 19;
|
final int SELECTION_END = 19;
|
||||||
final String EXPECTED_RESULT = "some text some text";
|
final String EXPECTED_RESULT = "some text some text";
|
||||||
|
@ -94,10 +95,11 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
// Send once to simulate the cursor actually responding to the move caused by typing.
|
// Send once to simulate the cursor actually responding to the move caused by typing.
|
||||||
// This is necessary because LatinIME is bookkeeping to avoid confusing a real cursor
|
// This is necessary because LatinIME is bookkeeping to avoid confusing a real cursor
|
||||||
// move with a move triggered by LatinIME inputting stuff.
|
// move with a move triggered by LatinIME inputting stuff.
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, typedLength, typedLength, -1, -1);
|
||||||
mInputConnection.setSelection(SELECTION_START, SELECTION_END);
|
mInputConnection.setSelection(SELECTION_START, SELECTION_END);
|
||||||
// And now we simulate the user actually selecting some text.
|
// And now we simulate the user actually selecting some text.
|
||||||
mLatinIME.onUpdateSelection(0, 0, SELECTION_START, SELECTION_END, -1, -1);
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
|
SELECTION_START, SELECTION_END, -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Keyboard.CODE_DELETE);
|
||||||
assertEquals("delete selection", EXPECTED_RESULT, mTextView.getText().toString());
|
assertEquals("delete selection", EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
}
|
}
|
||||||
|
@ -163,12 +165,14 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
|
|
||||||
public void testBackspaceAtStartAfterAutocorrect() {
|
public void testBackspaceAtStartAfterAutocorrect() {
|
||||||
final String STRING_TO_TYPE = "tgis ";
|
final String STRING_TO_TYPE = "tgis ";
|
||||||
|
final int typedLength = STRING_TO_TYPE.length();
|
||||||
final String EXPECTED_RESULT = "this ";
|
final String EXPECTED_RESULT = "this ";
|
||||||
final int NEW_CURSOR_POSITION = 0;
|
final int NEW_CURSOR_POSITION = 0;
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, typedLength, typedLength, -1, -1);
|
||||||
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
||||||
mLatinIME.onUpdateSelection(0, 0, NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Keyboard.CODE_DELETE);
|
||||||
assertEquals("auto correct then move cursor to start of line then backspace",
|
assertEquals("auto correct then move cursor to start of line then backspace",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
|
@ -176,12 +180,14 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
|
|
||||||
public void testAutoCorrectThenMoveCursorThenBackspace() {
|
public void testAutoCorrectThenMoveCursorThenBackspace() {
|
||||||
final String STRING_TO_TYPE = "and tgis ";
|
final String STRING_TO_TYPE = "and tgis ";
|
||||||
|
final int typedLength = STRING_TO_TYPE.length();
|
||||||
final String EXPECTED_RESULT = "andthis ";
|
final String EXPECTED_RESULT = "andthis ";
|
||||||
final int NEW_CURSOR_POSITION = STRING_TO_TYPE.indexOf('t');
|
final int NEW_CURSOR_POSITION = STRING_TO_TYPE.indexOf('t');
|
||||||
type(STRING_TO_TYPE);
|
type(STRING_TO_TYPE);
|
||||||
mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1);
|
mLatinIME.onUpdateSelection(0, 0, typedLength, typedLength, -1, -1);
|
||||||
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
mInputConnection.setSelection(NEW_CURSOR_POSITION, NEW_CURSOR_POSITION);
|
||||||
mLatinIME.onUpdateSelection(0, 0, NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
mLatinIME.onUpdateSelection(typedLength, typedLength,
|
||||||
|
NEW_CURSOR_POSITION, NEW_CURSOR_POSITION, -1, -1);
|
||||||
type(Keyboard.CODE_DELETE);
|
type(Keyboard.CODE_DELETE);
|
||||||
assertEquals("auto correct then move cursor then backspace",
|
assertEquals("auto correct then move cursor then backspace",
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.suggestions.SuggestionStripView;
|
||||||
|
|
||||||
public class InputLogicTestsNonEnglish extends InputTestsBase {
|
public class InputLogicTestsNonEnglish extends InputTestsBase {
|
||||||
|
final String NEXT_WORD_PREDICTION_OPTION = "next_word_prediction";
|
||||||
|
|
||||||
public void testAutoCorrectForFrench() {
|
public void testAutoCorrectForFrench() {
|
||||||
final String STRING_TO_TYPE = "irq ";
|
final String STRING_TO_TYPE = "irq ";
|
||||||
|
@ -43,16 +46,40 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
|
||||||
final String WORD_TO_TYPE = "test ";
|
final String WORD_TO_TYPE = "test ";
|
||||||
final String PUNCTUATION_FROM_STRIP = "!";
|
final String PUNCTUATION_FROM_STRIP = "!";
|
||||||
final String EXPECTED_RESULT = "test !!";
|
final String EXPECTED_RESULT = "test !!";
|
||||||
|
final boolean defaultNextWordPredictionOption =
|
||||||
|
mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_prediction);
|
||||||
|
final boolean previousNextWordPredictionOption =
|
||||||
|
setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false,
|
||||||
|
defaultNextWordPredictionOption);
|
||||||
|
try {
|
||||||
|
changeLanguage("fr");
|
||||||
|
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 for French",
|
||||||
|
EXPECTED_RESULT, mTextView.getText().toString());
|
||||||
|
} finally {
|
||||||
|
setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
|
||||||
|
defaultNextWordPredictionOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testWordThenSpaceDisplaysPredictions() {
|
||||||
|
final String WORD_TO_TYPE = "beaujolais ";
|
||||||
|
final String EXPECTED_RESULT = "nouveau";
|
||||||
changeLanguage("fr");
|
changeLanguage("fr");
|
||||||
type(WORD_TO_TYPE);
|
type(WORD_TO_TYPE);
|
||||||
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
sleep(DELAY_TO_WAIT_FOR_UNDERLINE);
|
||||||
runMessages();
|
runMessages();
|
||||||
assertTrue("type word then type space should display punctuation strip",
|
final SuggestionStripView suggestionStripView =
|
||||||
mLatinIME.isShowingPunctuationList());
|
(SuggestionStripView)mInputView.findViewById(R.id.suggestion_strip_view);
|
||||||
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
final SuggestedWords suggestedWords = suggestionStripView.getSuggestions();
|
||||||
pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
|
assertEquals("type word then type space yields predictions for French",
|
||||||
assertEquals("type word then type space then punctuation from strip twice for French",
|
EXPECTED_RESULT, suggestedWords.getWord(0));
|
||||||
EXPECTED_RESULT, mTextView.getText().toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoCorrectForGerman() {
|
public void testAutoCorrectForGerman() {
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
protected LatinIME mLatinIME;
|
protected LatinIME mLatinIME;
|
||||||
protected Keyboard mKeyboard;
|
protected Keyboard mKeyboard;
|
||||||
protected MyTextView mTextView;
|
protected MyTextView mTextView;
|
||||||
|
protected View mInputView;
|
||||||
protected InputConnection mInputConnection;
|
protected InputConnection mInputConnection;
|
||||||
private final HashMap<String, InputMethodSubtype> mSubtypeMap =
|
private final HashMap<String, InputMethodSubtype> mSubtypeMap =
|
||||||
new HashMap<String, InputMethodSubtype>();
|
new HashMap<String, InputMethodSubtype>();
|
||||||
|
@ -150,9 +151,9 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
final LayoutInflater inflater =
|
final LayoutInflater inflater =
|
||||||
(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
final ViewGroup vg = new FrameLayout(getContext());
|
final ViewGroup vg = new FrameLayout(getContext());
|
||||||
final View inputView = inflater.inflate(R.layout.input_view, vg);
|
mInputView = inflater.inflate(R.layout.input_view, vg);
|
||||||
mLatinIME.onCreateInputMethodInterface().startInput(ic, ei);
|
mLatinIME.onCreateInputMethodInterface().startInput(ic, ei);
|
||||||
mLatinIME.setInputView(inputView);
|
mLatinIME.setInputView(mInputView);
|
||||||
mLatinIME.onBindInput();
|
mLatinIME.onBindInput();
|
||||||
mLatinIME.onCreateInputView();
|
mLatinIME.onCreateInputView();
|
||||||
mLatinIME.onStartInputView(ei, false);
|
mLatinIME.onStartInputView(ei, false);
|
||||||
|
|
Loading…
Reference in New Issue