Multiple fixes to PermissionAppsFragmentTest

This is actually a base test of:

- LocationPermissionAppsFragmentTest
- CustomPermissionAppsFragmentTest
- StoragePermissionAppsFragmentTest

Fix the following issues:

- This relies on scroll-and-find to find an object on-screen, multiple
  times in a row. But, it is failing to scroll back up properly
  for each case. This is slowing the test down considerably.  Use
  scrollUntil(...) for more reliable scrolling.

- This test has multiple @Before clauses which need to be run in
  order, but @Before order is not guaranteed. Reduce to one @Before.

- When launching an activity, it is best to use CLEAR_TASK, which clears
  this activity if it was already open from a previous test (and
  possibly in an undesired state).

- When launching an activity, wait for a NEW_WINDOW accessibility event
  before continuing. (In other words, wait for the activity to finish
  launching.)

- Remove redundant test methods

After this change, the appDisappearsWhenUninstalled test's runtime went
down from 46 seconds to 17 seconds.

Bug: 294134564
Test: atest --iterations 10 LocationPermissionAppsFragmentTest CustomPermissionAppsFragmentTest StoragePermissionAppsFragmentTest
Change-Id: I27cbff77a849d05cd1e8e15208c8225f56311709
1 file changed