@Test public void shouldSetIndeterminate() { assertThat(dialog.isIndeterminate()).isFalse(); dialog.setIndeterminate(true); assertThat(dialog.isIndeterminate()).isTrue(); dialog.setIndeterminate(false); assertThat(dialog.isIndeterminate()).isFalse(); }
@Ignore("ProgressDialog is kinda busted") @Test // todo 2.0-cleanup public void show_shouldCreateAProgressDialog() { Context context = new Activity(); TestOnCancelListener cancelListener = new TestOnCancelListener(); ProgressDialog progressDialog = ProgressDialog.show(context, "Title", "Message", true, true, cancelListener); ShadowProgressDialog shadowProgressDialog = shadowOf(progressDialog); assertThat(progressDialog.getContext()).isSameAs(context); assertThat(shadowProgressDialog.getMessage()).isEqualTo("Message"); assertTrue(progressDialog.isIndeterminate()); assertTrue(shadowProgressDialog.isCancelable()); progressDialog.cancel(); assertThat(cancelListener.onCancelDialogInterface).isSameAs((DialogInterface) progressDialog); }
private void assertLatestDialogsSet( CharSequence expectedTitle, CharSequence expectedMessage, boolean expectedIndeterminate, boolean expectedCancelable, DialogInterface.OnCancelListener expectedCancelListener, Callable<ProgressDialog> callable) throws Exception { assertNull(ShadowDialog.getLatestDialog()); assertNull(ShadowAlertDialog.getLatestAlertDialog()); dialog = callable.call(); assertNotNull(dialog); assertThat(ShadowDialog.getLatestDialog()).isEqualTo(dialog); assertThat(ShadowAlertDialog.getLatestAlertDialog()).isEqualTo(dialog); assertThat(dialog.isIndeterminate()).as("isIndeterminate").isEqualTo(expectedIndeterminate); assertThat(shadowOf(dialog).getMessage()).as("message").isEqualTo(expectedMessage); assertThat(shadowOf(dialog).getTitle()).as("title").isEqualTo(expectedTitle); assertThat(shadowOf(dialog).isCancelable()).as("isCancelable").isEqualTo(expectedCancelable); assertThat(shadowOf(dialog).getOnCancelListener()).isEqualTo(expectedCancelListener); }