Java 类android.support.test.espresso.action.GeneralClickAction 实例源码
项目:espresso-commons
文件:RecyclerViewUtils.java
/**
* Returns an action that clicks a descendant of the view matched with the given resource id.
*
* @param id resource id of the view to click.
* @return an action that clicks a descendant of the view matched with the given resource id.
*/
public static ViewAction clickDescendantViewWithId(@IdRes final int id) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return hasDescendant(withId(id));
}
@Override
public String getDescription() {
return "Click on a descendant view with id: " + id;
}
@Override
public void perform(UiController uiController, View view) {
GeneralClickAction action = new GeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER);
View target = view.findViewById(id);
// getConstraints() guarantees that the target never be null.
action.perform(uiController, target);
}
};
}
项目:espresso-sample-for-droidkaigi2017
文件:RecyclerViewUtils.java
/**
* Returns an action that clicks a descendant of the view matched with the given resource id.
*/
public static ViewAction clickDescendantViewWithId(@IdRes final int id) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return hasDescendant(withId(id));
}
@Override
public String getDescription() {
return "Click on a descendant view with id: " + id;
}
@Override
public void perform(UiController uiController, View view) {
GeneralClickAction action = new GeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER);
View target = view.findViewById(id);
// getConstraints() guarantees that the target never be null.
action.perform(uiController, target);
}
};
}
项目:SmoothClicker
文件:ItSelectMultiPointsActivity.java
/**
* Custom ViewAction to click on dedicated coordinates
* @param x -
* @param y -
* @return ViewAction -
*/
private ViewAction clickXY( final int x, final int y ){
return new GeneralClickAction(
Tap.SINGLE,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates( View view ){
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
final float screenX = screenPos[0] + x;
final float screenY = screenPos[1] + y;
return new float[]{screenX, screenY};
}
},
Press.FINGER);
}
项目:SmoothClicker
文件:ItClickerActivity.java
/**
* Custom ViewAction to click on dedicated coordinates
* @param x -
* @param y -
* @return ViewAction -
*/
private ViewAction clickXY( final int x, final int y ){
return new GeneralClickAction(
Tap.SINGLE,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates( View view ){
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
final float screenX = screenPos[0] + x;
final float screenY = screenPos[1] + y;
return new float[]{screenX, screenY};
}
},
Press.FINGER);
}
项目:Todo.txt-gDrive
文件:MainActivityTest.java
private static ViewAction clickXY(final int x, final int y) {
return new GeneralClickAction(
Tap.SINGLE,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
final float screenX = screenPos[0] + x;
final float screenY = screenPos[1] + y;
float[] coordinates = {screenX, screenY};
return coordinates;
}
},
Press.FINGER);
}
项目:translationRecorder
文件:TestUtils.java
public static ViewAction clickXY(final int x, final int y){
return new GeneralClickAction(
Tap.SINGLE,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
final float screenX = screenPos[0] + x;
final float screenY = screenPos[1] + y;
float[] coordinates = {screenX, screenY};
return coordinates;
}
},
Press.FINGER);
}
项目:akvo-caddisfly
文件:TestUtil.java
public static ViewAction clickPercent(final float pctX, final float pctY) {
return new GeneralClickAction(
Tap.SINGLE,
view -> {
final int[] screenPos = new int[2];
view.getLocationOnScreen(screenPos);
int w = view.getWidth();
int h = view.getHeight();
float x = w * pctX;
float y = h * pctY;
final float screenX = screenPos[0] + x;
final float screenY = screenPos[1] + y;
return new float[]{screenX, screenY};
},
Press.FINGER);
}
项目:ChimpCheck
文件:ChimpActionFactory.java
public static ViewAction clickXY(final int x, final int y){
return new GeneralClickAction(
Tap.SINGLE,
getCoordinatesProvider(x, y),
Press.FINGER);
}
项目:ChimpCheck
文件:ChimpActionFactory.java
public static ViewAction longClickXY(final int x, final int y){
return new GeneralClickAction(
Tap.LONG,
getCoordinatesProvider(x, y),
Press.FINGER);
}
项目:material-activity-chooser
文件:ViewActions.java
public static ViewAction clickOnTop() {
return new GeneralClickAction(Tap.SINGLE, GeneralLocation.TOP_CENTER, Press.FINGER);
}
项目:easy-adapter
文件:CustomViewActions.java
public static ViewAction clickOnChild(int childViewId) {
return actionWithAssertions((new ChildClickAction(
new GeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER),
childViewId)));
}
项目:easy-adapter
文件:CustomViewActions.java
public ChildClickAction(GeneralClickAction generalClickAction, int childViewId) {
mGeneralClickAction = generalClickAction;
mChildViewId = childViewId;
}