Java 类android.support.test.espresso.action.GeneralSwipeAction 实例源码
项目:orgzly-android
文件:NewNoteTest.java
@Test
public void testNewNoteFromQuickMenuWhenCabIsDisplayed() {
shelfTestUtils.setupBook("booky", "Booky Preface\n* 1\n** 2\n*** 3\n*** 4\n** 5\n* 6");
activityRule.launchActivity(null);
onView(allOf(withText("booky"), isDisplayed())).perform(click());
onView(withId(R.id.action_context_bar)).check(matches(not(isDisplayed())));
onListItem(2).perform(longClick());
/* Swipe left. */
onListItem(2).perform(new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER, GeneralLocation.CENTER_LEFT, Press.FINGER));
onView(withId(R.id.action_context_bar)).check(matches(isDisplayed()));
onListItem(2).onChildView(withId(R.id.item_menu_new_under_btn)).perform(click());
onView(withId(R.id.fragment_note_title)).check(matches(isDisplayed()));
onView(withId(R.id.done)).check(matches(isDisplayed()));
onView(withId(R.id.action_context_bar)).check(matches(not(isDisplayed())));
}
项目:material-components-android
文件:BottomSheetBehaviorTest.java
@Test
@MediumTest
public void testSwipeUpToExpand() {
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
.perform(
DesignViewActions.withCustomConstraints(
new GeneralSwipeAction(
Swipe.FAST,
GeneralLocation.VISIBLE_CENTER,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
return new float[] {view.getWidth() / 2, 0};
}
},
Press.FINGER),
ViewMatchers.isDisplayingAtLeast(5)));
registerIdlingResourceCallback();
try {
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_EXPANDED));
} finally {
unregisterIdlingResourceCallback();
}
}
项目:SwipeCoordinator
文件:ViewActions.java
static ViewAction swipeRightNotReachingThreshold(Context context) {
final float x = getWidthScreen(context) * 0.3f;
return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
@Override public float[] calculateCoordinates(View view) {
return new float[] {x, 0f};
}
}, Press.FINGER);
}
项目:SwipeCoordinator
文件:ViewActions.java
static ViewAction swipeRightReachingThreshold(Context context) {
final float x = getWidthScreen(context) * 0.8f;
return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
@Override public float[] calculateCoordinates(View view) {
return new float[] {x, 0f};
}
}, Press.FINGER);
}
项目:SwipeCoordinator
文件:ViewActions.java
static ViewAction swipeDownNotReachingThreshold(Context context) {
final float y = getHeightScreen(context) * 0.3f;
return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
@Override public float[] calculateCoordinates(View view) {
return new float[] {0f, y};
}
}, Press.FINGER);
}
项目:SwipeCoordinator
文件:ViewActions.java
static ViewAction swipeDownReachingThreshold(Context context) {
final float y = getHeightScreen(context) * 0.8f;
return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_LEFT, new CoordinatesProvider() {
@Override public float[] calculateCoordinates(View view) {
return new float[] {0f, y};
}
}, Press.FINGER);
}
项目:Material-BottomNavigation
文件:ViewActionsCompat.java
public static ViewAction swipeUp(final Swiper swipe) {
return ViewActions.actionWithAssertions(new GeneralSwipeAction(
swipe,
GeneralLocation.CENTER,
GeneralLocation.TOP_CENTER,
Press.FINGER
));
}
项目:Material-BottomNavigation
文件:ViewActionsCompat.java
public static ViewAction swipeDown(final Swiper swipe) {
return ViewActions.actionWithAssertions(new GeneralSwipeAction(
swipe,
GeneralLocation.CENTER,
GeneralLocation.BOTTOM_CENTER,
Press.FINGER
));
}
项目:material-components-android
文件:BottomSheetBehaviorTest.java
@Test
@MediumTest
public void testHalfExpandedToExpanded() throws Throwable {
getBehavior().setFitToContents(false);
checkSetState(BottomSheetBehavior.STATE_HALF_EXPANDED, ViewMatchers.isDisplayed());
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
.perform(
DesignViewActions.withCustomConstraints(
new GeneralSwipeAction(
Swipe.FAST,
GeneralLocation.VISIBLE_CENTER,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
return new float[] {view.getWidth() / 2, 0};
}
},
Press.FINGER),
ViewMatchers.isDisplayingAtLeast(5)));
registerIdlingResourceCallback();
try {
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_EXPANDED));
} finally {
unregisterIdlingResourceCallback();
}
}
项目:material-components-android
文件:BottomSheetBehaviorTest.java
@Test
@MediumTest
public void testCollapsedToExpanded() throws Throwable {
getBehavior().setFitToContents(false);
checkSetState(BottomSheetBehavior.STATE_COLLAPSED, ViewMatchers.isDisplayed());
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
.perform(
DesignViewActions.withCustomConstraints(
new GeneralSwipeAction(
Swipe.FAST,
GeneralLocation.VISIBLE_CENTER,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
return new float[] {view.getWidth() / 2, 0};
}
},
Press.FINGER),
ViewMatchers.isDisplayingAtLeast(5)));
registerIdlingResourceCallback();
try {
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_EXPANDED));
} finally {
unregisterIdlingResourceCallback();
}
}
项目:material-components-android
文件:BottomSheetBehaviorTest.java
@Test
@MediumTest
public void testInvisible() throws Throwable {
// Make the bottomsheet invisible
activityTestRule.runOnUiThread(
new Runnable() {
@Override
public void run() {
getBottomSheet().setVisibility(View.INVISIBLE);
assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_COLLAPSED));
}
});
// Swipe up as if to expand it
Espresso.onView(ViewMatchers.withId(R.id.bottom_sheet))
.perform(
DesignViewActions.withCustomConstraints(
new GeneralSwipeAction(
Swipe.FAST,
GeneralLocation.VISIBLE_CENTER,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
return new float[] {view.getWidth() / 2, 0};
}
},
Press.FINGER),
not(ViewMatchers.isDisplayed())));
// Check that the bottom sheet stays the same collapsed state
activityTestRule.runOnUiThread(
new Runnable() {
@Override
public void run() {
assertThat(getBehavior().getState(), is(BottomSheetBehavior.STATE_COLLAPSED));
}
});
}
项目:Bill-Calculator
文件:Tester.java
ViewAction swipeAwayRight() {
return actionWithAssertions(new GeneralSwipeAction(Swipe.FAST,
GeneralLocation.CENTER,
new CoordinatesProvider() {
@Override
public float[] calculateCoordinates(View view) {
float xy[] = GeneralLocation.CENTER_RIGHT.calculateCoordinates(view);
xy[0] += 20f * view.getWidth();
return xy;
}
},
Press.FINGER));
}
项目:Ironhide
文件:SwipeAction.java
/**
* Gets a swipe action.
*
* @param speed the speed of the swipe
* @param direction the direction of the swipe
* @return the swipe action requested
*/
public static GeneralSwipeAction getSwipe(Swiper speed, SwipeDirection direction) {
Pair<Swiper, SwipeDirection> key = new Pair<>(speed, direction);
if (!bufferedSwipeActions.containsKey(key))
bufferedSwipeActions.put(key, generateSwipe(speed, direction));
return bufferedSwipeActions.get(key);
}
项目:SwipeOpenItemTouchHelper
文件:SwipeOpenItemTouchHelperTest.java
/**
* Uses a slow swipe to simulate a scroll
* @return the view action
*/
private ViewAction scroll() {
return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.BOTTOM_CENTER,
GeneralLocation.TOP_CENTER, Press.FINGER);
}
项目:SwipeOpenItemTouchHelper
文件:SwipeOpenItemTouchHelperTest.java
private static ViewAction swipeRight() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_LEFT,
GeneralLocation.CENTER_RIGHT, Press.FINGER);
}
项目:SwipeOpenItemTouchHelper
文件:SwipeOpenItemTouchHelperTest.java
private static ViewAction swipeLeft() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_RIGHT,
GeneralLocation.CENTER_LEFT, Press.FINGER);
}
项目:tagscout
文件:TagsScreenTest.java
public static ViewAction swipeDown() {
return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_CENTER,
GeneralLocation.BOTTOM_CENTER, Press.FINGER
);
}
项目:PrettyBundle
文件:ExtViewActions.java
public static ViewAction swipeTop() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.BOTTOM_CENTER, GeneralLocation.TOP_CENTER, Press.FINGER);
}
项目:PrettyBundle
文件:ExtViewActions.java
public static ViewAction swipeBottom() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.TOP_CENTER, GeneralLocation.BOTTOM_CENTER, Press.FINGER);
}
项目:agera
文件:MainActivityTest.java
private static ViewAction swipeDown() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.TOP_CENTER,
GeneralLocation.BOTTOM_CENTER, Press.FINGER);
}
项目:agera
文件:MainActivityTest.java
private static ViewAction swipeDown() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.TOP_CENTER,
GeneralLocation.BOTTOM_CENTER, Press.FINGER);
}
项目:RxBinding
文件:RxViewPagerTest.java
private static ViewAction swipeLeft() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_RIGHT,
GeneralLocation.CENTER_LEFT, Press.FINGER);
}
项目:RxBinding
文件:RxSwipeRefreshLayoutTest.java
private static ViewAction swipeDown() {
return new GeneralSwipeAction(Swipe.SLOW, GeneralLocation.TOP_CENTER,
GeneralLocation.BOTTOM_CENTER, Press.FINGER);
}
项目:RxBinding
文件:RxSwipeDismissBehaviorTest.java
private static ViewAction swipeRight() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_LEFT,
GeneralLocation.CENTER_RIGHT, Press.FINGER);
}
项目:u2020-mvp
文件:ViewActions.java
public static ViewAction swipeTop() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.BOTTOM_CENTER, GeneralLocation.TOP_CENTER, Press.FINGER);
}
项目:u2020-mvp
文件:ViewActions.java
public static ViewAction swipeBottom() {
return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.TOP_CENTER, GeneralLocation.BOTTOM_CENTER, Press.FINGER);
}
项目:GitHub
文件:Utils.java
/**
* Returns an action that performs a swipe right-to-left across the vertical center of the
* view. The swipe doesn't start at the very edge of the view, but is a bit offset.<br>
* <br>
* View constraints:
* <ul>
* <li>must be displayed on screen
* <ul>
*/
public static ViewAction swipeLeftSlow() {
return actionWithAssertions(new GeneralSwipeAction(Swipe.SLOW,
translate(GeneralLocation.CENTER_RIGHT, -EDGE_FUZZ_FACTOR, 0),
GeneralLocation.CENTER_LEFT, Press.FINGER));
}
项目:GitHub
文件:Utils.java
/**
* Returns an action that performs a swipe left-to-right across the vertical center of the
* view. The swipe doesn't start at the very edge of the view, but is a bit offset.<br>
* <br>
* View constraints:
* <ul>
* <li>must be displayed on screen
* <ul>
*/
public static ViewAction swipeRightSlow() {
return actionWithAssertions(new GeneralSwipeAction(Swipe.SLOW,
translate(GeneralLocation.CENTER_LEFT, EDGE_FUZZ_FACTOR, 0),
GeneralLocation.CENTER_RIGHT, Press.FINGER));
}
项目:GitHub
文件:Utils.java
/**
* Returns an action that performs a swipe top-to-bottom across the horizontal center of the view.
* The swipe doesn't start at the very edge of the view, but has a bit of offset.<br>
* <br>
* View constraints:
* <ul>
* <li>must be displayed on screen
* <ul>
*/
public static ViewAction swipeDownSlow() {
return actionWithAssertions(new GeneralSwipeAction(Swipe.SLOW,
translate(GeneralLocation.TOP_CENTER, 0, EDGE_FUZZ_FACTOR),
GeneralLocation.BOTTOM_CENTER, Press.FINGER));
}
项目:GitHub
文件:Utils.java
/**
* Returns an action that performs a swipe bottom-to-top across the horizontal center of the view.
* The swipe doesn't start at the very edge of the view, but has a bit of offset.<br>
* <br>
* View constraints:
* <ul>
* <li>must be displayed on screen
* <ul>
*/
public static ViewAction swipeUpSlow() {
return actionWithAssertions(new GeneralSwipeAction(Swipe.SLOW,
translate(GeneralLocation.BOTTOM_CENTER, 0, -EDGE_FUZZ_FACTOR),
GeneralLocation.TOP_CENTER, Press.FINGER));
}
项目:espresso-macchiato
文件:EspDrawer.java
/**
* Open the drawer.
*
* @since Espresso Macchiato 0.1
*/
public void open() {
findDrawerLayout().perform(ViewActions.actionWithAssertions(new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_LEFT, GeneralLocation.CENTER_RIGHT, Press.FINGER)));
}
项目:espresso-macchiato
文件:EspDrawer.java
/**
* Close the drawer.
*
* @since Espresso Macchiato 0.1
*/
public void close() {
findDrawerLayout().perform(ViewActions.actionWithAssertions(new GeneralSwipeAction(Swipe.FAST, GeneralLocation.CENTER_RIGHT, GeneralLocation.CENTER_LEFT, Press.FINGER)));
}
项目:Ironhide
文件:SwipeAction.java
/**
* Creates a new swipe action.
*
* @param speed the speed of the swipe
* @param direction the direction of the swipe
* @return the swipe action requested
*/
private static GeneralSwipeAction generateSwipe(Swiper speed, SwipeDirection direction) {
return new GeneralSwipeAction(speed, direction.start, direction.end, Press.FINGER);
}