@Test public void whenStoresAreLoadedThenAProgressDialogIsDisplayed() { ShadowCursorWrapper wrapper = createCursorWithDefaultReminder(); GroceryStoreManagerInterface groceryStoreManagerMock = getTestReminderModule().getGroceryStoreManager(); when(groceryStoreManagerMock.getCurrentLocation()).thenReturn(new Location(LocationManager.PASSIVE_PROVIDER)); CursorLoader cursorLoader = (CursorLoader)activity.onCreateLoader(0, null); activity.onLoadFinished(cursorLoader, wrapper); ProgressDialog progressDialog = (ProgressDialog)ShadowProgressDialog.getLatestDialog(); assertTrue(progressDialog.isShowing()); assertTrue(progressDialog.isIndeterminate()); ShadowProgressDialog shadowProgressDialog = Shadows.shadowOf(progressDialog); assertEquals(activity.getString(R.string.loading_stores_dialog_title), shadowProgressDialog.getTitle()); assertTrue(shadowProgressDialog.isCancelable()); }
@Test @Ignore //FIXME This works in production. Something is going wrong in robolectric public void givenStoresExistWhenTheCursorLoaderIsFinishedThenTheProgressDialogIsDismissed() { ShadowCursorWrapper wrapper = createCursorWithDefaultReminder(); GroceryStoreManagerInterface groceryStoreManagerMock = getTestReminderModule().getGroceryStoreManager(); when(groceryStoreManagerMock.getCurrentLocation()).thenReturn(null); CursorLoader cursorLoader = (CursorLoader)activity.onCreateLoader(0, null); activity.onLoadFinished(cursorLoader, wrapper); ProgressDialog progressDialog = (ProgressDialog)ShadowProgressDialog.getLatestDialog(); assertFalse(progressDialog.isShowing()); }
public static void assertProgressDialogIsShown(@StringRes int title) { ProgressDialog alert = (ProgressDialog) ShadowProgressDialog.getLatestAlertDialog(); ShadowProgressDialog shadowProgressDialog = shadowOf(alert); assertThat(shadowProgressDialog.getTitle().toString(), equalTo(getString(title))); }
public static ShadowProgressDialog shadowOf(ProgressDialog instance) { return (ShadowProgressDialog) shadowOf_(instance); }