Remove use of isAttachedToWindow in fragment tests

Bug 32493766
Bug 32470870
Bug 32502590

Also made timeouts longer to reduce flakiness.
Also used a CountDownLatch for getting the results
of startActivityForResult.

Test: gradlew connectedCheck in fragments/ on API 16 emuator.

Change-Id: If0347a1bffa1e2fff15f19171ef2b741f6e03d7a
2 files changed