Created
January 29, 2021 17:23
-
-
Save NinoDLC/824094aa99bae7ca4f508b1791d51674 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.View; | |
import androidx.annotation.IdRes; | |
import androidx.test.espresso.UiController; | |
import androidx.test.espresso.ViewAction; | |
import org.hamcrest.Matcher; | |
public class ClickChildViewWithId implements ViewAction { | |
@IdRes | |
private final int viewId; | |
public ClickChildViewWithId(@IdRes int viewId) { | |
this.viewId = viewId; | |
} | |
@Override | |
public Matcher<View> getConstraints() { | |
return null; | |
} | |
@Override | |
public String getDescription() { | |
return "Click on a child view with specified id : " + viewId; | |
} | |
@Override | |
public void perform(UiController uiController, View view) { | |
View v = view.findViewById(viewId); | |
v.performClick(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment