summaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/utils/CustomMatchers.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/androidTest/java/utils/CustomMatchers.java')
-rw-r--r--app/src/androidTest/java/utils/CustomMatchers.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/src/androidTest/java/utils/CustomMatchers.java b/app/src/androidTest/java/utils/CustomMatchers.java
new file mode 100644
index 00000000..5fe11cd2
--- /dev/null
+++ b/app/src/androidTest/java/utils/CustomMatchers.java
@@ -0,0 +1,31 @@
+package utils;
+
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+public class CustomMatchers {
+
+ public static Matcher<View> childAtPosition(
+ final Matcher<View> parentMatcher, final int position) {
+
+ return new TypeSafeMatcher<View>() {
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("Child at position " + position + " in parent ");
+ parentMatcher.describeTo(description);
+ }
+
+ @Override
+ public boolean matchesSafely(View view) {
+ ViewParent parent = view.getParent();
+ return parent instanceof ViewGroup && parentMatcher.matches(parent)
+ && view.equals(((ViewGroup) parent).getChildAt(position));
+ }
+ };
+ }
+}