skyisle / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
1 stars 0 forks source link

TypeTextAction not supported for android.support.v7.widget.SearchView #54

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a search interface 
(http://developer.android.com/guide/topics/search/search-dialog.html)
2. Create a test for the search activity
3. public void testSearch() throws Exception {
        Matcher<View> matcherView = withId(R.id.menu_search);

        onView(matcherView)
            .perform(click());

        onView(withParent(matcherView))
            .perform(typeText("test"), pressImeActionButton());
    }

What is the expected output? 

A "Test passed" message.

What do you see instead?

java.lang.RuntimeException: Action will not be performed because the target 
view does not match one or more of the following constraints:
((is displayed on the screen to the user) and (supports input methods or is 
assignable from class: class android.widget.SearchView))

What version of the product are you using? 

espresso-1.1

On what operating system?

OS X Version 10.8.4

Please provide any additional information below.

I have checked TypeTextAction.java class to see what is going wrong and that's 
what I've found:

@SuppressWarnings("unchecked")
  @Override
  public Matcher<View> getConstraints() {
    Matcher<View> matchers = allOf(isDisplayed());
    if (!tapToFocus) {
      matchers = allOf(matchers, hasFocus());
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
       return allOf(matchers, supportsInputMethods());
    } else {
       // SearchView does not support input methods itself (rather it delegates to an internal text
       // view for input).
       return allOf(matchers, anyOf(supportsInputMethods(), isAssignableFrom(SearchView.class)));
    }
  }

Apparently, it's being checked just if the matchers "isAssignabledFrom" 
SearchView.class (android.widget.SearchView).

If I'm using android.support.v7.widget.SearchView, what should I do to match 
this constraint?

Original issue reported on code.google.com by sagui...@gmail.com on 10 Feb 2014 at 8:24

GoogleCodeExporter commented 9 years ago

Original comment by vale...@google.com on 7 May 2014 at 7:10