use of org.robolectric.annotation.Config in project glide by bumptech.
the class GifDecoderTest method testFirstFrameMustClearBeforeDrawingWhenLastFrameIsDisposalNone.
@Test
@Config(shadows = { CustomShadowBitmap.class })
public void testFirstFrameMustClearBeforeDrawingWhenLastFrameIsDisposalNone() throws IOException {
byte[] data = TestUtil.resourceToBytes(getClass(), "transparent_disposal_none.gif");
GifHeaderParser headerParser = new GifHeaderParser();
headerParser.setData(data);
GifHeader header = headerParser.parseHeader();
GifDecoder decoder = new StandardGifDecoder(provider);
decoder.setData(header, data);
decoder.advance();
Bitmap firstFrame = decoder.getNextFrame();
decoder.advance();
decoder.getNextFrame();
decoder.advance();
Bitmap firstFrameTwice = decoder.getNextFrame();
assertTrue(Arrays.equals((((CustomShadowBitmap) shadowOf(firstFrame))).getPixels(), (((CustomShadowBitmap) shadowOf(firstFrameTwice))).getPixels()));
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class ItemActivityTest method testScrollToTop.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollToTop() {
Intent intent = new Intent();
intent.putExtra(ItemActivity.EXTRA_ITEM, new TestItem() {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
@Override
public String getId() {
return "1";
}
@Override
public boolean isStoryType() {
return true;
}
@Override
public int getKidCount() {
return 10;
}
@Override
public String getUrl() {
return "http://example.com";
}
});
controller.withIntent(intent).create().start().resume();
// see https://github.com/robolectric/robolectric/issues/1326
ShadowLooper.pauseMainLooper();
controller.visible();
ShadowApplication.getInstance().getForegroundThreadScheduler().advanceToLastPostedRunnable();
RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
recyclerView.smoothScrollToPosition(1);
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(1);
TabLayout tabLayout = (TabLayout) activity.findViewById(R.id.tab_layout);
assertThat(tabLayout.getTabCount()).isEqualTo(2);
tabLayout.getTabAt(1).select();
tabLayout.getTabAt(0).select();
tabLayout.getTabAt(0).select();
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(0);
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class DrawerActivityLoginTest method testRemoveAccount.
@Config(sdk = 21)
@Test
public void testRemoveAccount() {
ShadowAccountManager.get(activity).addAccountExplicitly(new Account("existing", BuildConfig.APPLICATION_ID), "password", null);
Preferences.setUsername(activity, "existing");
drawerAccount.performClick();
AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog();
assertNotNull(alertDialog);
assertThat(alertDialog.getListView().getAdapter()).hasCount(1);
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick();
assertThat(alertDialog).isNotShowing();
assertThat(ShadowAccountManager.get(activity).getAccounts()).isEmpty();
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class ItemActivityTest method testFullscreen.
@Config(shadows = { ShadowFloatingActionButton.class })
@Test
public void testFullscreen() {
Intent intent = new Intent();
WebItem webItem = new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
@Override
public String getId() {
return "1";
}
};
intent.putExtra(ItemActivity.EXTRA_ITEM, webItem);
controller.withIntent(intent).create().start().resume().visible();
ShadowFloatingActionButton shadowFab = (ShadowFloatingActionButton) ShadowExtractor.extract(activity.findViewById(R.id.reply_button));
assertTrue(shadowFab.isVisible());
ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, true));
assertFalse(shadowFab.isVisible());
ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false));
assertTrue(shadowFab.isVisible());
}
use of org.robolectric.annotation.Config 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);
}
Aggregations