A lot of people have asked how to get the Espresso framework to wait for a background task to be finished before performing an action or asserting something. I understand that in those situations, IdlingResource is often the answer.
My question is sort of the opposite. I have a countdown that Espresso waits for by default because a ProgressBar gets updated. During this countdown, I have a sort of "Cancel" button to stop the countdown.
The test I want to write will set up the background task and check that cancel button takes the app back to the previous screen. Right now it waits for the background task to finish before trying to click the cancel button but the cancel button disappears after the task is done.
How would I "force" Espresso to perform an action (click the cancel), even though the app is not idle?