How can I unit test this hitTest
override?
- (UIView*) hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView* hitView = [super hitTest:point withEvent:event];
// Do something based on hitView's properties
}
The problem I'm facing is that UIEvent
does not have a public constructor, and thus I can't create an UIEvent
to produce different results on [super hitTest:point withEvent:event]
.
Alternatively I could create a mock UIEvent
, but that would imply knowing what [super hitTest:point withEvent:event]
does with it, which I don't, and even if I did, it might change.
Another option would be to swizzle [super hitTest:point withEvent:event]
(with OCMock) but I don't know if it's possible to swizzle just the superclass implementation.