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);
}
use of org.robolectric.annotation.Config in project materialistic by hidroh.
the class UserActivityTest method testScrollToTop.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollToTop() {
verify(userManager).getUser(eq("username"), userCaptor.capture());
userCaptor.getValue().onResponse(user);
RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
recyclerView.smoothScrollToPosition(1);
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(1);
TabLayout.Tab tab = ((TabLayout) activity.findViewById(R.id.tab_layout)).getTabAt(0);
tab.select();
tab.select();
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(0);
}
use of org.robolectric.annotation.Config in project android-oss by kickstarter.
the class DateTimeUtilsTest method testRelative_withLocale.
@Test
@Config(qualifiers = "de")
public void testRelative_withLocale() {
final Context context = context();
final KSString ksString = ksString();
final DateTime dateTime = DateTime.parse("2015-12-17T18:35:05Z");
final RelativeDateTimeOptions.Builder builder = RelativeDateTimeOptions.builder();
assertEquals("vor 2 Minuten", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:37:05Z")).build()));
assertEquals("in 2 Minuten", DateTimeUtils.relative(context, ksString, dateTime, builder.relativeToDateTime(DateTime.parse("2015-12-17T18:33:05Z")).build()));
}
use of org.robolectric.annotation.Config in project OneSignal-Android-SDK by OneSignal.
the class MainOneSignalClassRunner method shouldCancelAndClearNotifications.
@Test
@Config(shadows = { ShadowRoboNotificationManager.class, ShadowBadgeCountUpdater.class })
public void shouldCancelAndClearNotifications() throws Exception {
ShadowRoboNotificationManager.notifications.clear();
OneSignalInitFromApplication();
threadAndTaskWait();
// Create 2 notifications
Bundle bundle = getBaseNotifBundle();
OneSignalPackagePrivateHelper.NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, bundle, null);
bundle = getBaseNotifBundle("UUID2");
OneSignalPackagePrivateHelper.NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, bundle, null);
// Test canceling
Map<Integer, ShadowRoboNotificationManager.PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
Iterator<Map.Entry<Integer, ShadowRoboNotificationManager.PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();
ShadowRoboNotificationManager.PostedNotification postedNotification = postedNotifsIterator.next().getValue();
OneSignal.cancelNotification(postedNotification.id);
Assert.assertEquals(1, ShadowBadgeCountUpdater.lastCount);
Assert.assertEquals(1, ShadowRoboNotificationManager.notifications.size());
OneSignal.clearOneSignalNotifications();
Assert.assertEquals(0, ShadowBadgeCountUpdater.lastCount);
Assert.assertEquals(0, ShadowRoboNotificationManager.notifications.size());
// Make sure they are marked dismissed.
SQLiteDatabase readableDb = OneSignalDbHelper.getInstance(blankActivity).getReadableDatabase();
Cursor cursor = readableDb.query(OneSignalPackagePrivateHelper.NotificationTable.TABLE_NAME, new String[] { "created_time" }, OneSignalPackagePrivateHelper.NotificationTable.COLUMN_NAME_DISMISSED + " = 1", null, null, null, null);
Assert.assertEquals(2, cursor.getCount());
cursor.close();
}
Aggregations