robolectric/robolectric — pull request #1048 by zofrex (2014-04-24 22:08:33+00:00)
Title: Add method to ShadowPhoneWindow to get the indeterminate progress bar

The problem I was trying to solve:

Testing that `getActivity().setProgressBarIndeterminateVisibility()` was called.

I went off reading Activity, Window, PhoneWindow, ProgressBar, did a bit of TDD, and came up with this. What do you think? If you like the approach, I could also whip this up for the regular progress bar as well.

At first I considered Activity#getProgressBarIndeterminateVisibility but thought it would produce tests overly coupled to the implementation, given that there are other ways of changing the bar's state. The more general Window#getFeatureInt seemed quite Robolectric-y, but has the potential to involve complicated logic which mirror's Android's).

This way I'm asking the question I really want to ask - is the progress bar visible? The use case for how I'm using this in my code is very similar to the test for it (but with the set call occuring in the SUT).