After looking at this test with brettchagot, it was determined this is caused by espresso not being registered to hte right Observer or event listener. As you can see in the logs below, the click is performed at 23:57:39.951, and hte thread goes idle, but it isn't until 23:57:40.160 that the dialog is removed. So The click happens, the thread goes idel, so Espresso checks the assert which fails, and then the dialog is actually removed.
11-29 23:57:39.628 29317 29334 W hh : before click
11-29 23:57:39.631 29317 29317 I ViewInteraction: Performing 'single click' action on view with id: org.chromium.chrome.tests:id/tab_switcher_button
11-29 23:57:39.946 29401 29401 I BeaconBle: 'L' hardware scan: scan stopped, no clients
11-29 23:57:39.951 29317 29334 W hh : after click
11-29 23:57:40.074 28164 28183 I Finsky : [29976] com.google.android.finsky.bp.an.run(6): Stats for Executor: InstallQueueDatabaseManager com.google.android.finsky.bp.ao@2e41de6[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
11-29 23:57:40.160 29317 29317 E hh : removing dialog
It confirms my discovery that a sleep of 1000 milliseconds added after the click but before the check causes the test to pass (and 100 still causes the test to fail)
Thanks for the investigation, I think this might be due to the fact that we have animations running for dialog dismissal. We would probably need to wait for the view to be completely removed from view hierarchy before asserting.
I've been doing some refactor on the production code, so I will be touching this file very soon.
Comment 1 by aber...@chromium.org
, Jan 23 2018Status: Assigned (was: Available)