jonathanpenn / ui-auto-monkey

UI AutoMonkey is a simple stress testing script for iOS applications that runs in UI Automation and Instruments. Grass fed. Free range.
http://cocoamanifest.net
MIT License
1.47k stars 249 forks source link

setting the frame #7

Open smaljaar opened 10 years ago

smaljaar commented 10 years ago

Hey, I was using the ui-auto-monkey framework and i really wanted to use it in a specific frame. I ran across an issue there, but maybe i'm just using the code wrong.

So I set a frame with x = 0 and y = 70 so the monkey would not tap on a navigation bar. However when I released the monkey on iPad and also allowed for the event to change the orientation, I got taps out of bounds.

I think the problem comes from that I don't know what I should set the frame width and height to, if I need to set them at all.

Any ideas?

jonathanpenn commented 10 years ago

Ah, you know what, I don't think the frame limiting code takes rotation into account. I don't use the frame limitations myself. It was added by Olivier Halligon. He must not have needed to worry about different orientations with his frame limiting, either.

If you want to change it, all the logic for choosing random x and y locations on the screen are in these two methods:

https://github.com/jonathanpenn/ui-auto-monkey/blob/master/UIAutoMonkey.js#L230

and

https://github.com/jonathanpenn/ui-auto-monkey/blob/master/UIAutoMonkey.js#L246

You can tweak these two methods to take the orientation into account. When you think you've got it working, submit a pull request and I'll get it merged in.