32 lines
975 B
Java
32 lines
975 B
Java
package cy.agorise.crystalwallet.Assertions;
|
|
|
|
import androidx.test.espresso.NoMatchingViewException;
|
|
import androidx.test.espresso.ViewAssertion;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import android.view.View;
|
|
|
|
import static org.hamcrest.MatcherAssert.assertThat;
|
|
import static org.hamcrest.Matchers.is;
|
|
|
|
/**
|
|
* Created by Henry Varona on 19/9/2017.
|
|
*/
|
|
|
|
public class RecyclerViewItemsCountAssertion implements ViewAssertion {
|
|
private final int expectedCount;
|
|
|
|
public RecyclerViewItemsCountAssertion(int expectedCount) {
|
|
this.expectedCount = expectedCount;
|
|
}
|
|
|
|
@Override
|
|
public void check(View view, NoMatchingViewException noViewFoundException) {
|
|
if (noViewFoundException != null) {
|
|
throw noViewFoundException;
|
|
}
|
|
|
|
RecyclerView recyclerView = (RecyclerView) view;
|
|
RecyclerView.Adapter adapter = recyclerView.getAdapter();
|
|
assertThat(adapter.getItemCount(), is(expectedCount));
|
|
}
|
|
} |