本文整理汇总了Java中android.support.test.espresso.action.GeneralLocation类的典型用法代码示例。如果您正苦于以下问题:Java GeneralLocation类的具体用法?Java GeneralLocation怎么用?Java GeneralLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeneralLocation类属于android.support.test.espresso.action包,在下文中一共展示了GeneralLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSwipeUpToExpand
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
@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();
}
}
开发者ID:material-components,项目名称:material-components-android,代码行数:27,代码来源:BottomSheetBehaviorTest.java
示例2: clickDescendantViewWithId
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
/**
* 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);
}
};
}
示例3: testNewNoteFromQuickMenuWhenCabIsDisplayed
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
@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())));
}
示例4: clickDescendantViewWithId
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
/**
* 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);
}
};
}
示例5: swipeRightNotReachingThreshold
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
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);
}
示例6: swipeRightReachingThreshold
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
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);
}
示例7: swipeDownNotReachingThreshold
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
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);
}
示例8: swipeDownReachingThreshold
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
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);
}
示例9: swipeUp
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
public static ViewAction swipeUp(final Swiper swipe) {
return ViewActions.actionWithAssertions(new GeneralSwipeAction(
swipe,
GeneralLocation.CENTER,
GeneralLocation.TOP_CENTER,
Press.FINGER
));
}
示例10: swipeDown
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
public static ViewAction swipeDown(final Swiper swipe) {
return ViewActions.actionWithAssertions(new GeneralSwipeAction(
swipe,
GeneralLocation.CENTER,
GeneralLocation.BOTTOM_CENTER,
Press.FINGER
));
}
示例11: testHalfExpandedToExpanded
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
@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();
}
}
开发者ID:material-components,项目名称:material-components-android,代码行数:29,代码来源:BottomSheetBehaviorTest.java
示例12: testCollapsedToExpanded
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
@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();
}
}
开发者ID:material-components,项目名称:material-components-android,代码行数:29,代码来源:BottomSheetBehaviorTest.java
示例13: testInvisible
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
@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));
}
});
}
开发者ID:material-components,项目名称:material-components-android,代码行数:37,代码来源:BottomSheetBehaviorTest.java
示例14: swipeBottomSheetDown
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
public static ViewAction swipeBottomSheetDown() {
/* The default swipe action has a constraint where the swiped view has to be displayed in at least 90%,
* which is not the case with bottom sheets...
*/
return new NoConstraintsSwipeAction(Swipe.FAST, GeneralLocation.TOP_CENTER,
GeneralLocation. BOTTOM_CENTER, Press.FINGER);
}
示例15: swipeBottomSheetUp
import android.support.test.espresso.action.GeneralLocation; //导入依赖的package包/类
public static ViewAction swipeBottomSheetUp() {
/* The default swipe action has a constraint where the swiped view has to be displayed in at least 90%,
* which is not the case with bottom sheets...
*/
return new NoConstraintsSwipeAction(Swipe.FAST, GeneralLocation.VISIBLE_CENTER,
GeneralLocation. TOP_CENTER, Press.FINGER);
}