zucchini-src/zucchini — pull request #13 by Jaco-Pretorius (2013-03-30 00:35:50+00:00)
Title: Screenshot orientation matching device orientation

Hi

One of the issues I've been having is that the generated screenshot are always displayed in portrait mode, even when the app is in landscape mode. This is especially an issue because UIA will sometimes generate the screenshot upside down when taking the screenshot (as far as I can tell this is because the simulator will randomly choose to be in either LeftLandscape or RightLandscape mode). This pull request fixes that.

When taking the screenshot the coffee-script will ask the UIA app object for the interface orientation and prepend that to the generated filename - so 01_MainMenu.png will become 01_LandscapeRight_MainMenu.png. Now, when the screenshots are compared and extra step is added (before masking is done) - rotating. In this step the orientation is stripped out of the filename with a regex and ImageMagick is used to rotate the screenshot appropriately.

I would really have preferred if there was a way to add metadata to the generated screenshot (so that I don't have to embed the orientation in the filename), but the API only allows us to pass a single value - the name.

All appropriate specs have been added and the screenshot classes has been modified to allow this change. The overall structure of the screenshot class seems to be in need of some cleanup, so if you're happy with this change I will probably submit another to do the refactoring.

Thanks
Jaco