Sample: Wait for Service
Wait loginComplete = new Wait() {
@Override
public Boolean apply() {
return Service.isLogin() == true;
}
};
Wait.until(loginComplete);
Sample: Wait for UI
Wait playlistUpdated = new Wait() {
@Override
public Boolean apply() {
try {
onView(withText("華語速爆新歌 (每週二五更新)")).check(matches(isDisplayed()));
} catch (NoMatchingViewException e) {
// keep waiting
return false;
}
// complete
return true;
}
};
assertTrue(Wait.until(playlistUpdated));