Looks like this can help with testing toasts in our espresso automation. Thanks for sharing it.
Satyajit Malugu
1

If you’re using a snackbar, then there are callbacks for show and dismiss events, maybe you can use something similar for toast, or wrap the object and try to mirror its internal state in your wrapper.

Snackbar sb = TextToSpeechSnackbarFactory.genericErrorSnackbar(container);
sb.addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>() {
@Override
public void onDismissed(Snackbar transientBottomBar, int event) {
super.onDismissed(transientBottomBar, event);
}

@Override
public void onShown(Snackbar transientBottomBar) {
super.onShown(transientBottomBar);
}
});
sb.show();
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.