Fix up the unit tests for the CallDetailActivity.
- We've recently moved lots of code to use AsyncTask to avoid strict mode
violations.
- Thanks to the new BackgroundTaskService, these weren't being executed,
and the tests were failing. But simply executing them is not a fix,
we want much finer grained control over what executes when, so we
can assert about different states of the ui.
- This cl introduces the concept of an identifier to go with the submitted
task, so that you can uniquely identify tasks from the test.
Additionally, on further reflection, adding a new interface BackgroundTask
wasn't necessarily a great idea. Nor was calling the thing that submits them a
Service - that name is already overloaded to mean something else in Android.
Therefore this cl makes a number of other style changes to the pattern:
- The BackgroundTaskService just becomes an interface AsyncTaskExecutor, with a
single submit() method, in a very similar fashion to the Executor pattern in
java.util.concurrent.
- We introduce the AsyncTaskExecutors class, which may be used to create
AsyncTaskExecutor objects, and also introduces a seam for injecting fake
executors for testing.
- This cl introduces a FakeAsyncTaskExecutor, which can be used to inspect the
tasks that have been submitted, as well as being used to execute them in a
controlled manner between assertions.
- This is now being used to control the flow of voicemail fetching from
the unit tests, and make sure that the recently implemented logic to
read has content, move to buffering state, then move to preparing,
is all working correctly.
- Later this will also be used to exhaustively test all the other
situations we care about.
Change-Id: Ia75df4996f9a5168db8d9f39560b62ccf4b98b46
12 files changed