Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumentation tests #19

Open
carlbenson opened this issue Feb 16, 2016 · 5 comments
Open

Instrumentation tests #19

carlbenson opened this issue Feb 16, 2016 · 5 comments

Comments

@carlbenson
Copy link

How can I do instrumentation tests using for instance Espresso and hamcrest view matchers if the PinEntry view does not support any input?

Caused by: 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)) Target view: "PinEntryView{id=2131427464, res-name=pin_entry, visibility=VISIBLE, width=570, height=120, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=207.0, y=154.0, child-count=5}" at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:138)

@Philio
Copy link
Owner

Philio commented Feb 16, 2016

If it doesn't meet the constraint is displayed on the screen to the user then the view must not be visible?
Could you provide some code?

@carlbenson
Copy link
Author

It's visible, but apparently it does not support any input methods.

EnterPinActivityInstrumentationTest.java.txt

@Philio
Copy link
Owner

Philio commented Feb 16, 2016

The view itself is just a view group with an EditText inside which it delegates focus to. It doesn't accept input directly so that might be the issue.

@carlbenson
Copy link
Author

So would it be possible to expose the EditText somehow so this view can be used in instrumentation tests?

@carlbenson
Copy link
Author

I'm testing using a work-around now where I simply set the text in an observable and do the check when the observable has completed (Kotlin code)

@Test                                                                                               
fun enterPinCode() {                                                                                
    val view = mActivityRule.activity.findViewById(R.id.pin_entry) as PinEntryView                  
    observable<Unit> {                                                                              
        view.setText("123")                                                                         
    }.subscribeOn(AndroidSchedulers.mainThread())                                                   
            .doOnCompleted {                                                                        
                onView(ViewMatchers.withId(R.id.pin_next_button)).check(matches(not(isDisplayed())))
            }.subscribe()                                                                           

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants