use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class BaseListActivityLandTest method testScrollItemToTop.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollItemToTop() {
activity.onItemSelected(new TestHnItem(1L) {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
});
TabLayout tabLayout = (TabLayout) activity.findViewById(R.id.tab_layout);
assertThat(tabLayout.getTabCount()).isEqualTo(2);
tabLayout.getTabAt(0).select();
ViewPager viewPager = (ViewPager) activity.findViewById(R.id.content);
viewPager.getAdapter().instantiateItem(viewPager, 0);
viewPager.getAdapter().finishUpdate(viewPager);
RecyclerView itemRecyclerView = (RecyclerView) viewPager.findViewById(R.id.recycler_view);
itemRecyclerView.smoothScrollToPosition(1);
assertThat(customShadowOf(itemRecyclerView).getScrollPosition()).isEqualTo(1);
tabLayout.getTabAt(1).select();
tabLayout.getTabAt(0).select();
tabLayout.getTabAt(0).select();
assertThat(customShadowOf(itemRecyclerView).getScrollPosition()).isEqualTo(0);
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class BaseListActivityLandTest method testSelectItemOpenStory.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testSelectItemOpenStory() {
assertThat(activity.findViewById(R.id.empty_selection)).isVisible();
activity.onItemSelected(new TestHnItem(1L) {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(activity.findViewById(R.id.empty_selection)).isNotVisible();
assertStoryMode();
shadowOf(activity).clickMenuItem(R.id.menu_share);
PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
assertThat(popupMenu.getMenu()).hasItem(R.id.menu_article).hasItem(R.id.menu_comments);
shadowOf(activity).clickMenuItem(R.id.menu_external);
assertNotNull(ShadowPopupMenu.getLatestPopupMenu());
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class BaseListActivityLandTest method testBackPressed.
@Test
public void testBackPressed() {
activity.onItemSelected(new TestHnItem(1L) {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
});
activity.onKeyDown(KeyEvent.KEYCODE_BACK, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
verify(keyDelegate).setBackInterceptor(any(KeyDelegate.BackInterceptor.class));
verify(keyDelegate).onKeyDown(anyInt(), any(KeyEvent.class));
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class BaseListActivityLandTest method testDefaultReadabilityView.
@Test
public void testDefaultReadabilityView() {
PreferenceManager.getDefaultSharedPreferences(activity).edit().putString(activity.getString(R.string.pref_story_display), activity.getString(R.string.pref_story_display_value_readability)).apply();
controller.pause().resume();
activity.onItemSelected(new TestHnItem(1L) {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
});
ViewPager viewPager = (ViewPager) activity.findViewById(R.id.content);
viewPager.getAdapter().instantiateItem(viewPager, viewPager.getCurrentItem());
assertStoryMode();
}
use of io.github.hidroh.materialistic.data.TestHnItem in project materialistic by hidroh.
the class UserActivityTest method testCommentBinding.
@Test
public void testCommentBinding() {
verify(userManager).getUser(eq("username"), userCaptor.capture());
userCaptor.getValue().onResponse(user);
RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
verify(itemManager).getItem(eq("1"), eq(ItemManager.MODE_DEFAULT), itemCaptor.capture());
itemCaptor.getValue().onResponse(new TestHnItem(1L) {
@Override
public String getText() {
return "content";
}
@Override
public String getParent() {
return "2";
}
});
RecyclerView.ViewHolder viewHolder = customShadowOf(recyclerView.getAdapter()).getViewHolder(0);
assertThat(viewHolder.itemView.findViewById(R.id.title)).isNotVisible();
assertThat((TextView) viewHolder.itemView.findViewById(R.id.text)).isVisible().hasTextString("content");
viewHolder.itemView.findViewById(R.id.comment).performClick();
assertThat(shadowOf(activity).getNextStartedActivity()).hasComponent(activity, ThreadPreviewActivity.class).hasExtra(ThreadPreviewActivity.EXTRA_ITEM);
}
Aggregations