Search in sources :

Example 1 with TestFloatingBehavior

use of android.support.design.testapp.custom.TestFloatingBehavior in project material-components-android by material-components.

the class CoordinatorSnackbarWithFabTest method testBehaviorBasedSlidingFromRuntimeApiCall.

@Test
public void testBehaviorBasedSlidingFromRuntimeApiCall() {
    // Use a layout in which an AppCompatTextView child doesn't have any configured Behavior
    onView(withId(R.id.coordinator_stub)).perform(inflateViewStub(R.layout.design_snackbar_behavior_runtime));
    // and configure that Behavior at runtime by setting it on its LayoutParams
    final AppCompatTextView textView = (AppCompatTextView) mCoordinatorLayout.findViewById(R.id.text);
    final CoordinatorLayout.LayoutParams textViewLp = (CoordinatorLayout.LayoutParams) textView.getLayoutParams();
    textViewLp.setBehavior(new TestFloatingBehavior());
    // Create and show a snackbar
    mSnackbar = Snackbar.make(mCoordinatorLayout, MESSAGE_TEXT, Snackbar.LENGTH_INDEFINITE).setAction(ACTION_TEXT, mock(View.OnClickListener.class));
    SnackbarUtils.showTransientBottomBarAndWaitUntilFullyShown(mSnackbar);
    verifySnackbarViewStacking(textView, 0);
}
Also used : AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) Espresso.onView(android.support.test.espresso.Espresso.onView) View(android.view.View) TestFloatingBehavior(android.support.design.testapp.custom.TestFloatingBehavior) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

TestFloatingBehavior (android.support.design.testapp.custom.TestFloatingBehavior)1 Espresso.onView (android.support.test.espresso.Espresso.onView)1 MediumTest (android.support.test.filters.MediumTest)1 AppCompatTextView (android.support.v7.widget.AppCompatTextView)1 View (android.view.View)1 Test (org.junit.Test)1