Issue
I run the code belows and got error at return anything();
error: incompatible types
required: Matcher <View>
found: Matcher <Object>
/**
* Perform action of waiting until UI thread is free. <p/> E.g.: onView(isRoot()).perform(waitUntilIdle());
* @return
*/
public static ViewAction waitUntilIdle(){
return new ViewAction(){
@Override public Matcher<View> getConstraints(){
return anything();
}
@Override public String getDescription(){
return "wait until UI thread is free";
}
@Override public void perform( final UiController uiController, final View view){
uiController.loopMainThreadUntilIdle();
}
}
;
}
Any ideas?
Solution
anything()
is not a generic method, so you will always get a Matcher<Object>
.
Internally anything()
uses the IsAnything
class. You can make your own anyView()
method to return a Matcher<View>
.
public static ViewAction waitUntilIdle(){
return new ViewAction(){
@Override public Matcher<View> getConstraints(){
return anyView();
}
@NonNull
private Matcher<View> anyView() {
return new IsAnything<>();
}
@Override public String getDescription(){
return "wait until UI thread is free";
}
@Override public void perform( final UiController uiController, final View view){
uiController.loopMainThreadUntilIdle();
}
}
;
}
Answered By - yogurtearl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.