use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowLayoutInflaterTest method testSetContentViewByItemResource.
@Test
@Config(qualifiers = "w0dp")
public void testSetContentViewByItemResource() throws Exception {
Activity activity = buildActivity(Activity.class).create().get();
activity.setContentView(R.layout.main_layout);
TextView tv1 = (TextView) activity.findViewById(R.id.hello);
TextView tv2 = (TextView) activity.findViewById(R.id.world);
assertNotNull(tv1);
assertNull(tv2);
}
use of org.robolectric.annotation.Config in project robolectric by robolectric.
the class ShadowLayoutInflaterTest method testMultiOrientation_explicitLandscape.
@Test
@Config(qualifiers = "land")
public void testMultiOrientation_explicitLandscape() throws Exception {
context = buildActivity(Activity.class).create().start().resume().get();
// Confirm explicit "orientation = landscape" works.
context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
int layoutResId = context.getResources().getIdentifier("multi_orientation", "layout", TEST_PACKAGE);
ViewGroup view = (ViewGroup) LayoutInflater.from(context).inflate(layoutResId, null);
assertEquals(view.getId(), R.id.landscape);
assertInstanceOf(LinearLayout.class, view);
}
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();
}
Aggregations