UmA*_*orn 3 testing android android-testing android-espresso
我运行下面的代码并返回任何错误();
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();
}
}
;
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
anything()
不是一般的方法,所以你总会得到一个Matcher<Object>
.
内部anything()
使用IsAnything
该类.您可以使用自己的anyView()
方法返回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();
}
}
;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
650 次 |
最近记录: |