TestsUI: create Anna Haro contact instead of assuming she alread exists

This commit is contained in:
Gautier Pelloux-Prayer 2016-03-23 15:19:41 +01:00
parent e6b9e59d65
commit 4002a2d081
4 changed files with 57 additions and 41 deletions

View file

@ -109,13 +109,18 @@
- (void)testChatFromContactPhoneNumber {
[tester tapViewWithAccessibilityLabel:@"Contacts"];
[tester tapViewWithAccessibilityLabel:@"Anna Haro"];
NSString *fullName = [NSString stringWithFormat:@"Anna %@", self.me];
[self createContact:@"Anna" lastName:self.me phoneNumber:@"555-522-8243" SIPAddress:nil];
[tester tapViewWithAccessibilityLabel:@"Back"];
[tester tapViewWithAccessibilityLabel:@"All contacts filter"];
[tester tapViewWithAccessibilityLabel:fullName];
[tester tapViewWithAccessibilityLabel:@"Chat with 5555228243"];
[self goBackFromChat];
UITableView *tv = [self findTableView:@"Chat list"];
ASSERT_EQ([tv numberOfRowsInSection:0], 1);
[tester waitForViewWithAccessibilityLabel:@"Contact name, Message"
value:@"Anna Haro (0)"
value:[NSString stringWithFormat:@"%@ (0)", fullName]
traits:UIAccessibilityTraitStaticText];
}

View file

@ -29,45 +29,6 @@
#pragma mark - Utils
- (void)setText:(NSString *)text forIndex:(NSInteger)idx inSection:(NSInteger)section {
[tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:section]
inTableViewWithAccessibilityIdentifier:@"Contact table"];
[tester enterTextIntoCurrentFirstResponder:text];
}
- (void)createContact:(NSString *)firstName
lastName:(NSString *)lastName
phoneNumber:(NSString *)phone
SIPAddress:(NSString *)sip {
XCTAssert(firstName != nil);
[tester tapViewWithAccessibilityLabel:@"Add contact"];
// check that the OK button is disabled
[tester waitForViewWithAccessibilityLabel:@"Edit"
traits:UIAccessibilityTraitButton | UIAccessibilityTraitNotEnabled |
UIAccessibilityTraitSelected];
[self setText:firstName forIndex:0 inSection:ContactSections_FirstName];
// entering text should enable the "edit" button
[tester waitForViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton | UIAccessibilityTraitSelected];
if (lastName) {
[self setText:lastName forIndex:0 inSection:ContactSections_LastName];
}
if (phone) {
[self setText:phone forIndex:0 inSection:ContactSections_Number];
}
if (sip) {
[self setText:sip forIndex:0 inSection:ContactSections_Sip];
}
[tester tapViewWithAccessibilityLabel:@"Edit"];
}
- (void)tapCellForRowAtIndexPath:(NSInteger)idx inSection:(NSInteger)section atX:(CGFloat)x {
UITableView *tv = [self findTableView:@"Contact table"];
NSIndexPath *path = [NSIndexPath indexPathForRow:idx inSection:section];
@ -85,6 +46,12 @@
[self tapCellForRowAtIndexPath:idx inSection:section atX:-7];
}
- (void)setText:(NSString *)text forIndex:(NSInteger)idx inSection:(NSInteger)section {
[tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:section]
inTableViewWithAccessibilityIdentifier:@"Contact table"];
[tester enterTextIntoCurrentFirstResponder:text];
}
- (void)addEntries:(NSArray *)numbers inSection:(NSInteger)section {
[tester tapViewWithAccessibilityLabel:@"Edit"];
NSString *name = (section == ContactSections_Sip) ? @"Add new SIP address" : @"Add new phone number";

View file

@ -27,6 +27,10 @@
- (void)waitForRegistration;
- (void)removeAllRooms;
- (void)createContact:(NSString *)firstName
lastName:(NSString *)lastName
phoneNumber:(NSString *)phone
SIPAddress:(NSString *)sip;
@end

View file

@ -13,6 +13,7 @@
#import "KIF/KIFTypist.h"
#import "Log.h"
#import "Utils.h"
#import "ContactDetailsTableView.h"
@implementation LinphoneTestCase
@ -190,4 +191,43 @@
[tester tapViewWithAccessibilityLabel:@"DELETE" traits:UIAccessibilityTraitButton];
}
- (void)setText:(NSString *)text forIndex:(NSInteger)idx inSection:(NSInteger)section {
[tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:section]
inTableViewWithAccessibilityIdentifier:@"Contact table"];
[tester enterTextIntoCurrentFirstResponder:text];
}
- (void)createContact:(NSString *)firstName
lastName:(NSString *)lastName
phoneNumber:(NSString *)phone
SIPAddress:(NSString *)sip {
XCTAssert(firstName != nil);
[tester tapViewWithAccessibilityLabel:@"Add contact"];
// check that the OK button is disabled
[tester waitForViewWithAccessibilityLabel:@"Edit"
traits:UIAccessibilityTraitButton | UIAccessibilityTraitNotEnabled |
UIAccessibilityTraitSelected];
[self setText:firstName forIndex:0 inSection:ContactSections_FirstName];
// entering text should enable the "edit" button
[tester waitForViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton | UIAccessibilityTraitSelected];
if (lastName) {
[self setText:lastName forIndex:0 inSection:ContactSections_LastName];
}
if (phone) {
[self setText:phone forIndex:0 inSection:ContactSections_Number];
}
if (sip) {
[self setText:sip forIndex:0 inSection:ContactSections_Sip];
}
[tester tapViewWithAccessibilityLabel:@"Edit"];
}
@end