I am writing a test to confirm the if a method shifts the focus to next textField. I tried the code from iOS unit test: How to set/update/examine firstResponder?. But it fails.
- (void)testFocusMovedToYearField {
UIWindow *window = [[UIWindow alloc] init];
[window addSubview:self.dateCell.txtDay];
[window addSubview:self.dateCell.txtYear];
[self.dateCell completionBlockHelper];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:5.0]];
XCTAssertTrue([self.kioskDateCell.txtYear isFirstResponder]);
}
The function completionBlockHelper
contains the code to make the txtYear
become first responder.
Any suggestions will be helpful.