use of android.support.test.espresso.ViewAction in project storymaker by StoryMaker.
the class Util method waitId.
public static ViewAction waitId(final int viewId, final long millis) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isRoot();
}
@Override
public String getDescription() {
return "wait for a specific view with id <" + viewId + "> during " + millis + " millis.";
}
@Override
public void perform(final UiController uiController, final View view) {
uiController.loopMainThreadUntilIdle();
final long startTime = System.currentTimeMillis();
final long endTime = startTime + millis;
final Matcher<View> viewMatcher = withId(viewId);
do {
for (View child : TreeIterables.breadthFirstViewTraversal(view)) {
// found view with required ID
if (viewMatcher.matches(child)) {
return;
}
}
uiController.loopMainThreadForAtLeast(50);
} while (System.currentTimeMillis() < endTime);
// timeout happens
throw new PerformException.Builder().withActionDescription(this.getDescription()).withViewDescription(HumanReadables.describe(view)).withCause(new TimeoutException()).build();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TextInputLayoutActions method setCounterMaxLength.
public static ViewAction setCounterMaxLength(final int maxLength) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Sets the counter max length";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setCounterMaxLength(maxLength);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TextInputLayoutActions method setPasswordVisibilityToggleEnabled.
public static ViewAction setPasswordVisibilityToggleEnabled(final boolean enabled) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Sets the error";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setPasswordVisibilityToggleEnabled(enabled);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TextInputLayoutActions method setTypeface.
public static ViewAction setTypeface(final Typeface typeface) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Sets the typeface";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setTypeface(typeface);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.test.espresso.ViewAction in project material-components-android by material-components.
the class TextInputLayoutActions method setError.
public static ViewAction setError(final CharSequence error) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Sets the error";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setError(error);
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations