I have a button in my activity. Once clicked, it checks user registration status. If registered then shows a dialog otherwise starts registration activity.
I set required flags that says user has registered. I perform click and expect the dialog must be created but after debug I see this is null :(
This is my code:
@Test
public void testSignupButton()
{
PreferenceUtils.setSessionId(activity, "sessionId");
assertTrue(PreferenceUtils.isActivated(activity));
btnSignUp.performClick();
Dialog dialog = ShadowDialog.getLatestDialog(); // << dialog is null
ShadowDialog loginDialogFragment = Shadows.shadowOf(dialog); // Test fails here since dialog is null
assertThat(loginDialogFragment.getTitle().toString(), equalTo("TestDialogFragment"));
}
Any idea, would be appreciated, thanks.