Merge "[Network Connection] Implement Unavailable callback when the user cancels"

This commit is contained in:
TreeHugger Robot
2019-03-21 05:48:17 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 1 deletions

View File

@@ -330,4 +330,21 @@ public class NetworkRequestDialogFragmentTest {
// Check
assertThat(button.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void cancelDialog_callsReject() {
// Assert
networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), /* tag */ null);
final AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
final NetworkRequestUserSelectionCallback selectionCallback = mock(
NetworkRequestUserSelectionCallback.class);
networkRequestDialogFragment.onUserSelectionCallbackRegistration(selectionCallback);
// Action
final Button button = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
button.performClick();
// Check
verify(selectionCallback, times(1)).reject();
}
}