Search in sources :

Example 1 with ShadowNestedScrollView

use of io.github.hidroh.materialistic.test.shadow.ShadowNestedScrollView in project materialistic by hidroh.

the class WebFragmentTest method testScroll.

@Config(shadows = ShadowNestedScrollView.class)
@Test
public void testScroll() {
    ShadowNestedScrollView shadowScrollView = customShadowOf((NestedScrollView) activity.findViewById(R.id.nested_scroll_view));
    WebFragment fragment = (WebFragment) activity.getSupportFragmentManager().findFragmentByTag(WebFragment.class.getName());
    fragment.scrollToNext();
    assertThat(shadowScrollView.getLastScrollDirection()).isEqualTo(View.FOCUS_DOWN);
    fragment.scrollToPrevious();
    assertThat(shadowScrollView.getLastScrollDirection()).isEqualTo(View.FOCUS_UP);
    fragment.scrollToTop();
    assertThat(shadowScrollView.getSmoothScrollY()).isEqualTo(0);
}
Also used : ShadowNestedScrollView(io.github.hidroh.materialistic.test.shadow.ShadowNestedScrollView) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Aggregations

ShadowNestedScrollView (io.github.hidroh.materialistic.test.shadow.ShadowNestedScrollView)1 Test (org.junit.Test)1 Config (org.robolectric.annotation.Config)1