Recorded intent won't show email address when using Intent.ACTION_CHOOSER

42 views
Skip to first unread message

M C

unread,
Oct 28, 2020, 6:37:52 PM10/28/20
to Android Testing Support Library
Hello, 

I am starting an activity for sending an Email using an intent as follows:

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


Reply all
Reply to author
Forward
0 new messages