use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.
the class TestUtilsMatchers method withFabBackgroundFill.
/**
* Returns a matcher that matches FloatingActionButtons with the specified background fill color.
*/
public static Matcher withFabBackgroundFill(@ColorInt final int fillColor) {
return new BoundedMatcher<View, View>(View.class) {
private String failedCheckDescription;
@Override
public void describeTo(final Description description) {
description.appendText(failedCheckDescription);
}
@Override
public boolean matchesSafely(final View view) {
if (!(view instanceof FloatingActionButton)) {
return false;
}
final FloatingActionButton fab = (FloatingActionButton) view;
// Since the FAB background is round, and may contain the shadow, we'll look at
// just the center half rect of the content area
final Rect area = new Rect();
fab.getContentRect(area);
final int rectHeightQuarter = area.height() / 4;
final int rectWidthQuarter = area.width() / 4;
area.left += rectWidthQuarter;
area.top += rectHeightQuarter;
area.right -= rectWidthQuarter;
area.bottom -= rectHeightQuarter;
try {
TestUtils.assertAllPixelsOfColor("", fab.getBackground(), view.getWidth(), view.getHeight(), false, fillColor, area, 0, true);
} catch (Throwable t) {
failedCheckDescription = t.getMessage();
return false;
}
return true;
}
};
}
use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.
the class FloatingActionButtonActions method showThenHide.
public static ViewAction showThenHide(final int animDuration) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Calls show() then hide()";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
FloatingActionButton fab = (FloatingActionButton) view;
fab.show();
fab.hide();
uiController.loopMainThreadForAtLeast(animDuration + 50);
}
};
}
use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.
the class FloatingActionButtonActions method setSize.
public static ViewAction setSize(@FloatingActionButton.Size final int size) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Sets FloatingActionButton size";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final FloatingActionButton fab = (FloatingActionButton) view;
fab.setSize(size);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.
the class FloatingActionButtonActions method hideThenShow.
public static ViewAction hideThenShow(final int animDuration) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Calls hide() then show()";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
FloatingActionButton fab = (FloatingActionButton) view;
fab.hide();
fab.show();
uiController.loopMainThreadForAtLeast(animDuration + 100);
}
};
}
use of android.support.design.widget.FloatingActionButton in project material-components-android by material-components.
the class FloatingActionButtonActions method setImageResource.
public static ViewAction setImageResource(@DrawableRes final int resId) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(FloatingActionButton.class);
}
@Override
public String getDescription() {
return "Sets FloatingActionButton image resource";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
final FloatingActionButton fab = (FloatingActionButton) view;
fab.setImageResource(resId);
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations