From 4002a2d081fd2b4e3bdfa2bae4d44c2e45739557 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 23 Mar 2016 15:19:41 +0100 Subject: [PATCH] TestsUI: create Anna Haro contact instead of assuming she alread exists --- TestsUI/ChatTester.m | 9 ++++++-- TestsUI/ContactsTester.m | 45 +++++--------------------------------- TestsUI/LinphoneTestCase.h | 4 ++++ TestsUI/LinphoneTestCase.m | 40 +++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 41 deletions(-) diff --git a/TestsUI/ChatTester.m b/TestsUI/ChatTester.m index 49040d353..b29fd08dd 100644 --- a/TestsUI/ChatTester.m +++ b/TestsUI/ChatTester.m @@ -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]; } diff --git a/TestsUI/ContactsTester.m b/TestsUI/ContactsTester.m index 520bee4a1..e92f2e86b 100644 --- a/TestsUI/ContactsTester.m +++ b/TestsUI/ContactsTester.m @@ -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"; diff --git a/TestsUI/LinphoneTestCase.h b/TestsUI/LinphoneTestCase.h index 768604ef3..fec85cf43 100644 --- a/TestsUI/LinphoneTestCase.h +++ b/TestsUI/LinphoneTestCase.h @@ -27,6 +27,10 @@ - (void)waitForRegistration; - (void)removeAllRooms; +- (void)createContact:(NSString *)firstName + lastName:(NSString *)lastName + phoneNumber:(NSString *)phone + SIPAddress:(NSString *)sip; @end diff --git a/TestsUI/LinphoneTestCase.m b/TestsUI/LinphoneTestCase.m index 64ac658c9..655a81780 100644 --- a/TestsUI/LinphoneTestCase.m +++ b/TestsUI/LinphoneTestCase.m @@ -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