0

I am making use of a Presentation: Form Sheet in my app. So my ViewController gets displayed as a form with the black semi-transparent overlay around it.

I have implemented the logic to dismiss everything should the user tap anywhere outside my form sheet ViewController.

I would like to test this behavior but I'm not sure how to simulate the tap. How can I set an accessibility label to simulate this tap with a UI test?

Or any other suggestions how I can test this behavior?

Thanks!

m.y
  • 691
  • 9
  • 21

2 Answers2

1

You just want to click anywhere on the screen to dismiss everything?

    [tester tapScreenAtPoint:CGPoint];

does that for you.

Most stuff about KIF is explained here: http://www.raywenderlich.com/61419/ios-ui-testing-with-kif

Norman
  • 176
  • 1
  • 7
0

Hi you can use UITapGestureRecognizer like this :

First create an instance of UITapGestureRecognizer

UITapGestureRecognizer *tapGesture = tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(someMethod:)];

Then attach this gesture recognizer to your view (i.e, black overlay you're talking about )

[self.view addGestureRecognizer:tapGesture];

Then implement someMethod: which is the method (action) that gets called when your formsheet is tapped

-(void)someMethod
{
 //Logic to dismiss your formsheet 
}

HTH :D

iamyogish
  • 2,372
  • 2
  • 23
  • 40
  • If I was writing unit tests, that could indeed help but my scenario is more suited to a UI test isn't it? I am using KIF and all the steps are triggered by a tap on an element based on an accessibility label and/or identifier. – m.y Jul 24 '14 at 15:54