views:

38

answers:

1

I want to unit test a swipe left/right action on the screen in Android but I haven't been able to find any documentation on it. Can anyone lend a hand? Can it even be done?

+2  A: 

Generally the touch will perform an action and you will be testing the action, not the touch itself.

graham.reeds
I don't understand. Are you saying I should do the action and have the test listen for when it has been performed.
TehGoose
Let's say for the sake of argument AndroidOS calls OnSwipeEvent when someone swipes. In the stub of OnSwipeEvent you call MySwipeHandler. You need to test MySwipeHandler.
graham.reeds
Is that the only way? I thought I'd be able to test to see if the swipe events actually worked instead of just testing the methods they are supposed to call. I can simulate button clicks and such. Kinda a bummer I can't do the same. Thanks anyways.
TehGoose
Why would you want to check the swipe worked - did you write the swipe routines?
graham.reeds
Yup I did. It is a necessity for the unit test to include them if possible.
TehGoose