views:

15

answers:

1

I've been trying really hard (with no success) to generate a touch event in the private "PLAlbumView" class (which is the class where the picture thumbnails are displayed).

I've been trying to do that in order to test an End-To-End scenario on an iPhone application I've been working on that uses the camera.

So far, I have tried mimicking the exact same events sent when I do the tap manually, but that just didn't work. In order to do that, I subclassed UIWindow and put a breakpoint inside the "sendEvent" method. I made sure both my events and the events generated manually were the same.

These are the events I've been generating myself:

timestamp: 110624 touches: {( phase: Began tap count: 1 window: > view: > location in window: {22, 93} previous location in window: {22, 93} location in view: {22, 25} previous location in view: {22, 25} )}

timestamp: 110624 touches: {( phase: Ended tap count: 1 window: > view: > location in window: {22, 93} previous location in window: {22, 93} location in view: {22, 25} previous location in view: {22, 25} )}

These are the Events generated when I click manually:

timestamp: 110678 touches: {( phase: Began tap count: 1 window: > view: > location in window: {30, 116} previous location in window: {30, 116} location in view: {30, 48} previous location in view: {30, 48} )}

timestamp: 110678 touches: {( phase: Ended tap count: 1 window: > view: > location in window: {30, 116} previous location in window: {30, 116} location in view: {30, 48} previous location in view: {30, 48} )}

Is there something I am missing? Maybe there is something else I need to generate in order for the tap to work in that control?

I have used this technique with other types of controls and it worked.

A: 

I finally got it to work.

I did it by calling [PLUIAlbumViewController albumView: didTapPhotoAtIndex:] directly

This is basically what I did:

  1. I got a reference to PLAlbumView by doing a search on the UI Hierarchy
  2. From this reference, I got a reference to PLUIAlbumViewController by doing a search on the responder chain
  3. Called [PLUIAlbumViewController albumView: didTapPhotoAtIndex:] on the main thread.

I still don't know exactly why it is not responding to the events I faked though...

Vicente