Search in sources :

Example 11 with SuggestionSpan

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")));
}
Also used : SuggestionSpan(android.text.style.SuggestionSpan) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 12 with SuggestionSpan

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();
}
Also used : SuggestionSpan(android.text.style.SuggestionSpan) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 13 with SuggestionSpan

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.
}
Also used : SuggestionSpan(android.text.style.SuggestionSpan) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 14 with SuggestionSpan

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));
}
Also used : SuggestionSpan(android.text.style.SuggestionSpan) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 15 with SuggestionSpan

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.
}
Also used : SuggestionSpan(android.text.style.SuggestionSpan) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SuggestionSpan (android.text.style.SuggestionSpan)114 Paint (android.graphics.Paint)43 SmallTest (android.test.suitebuilder.annotation.SmallTest)35 Spannable (android.text.Spannable)29 Spanned (android.text.Spanned)24 Editable (android.text.Editable)21 TextPaint (android.text.TextPaint)21 SpannableString (android.text.SpannableString)14 View (android.view.View)10 SpannableStringBuilder (android.text.SpannableStringBuilder)7 SpellCheckSpan (android.text.style.SpellCheckSpan)7 Nullable (android.annotation.Nullable)5 TypedArray (android.content.res.TypedArray)5 Espresso.onView (android.support.test.espresso.Espresso.onView)5 NoMatchingViewException (android.support.test.espresso.NoMatchingViewException)5 ViewAssertion (android.support.test.espresso.ViewAssertion)5 RootMatchers.withDecorView (android.support.test.espresso.matcher.RootMatchers.withDecorView)5 BackgroundColorSpan (android.text.style.BackgroundColorSpan)5 ForegroundColorSpan (android.text.style.ForegroundColorSpan)5 ImageSpan (android.text.style.ImageSpan)5