LinphoneUITester: fix last failing test on travis by manually clicking Delete button in contact edit

This commit is contained in:
Gautier Pelloux-Prayer 2015-07-07 17:10:48 +02:00
parent ea99ba5b3d
commit 422570433d

View file

@ -79,10 +79,7 @@
traits:UIAccessibilityTraitStaticText];
}
- (void)tapEditButtonForRowAtIndexPath:(NSInteger)idx inSection:(NSInteger)section {
// tap the "+" to add a new item (or "-" to delete it).... WOW, this code is ugly!
// the thing is: we don't handle the "+" button ourself (system stuff)
// so it is not present in the tableview cell... so we tap on a fixed position of screen :)
- (void)tapCellForRowAtIndexPath:(NSInteger)idx inSection:(NSInteger)section atX:(CGFloat)x {
UITableView *tv = [self findTableView:@"Contact numbers table"];
NSIndexPath *path = [NSIndexPath indexPathForRow:idx inSection:section];
UITableViewCell *last =
@ -90,10 +87,21 @@
XCTAssertNotNil(last);
CGRect cellFrame = [last.contentView convertRect:last.contentView.frame toView:tv];
[tv tapAtPoint:CGPointMake(10, cellFrame.origin.y + cellFrame.size.height / 2.)];
[tv tapAtPoint:CGPointMake(x > 0 ? x : cellFrame.size.width + x, cellFrame.origin.y + cellFrame.size.height / 2.)];
[tester waitForAnimationsToFinish];
}
- (void)tapRemoveButtonForRowAtIndexPath:(NSInteger)idx inSection:(NSInteger)section {
[self tapCellForRowAtIndexPath:idx inSection:section atX:-10];
}
- (void)tapEditButtonForRowAtIndexPath:(NSInteger)idx inSection:(NSInteger)section {
// tap the "+" to add a new item (or "-" to delete it).... WOW, this code is ugly!
// the thing is: we don't handle the "+" button ourself (system stuff)
// so it is not present in the tableview cell... so we tap on a fixed position of screen :)
[self tapCellForRowAtIndexPath:idx inSection:section atX:10];
}
- (void)addEntries:(NSArray *)numbers inSection:(NSInteger)section {
[tester tapViewWithAccessibilityLabel:@"Edit"];
[self setText:[numbers objectAtIndex:0] forContactNumbersIndex:0 inSection:section];
@ -109,6 +117,15 @@
}
}
- (void)deleteContactEntryForRowAtIndexPath:(NSInteger)idx inSection:(NSInteger)section {
if ([tester tryFindingViewWithAccessibilityLabel:@"Delete" error:nil]) {
[tester tapViewWithAccessibilityLabel:@"Delete"];
} else {
// hack: Travis seems to be unable to click on delete for what ever reason
[self tapRemoveButtonForRowAtIndexPath:idx inSection:section];
}
}
- (void)testEditContact {
NSString* contactName = [self getUUID];
NSString* fullName = [contactName stringByAppendingString:@" dummy"];
@ -126,14 +143,12 @@
// remove all numbers
for (NSInteger i = 0; i < phones.count; i++) {
[self tapEditButtonForRowAtIndexPath:0 inSection:ContactSections_Number];
[tester waitForTappableViewWithAccessibilityLabel:@"Delete"];
[tester tapViewWithAccessibilityLabel:@"Delete"];
[self deleteContactEntryForRowAtIndexPath:0 inSection:ContactSections_Number];
}
// remove all SIPs
for (NSInteger i = 0; i < SIPs.count; i++) {
[self tapEditButtonForRowAtIndexPath:0 inSection:ContactSections_Sip];
[tester waitForTappableViewWithAccessibilityLabel:@"Delete"];
[tester tapViewWithAccessibilityLabel:@"Delete"];
[self deleteContactEntryForRowAtIndexPath:0 inSection:ContactSections_Sip];
}
[tester tapViewWithAccessibilityLabel:@"Edit"];