Wait for the longest valid lifecycle transition

In lifecycle tests when there are several valid sequences, wait for
the longest one. Otherwise we might capture some state in between two
valid sequences and the verification will fail.

E.g. if both [ON_NEW_INTENT, ON_RESUME] and
[ON_NEW_INTENT, ON_RESUME, ON_PAUSE, ON_RESUME] are valid, then
waiting for the shorter one may capture an intermediate state like
[ON_NEW_INTENT, ON_RESUME, ON_PAUSE] without the last ON_RESUME.

Bug: 111941844
Test: atest ActivityLifecycleTests#testOnNewIntentFromPaused
Change-Id: Ic98631364094a396d99da08c7d2de4b72222df8a
1 file changed