Fix flakiness in AnimatedImageDrawableTest
Bug: 129400990
Bug: 120280954
Bug: 72737527
Test: This
AnimatedImageDrawable only animates while the screen is on and it is on
screen. The screen may turn off while running CTS, resulting in the test
failing due to the animation not progressing. Fix this with the
following:
- Use the new AnimatedImageActivity for tests that require animating the
AID. It forces the screen to stay on while it's running. (In addition,
only use an Activity/ActivityRule for tests that require animation. This
speeds up the other tests by not forcing them to use the Activity.)
- Ensure that the Activity has focus before running tests that require
animation.
- Use WidgetTestUtils to ensure that the first draw occurred after
calling start(). This way the test starts timing at the same time as the
AID.
In addition, split up testRepeatCounts with junit-params so each test
runs independently.
Switch to getResourceAsUri in Utils, instead of having a duplicate
method.
Lastly, switch from class variables for Resources and ContentResolver to
methods so they are lazily referenced, as we've done in other tests.
Change-Id: I3f3fa8fea08350d9af2a3ae68a76e86c765d8c4c
4 files changed