robolectric/robolectric — pull request #825 by andymstone (2013-11-08 05:19:00+00:00)
Title: Allow setting display dimensions via @Config

It's useful to be able to set the screen size that is returned to activities via WindowManager.getDefaultDisplay for testing screen-size dependent code. As per issue #605 this isn't possible using Robolectric.setDefaultDisplay because that method doesn't pass the provided display to WindowManager.getDefaultDisplay.

Instead this adds two options to @Config: screenWidth and screenHeight.

I'm not sure if this is a good overall approach, since there are other screen parameters that you might conceivably want to set (density, dpi, etc), and adding all of them as separate config keywords might make things cluttered?

Also the way I've implemented it means that RobolectricTestRunner has a dependency on ShadowDisplay, not sure if that is a good idea.