use of org.robolectric.annotation.Config 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);
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class FavoriteManagerTest method testAdd.
@Config(sdk = 18)
@Test
public void testAdd() {
PreferenceManager.getDefaultSharedPreferences(RuntimeEnvironment.application).edit().putBoolean(RuntimeEnvironment.application.getString(R.string.pref_saved_item_sync), true).putBoolean(RuntimeEnvironment.application.getString(R.string.pref_offline_article), true).apply();
shadowOf((ConnectivityManager) RuntimeEnvironment.application.getSystemService(Context.CONNECTIVITY_SERVICE)).setActiveNetworkInfo(ShadowNetworkInfo.newInstance(null, ConnectivityManager.TYPE_WIFI, 0, true, true));
manager.add(RuntimeEnvironment.application, new TestWebItem() {
@Override
public String getId() {
return "3";
}
@Override
public String getUrl() {
return "http://newitem.com";
}
@Override
public String getDisplayedTitle() {
return "new title";
}
});
assertThat(resolver.getNotifiedUris()).isNotEmpty();
assertTrue(ShadowContentResolver.isSyncActive(new Account("Materialistic", BuildConfig.APPLICATION_ID), MaterialisticProvider.PROVIDER_AUTHORITY));
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class ItemFragmentSinglePageTest method testNavigate.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testNavigate() {
ShadowRecyclerView shadowRecyclerView = customShadowOf(recyclerView);
TestLayoutManager testLayout = new TestLayoutManager(activity);
recyclerView.setLayoutManager(testLayout);
fragment.onNavigate(Navigable.DIRECTION_DOWN);
assertThat(shadowRecyclerView.getScrollPosition()).isEqualTo(3);
shadowRecyclerView.getScrollListener().onScrollStateChanged(recyclerView, RecyclerView.SCROLL_STATE_IDLE);
testLayout.firstVisiblePosition = 3;
fragment.onNavigate(Navigable.DIRECTION_UP);
assertThat(shadowRecyclerView.getScrollPosition()).isEqualTo(0);
testLayout.firstVisiblePosition = 0;
fragment.onNavigate(Navigable.DIRECTION_RIGHT);
assertThat(shadowRecyclerView.getScrollPosition()).isEqualTo(1);
shadowRecyclerView.getScrollListener().onScrollStateChanged(recyclerView, RecyclerView.SCROLL_STATE_IDLE);
testLayout.firstVisiblePosition = 1;
fragment.onNavigate(Navigable.DIRECTION_LEFT);
assertThat(shadowRecyclerView.getScrollPosition()).isEqualTo(0);
shadowRecyclerView.getScrollListener().onScrollStateChanged(recyclerView, RecyclerView.SCROLL_STATE_IDLE);
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class ReadabilityFragmentTest method testScrollToTop.
@Config(shadows = ShadowNestedScrollView.class)
@Test
public void testScrollToTop() {
NestedScrollView scrollView = (NestedScrollView) activity.findViewById(R.id.nested_scroll_view);
scrollView.smoothScrollTo(0, 1);
assertThat(customShadowOf(scrollView).getSmoothScrollY()).isEqualTo(1);
fragment.scrollToTop();
assertThat(customShadowOf(scrollView).getSmoothScrollY()).isEqualTo(0);
controller.pause().stop().destroy();
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class BaseListActivityTest method testScrollToTop.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollToTop() {
RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
recyclerView.smoothScrollToPosition(1);
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(1);
activity.findViewById(R.id.toolbar).performClick();
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(0);
}
Aggregations