本文整理匯總了Java中android.support.test.espresso.UiController類的典型用法代碼示例。如果您正苦於以下問題:Java UiController類的具體用法?Java UiController怎麽用?Java UiController使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UiController類屬於android.support.test.espresso包,在下文中一共展示了UiController類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clickNoConstraints
import android.support.test.espresso.UiController; //導入依賴的package包/類
static ViewAction clickNoConstraints() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isEnabled(); // No constraints, isEnabled and isClickable are checked
}
@Override
public String getDescription() {
return "Click a view with no constraints.";
}
@Override
public void perform(UiController uiController, View view) {
view.performClick();
}
};
}
示例2: fillEntropy
import android.support.test.espresso.UiController; //導入依賴的package包/類
private ViewAction fillEntropy() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return allOf(isDisplayed(), isAssignableFrom(EntropyView.class));
}
@Override
public String getDescription() {
return "Dismisses the 'Gathering entropy...' dialog";
}
@Override
public void perform(final UiController uiController, final View view) {
((EntropyView) view).notifyListeners();
}
};
}
示例3: showControls
import android.support.test.espresso.UiController; //導入依賴的package包/類
private static ViewAction showControls() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(MovieView.class);
}
@Override
public String getDescription() {
return "Show controls of MovieView";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
((MovieView) view).showControls();
uiController.loopMainThreadUntilIdle();
}
};
}
開發者ID:googlesamples,項目名稱:android-PictureInPicture,代碼行數:21,代碼來源:MediaSessionPlaybackActivityTest.java
示例4: withCustomConstraints
import android.support.test.espresso.UiController; //導入依賴的package包/類
/**
* From: http://stackoverflow.com/questions/33505953/espresso-how-to-test-swiperefreshlayout/33516360#33516360
* <p>
* ViewPager will throw an error if not 90% of it is displayed. This reduces the restriction.
*
* @param action Action to be done.
* @param constraints Restrictions on the view.
* @return Performs an action on the view.
*/
public static ViewAction withCustomConstraints(final ViewAction action, final Matcher<View> constraints)
{
return new ViewAction()
{
@Override
public Matcher<View> getConstraints()
{
return constraints;
}
@Override
public String getDescription()
{
return action.getDescription();
}
@Override
public void perform(UiController uiController, View view)
{
action.perform(uiController, view);
}
};
}
示例5: setOrientation
import android.support.test.espresso.UiController; //導入依賴的package包/類
static ViewAction setOrientation(final int orientation) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isRoot();
}
@Override
public String getDescription() {
return "Change orientation";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
changeOrientation(view, orientation);
}
};
}
示例6: perform
import android.support.test.espresso.UiController; //導入依賴的package包/類
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
int orientation = getActivityOrientation(view);
boolean checkOrientation = false;
switch (orientationType) {
case PORTRAIT:
checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|| orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
|| orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
|| orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT;
break;
case LANDSCAPE:
checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|| orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
|| orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|| orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE;
break;
}
if (checkOrientation) {
isOrientation[0] = true;
}
}
示例7: onMapChangeLocationLayerRedrawn
import android.support.test.espresso.UiController; //導入依賴的package包/類
@Test
public void onMapChangeLocationLayerRedrawn() throws Exception {
executeLocationLayerTest(new LocationLayerPluginAction.onPerformLocationLayerAction() {
@Override
public void onLocationLayerAction(LocationLayerPlugin locationLayerPlugin, MapboxMap mapboxMap,
UiController uiController) {
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);
assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER) != null);
mapboxMap.setStyleUrl(Style.SATELLITE);
uiController.loopMainThreadForAtLeast(500);
assertEquals(locationLayerPlugin.getLocationLayerMode(), LocationLayerMode.TRACKING);
assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER) != null);
assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER).getVisibility().getValue()
.equals(Property.VISIBLE));
}
});
}
示例8: swipeOnCoord
import android.support.test.espresso.UiController; //導入依賴的package包/類
public static ViewAction swipeOnCoord(final float fromX, final float fromY, final float toX, final float toY) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isRoot();
}
@Override
public String getDescription() {
return "Swipe from" + fromX + ", " + fromY + " to " + toX + ", " + toY;
}
@Override
public void perform(UiController uiController, final View view) {
drag(fromX, fromY, toX, toY);
}
};
}
示例9: perform
import android.support.test.espresso.UiController; //導入依賴的package包/類
public void perform(UiController uiController, View view) {
RecyclerView recyclerView = (RecyclerView) view;
(new ScrollToPositionViewAction(this.position)).perform(uiController, view);
uiController.loopMainThreadUntilIdle();
View targetView = recyclerView.getChildAt(this.position).findViewById(this.viewId);
if (targetView == null) {
throw (new PerformException.Builder()).withActionDescription(this.toString())
.withViewDescription(HumanReadables.describe(view))
.withCause(new IllegalStateException(
"No view with id "
+ this.viewId
+ " found at position: "
+ this.position)
)
.build();
}
else {
this.viewAction.perform(uiController, targetView);
}
}
示例10: testGoToManual
import android.support.test.espresso.UiController; //導入依賴的package包/類
/**
* Test if the manual input activity opens.
*/
@Test
public void testGoToManual() {
onView(withId(R.id.manual_input_button)).check(matches(allOf( isEnabled(), isClickable()))).perform(
new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isEnabled(); // no constraints, they are checked above
}
@Override
public String getDescription() {
return "click manual input button";
}
@Override
public void perform(UiController uiController, View view) {
view.performClick();
}
}
);
intended(hasComponent(ManualInputActivity.class.getName()));
}
示例11: setNumber
import android.support.test.espresso.UiController; //導入依賴的package包/類
/**
* Set value for {@link NumberPicker}
*/
public static ViewAction setNumber(final int n) {
return new ViewAction() {
@Override
public void perform(UiController uiController, View view) {
((NumberPicker) view).setValue(n);
}
@Override
public String getDescription() {
return "Set NumberPicker value";
}
@Override
public Matcher<View> getConstraints() {
return ViewMatchers.isAssignableFrom(NumberPicker.class);
}
};
}
示例12: getText
import android.support.test.espresso.UiController; //導入依賴的package包/類
/**
* Try to getText from TextView
*/
private String getText(final Matcher<View> matcher) {
final String[] stringHolder = { null };
onView(matcher).perform(new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextView.class);
}
@Override
public String getDescription() {
return "getting text from a TextView";
}
@Override
public void perform(UiController uiController, View view) {
TextView tv = (TextView) view;
stringHolder[0] = tv.getText().toString();
}
});
return stringHolder[0];
}
示例13: scrollToEnd
import android.support.test.espresso.UiController; //導入依賴的package包/類
public static ViewAction scrollToEnd() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(RecyclerBodyView.class);
}
@Override
public String getDescription() {
return "scroll to end";
}
@Override
public void perform(final UiController uiController, final View view) {
final RecyclerBodyView castView = (RecyclerBodyView) view;
castView.showItem(castView.getItems().size() - 1);
}
};
}
示例14: withCustomConstraints
import android.support.test.espresso.UiController; //導入依賴的package包/類
public static ViewAction withCustomConstraints(final ViewAction action, final Matcher<View> constraints) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return constraints;
}
@Override
public String getDescription() {
return action.getDescription();
}
@Override
public void perform(UiController uiController, View view) {
action.perform(uiController, view);
}
};
}
示例15: lineOffsetFunctionMotorwayBaseLayer
import android.support.test.espresso.UiController; //導入依賴的package包/類
@Test
public void lineOffsetFunctionMotorwayBaseLayer() throws Exception {
executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
@Override
public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
LineLayer layer = mapboxMap.getLayerAs(MotorWay.BASE_LAYER_ID);
assertNotNull(layer.getLineOffset());
assertNotNull(layer.getLineOffset().getFunction());
assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass());
assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass());
assertEquals(1.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001);
assertEquals(5, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size());
}
});
}