From 422570433dbf17627c8dd683196b4e8d68394e34 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 7 Jul 2015 17:10:48 +0200 Subject: [PATCH] LinphoneUITester: fix last failing test on travis by manually clicking Delete button in contact edit --- KifTests/ContactsTester.m | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/KifTests/ContactsTester.m b/KifTests/ContactsTester.m index 9f3670c94..763e194c5 100644 --- a/KifTests/ContactsTester.m +++ b/KifTests/ContactsTester.m @@ -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"];