use of android.text.style.SuggestionSpan in project android_frameworks_base by ResurrectionRemix.
the class SuggestionsPopupWindowTest method testSuggestionItems.
@SmallTest
public void testSuggestionItems() {
final String text = "abc def ghi";
onView(withId(R.id.textview)).perform(click());
onView(withId(R.id.textview)).perform(replaceText(text));
final SuggestionSpan suggestionSpan = new SuggestionSpan(getActivity(), new String[] { "DEF", "Def" }, SuggestionSpan.FLAG_AUTO_CORRECTION);
setSuggestionSpan(suggestionSpan, text.indexOf('d'), text.indexOf('f') + 1);
showSuggestionsPopup();
assertSuggestionsPopupIsDisplayed();
assertSuggestionsPopupContainsItem("DEF");
assertSuggestionsPopupContainsItem("Def");
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.delete));
// Select an item.
clickSuggestionsPopupItem("DEF");
assertSuggestionsPopupIsNotDisplayed();
onView(withId(R.id.textview)).check(matches(withText("abc DEF ghi")));
showSuggestionsPopup();
assertSuggestionsPopupIsDisplayed();
assertSuggestionsPopupContainsItem("def");
assertSuggestionsPopupContainsItem("Def");
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.delete));
// Delete
clickSuggestionsPopupItem(getActivity().getString(com.android.internal.R.string.delete));
assertSuggestionsPopupIsNotDisplayed();
onView(withId(R.id.textview)).check(matches(withText("abc ghi")));
}
use of android.text.style.SuggestionSpan in project android_frameworks_base by ResurrectionRemix.
the class SuggestionsPopupWindowTest method testSelectionActionMode.
@SmallTest
public void testSelectionActionMode() {
final String text = "abc def ghi";
onView(withId(R.id.textview)).perform(click());
onView(withId(R.id.textview)).perform(replaceText(text));
final SuggestionSpan suggestionSpan = new SuggestionSpan(getActivity(), new String[] { "DEF", "Def" }, SuggestionSpan.FLAG_AUTO_CORRECTION);
setSuggestionSpan(suggestionSpan, text.indexOf('d'), text.indexOf('f') + 1);
onView(withId(R.id.textview)).perform(longPressOnTextAtIndex(text.indexOf('e')));
sleepForFloatingToolbarPopup();
assertFloatingToolbarContainsItem(getActivity().getString(com.android.internal.R.string.replace));
sleepForFloatingToolbarPopup();
clickFloatingToolbarItem(getActivity().getString(com.android.internal.R.string.replace));
assertSuggestionsPopupIsDisplayed();
}
use of android.text.style.SuggestionSpan in project android_frameworks_base by ResurrectionRemix.
the class SuggestionsPopupWindowTest method testMisspelled.
@SmallTest
public void testMisspelled() {
final String text = "abc def ghi";
onView(withId(R.id.textview)).perform(click());
onView(withId(R.id.textview)).perform(replaceText(text));
final SuggestionSpan suggestionSpan = new SuggestionSpan(getActivity(), new String[] { "DEF", "Def" }, SuggestionSpan.FLAG_MISSPELLED);
setSuggestionSpan(suggestionSpan, text.indexOf('d'), text.indexOf('f') + 1);
showSuggestionsPopup();
assertSuggestionsPopupIsDisplayed();
assertSuggestionsPopupContainsItem("DEF");
assertSuggestionsPopupContainsItem("Def");
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.addToDictionary));
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.delete));
// Click "Add to dictionary".
clickSuggestionsPopupItem(getActivity().getString(com.android.internal.R.string.addToDictionary));
// TODO: Check if add to dictionary dialog is displayed.
}
use of android.text.style.SuggestionSpan in project android_frameworks_base by DirtyUnicorns.
the class SuggestionsPopupWindowTest method testEasyCorrect.
@SmallTest
public void testEasyCorrect() {
final String text = "abc def ghi";
onView(withId(R.id.textview)).perform(click());
onView(withId(R.id.textview)).perform(replaceText(text));
final SuggestionSpan suggestionSpan = new SuggestionSpan(getActivity(), new String[] { "DEF", "Def" }, SuggestionSpan.FLAG_EASY_CORRECT | SuggestionSpan.FLAG_MISSPELLED);
setSuggestionSpan(suggestionSpan, text.indexOf('d'), text.indexOf('f') + 1);
onView(withId(R.id.textview)).perform(clickOnTextAtIndex(text.indexOf('e')));
assertSuggestionsPopupIsDisplayed();
assertSuggestionsPopupContainsItem("DEF");
assertSuggestionsPopupContainsItem("Def");
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.delete));
// Select an item.
clickSuggestionsPopupItem("DEF");
assertSuggestionsPopupIsNotDisplayed();
onView(withId(R.id.textview)).check(matches(withText("abc DEF ghi")));
onView(withId(R.id.textview)).perform(clickOnTextAtIndex(text.indexOf('e')));
assertSuggestionsPopupIsNotDisplayed();
showSuggestionsPopup();
assertSuggestionsPopupIsDisplayed();
assertSuggestionsPopupContainsItem("def");
assertSuggestionsPopupContainsItem("Def");
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.delete));
}
use of android.text.style.SuggestionSpan in project android_frameworks_base by DirtyUnicorns.
the class SuggestionsPopupWindowTest method testMisspelled.
@SmallTest
public void testMisspelled() {
final String text = "abc def ghi";
onView(withId(R.id.textview)).perform(click());
onView(withId(R.id.textview)).perform(replaceText(text));
final SuggestionSpan suggestionSpan = new SuggestionSpan(getActivity(), new String[] { "DEF", "Def" }, SuggestionSpan.FLAG_MISSPELLED);
setSuggestionSpan(suggestionSpan, text.indexOf('d'), text.indexOf('f') + 1);
showSuggestionsPopup();
assertSuggestionsPopupIsDisplayed();
assertSuggestionsPopupContainsItem("DEF");
assertSuggestionsPopupContainsItem("Def");
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.addToDictionary));
assertSuggestionsPopupContainsItem(getActivity().getString(com.android.internal.R.string.delete));
// Click "Add to dictionary".
clickSuggestionsPopupItem(getActivity().getString(com.android.internal.R.string.addToDictionary));
// TODO: Check if add to dictionary dialog is displayed.
}
Aggregations