Intent emailSelectorIntent = new Intent(Intent.ACTION_SENDTO);
emailSelectorIntent.setData(Uri.parse("mailto:"));
final Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, "x...@xyz.com");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "");
emailIntent.putExtra(Intent.EXTRA_TEXT, "");
emailIntent.setSelector(emailSelectorIntent);
v.getContext().startActivity(Intent.createChooser(emailIntent, "Send Email"));
And when I tap on the send email link using espresso, I am seeing the recorded intent as below:
Recorded intents:
-Intent { act=android.intent.action.CHOOSER (has extras) } handling packages:[[android]], extras:[Bundle[{android.intent.extra.INTENT=Intent { act=android.intent.action.SEND (has extras) sel=act=android.intent.action.SENDTO dat=mailto:} }, android.intent.extra.TITLE=Send email}]])
And the following matcher works:
intended(allOf(hasAction(Intent.ACTION_CHOOSER),
hasExtra(is(Intent.EXTRA_INTENT), hasAction(Intent.ACTION_SEND)),
hasExtra(is(Intent.EXTRA_TITLE), is("Send email"))));
Since my recorded intent doesn't have the email address, I couldn't test add it to my matcher using espresso-intents. How can I fix this issue?
Thanks,
MC