From 9395ea63c5c5550fd248500e757ce04a340b649d Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 4 Sep 2015 14:39:13 +0200 Subject: [PATCH] Wizard: display "Incorrect username or password" instead of "Forbidden" when failing to register --- Classes/WizardViewController.m | 3 + TestsUI/ChatTester.m | 152 ++++++++++++++++----------------- TestsUI/WizardTester.m | 3 +- 3 files changed, 81 insertions(+), 77 deletions(-) diff --git a/Classes/WizardViewController.m b/Classes/WizardViewController.m index 7802a23da..af9e0c5f5 100644 --- a/Classes/WizardViewController.m +++ b/Classes/WizardViewController.m @@ -545,6 +545,9 @@ static UICompositeViewDescription *compositeDescription = nil; } case LinphoneRegistrationFailed: { [waitView setHidden:true]; + if ([message isEqualToString:@"Forbidden"]) { + message = NSLocalizedString(@"Incorrect username or password.", nil); + } UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Registration failure", nil) message:message delegate:nil diff --git a/TestsUI/ChatTester.m b/TestsUI/ChatTester.m index f1e50ea67..4c9bf5c1a 100644 --- a/TestsUI/ChatTester.m +++ b/TestsUI/ChatTester.m @@ -101,73 +101,11 @@ [tester waitForViewWithAccessibilityLabel:@"Download"]; [tester tapViewWithAccessibilityLabel:@"Download"]; [tester waitForTimeInterval:.5f]; // just wait a few secs to start download - ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 1); + ASSERT_EQ(LinphoneManager.instance.fileTransferDelegates.count, 1); } #pragma mark - tests -- (void)test3DownloadsSimultanously { - [self startChatWith:[self me]]; - [self uploadImageWithQuality:@"Maximum"]; - [self uploadImageWithQuality:@"Average"]; - [self uploadImageWithQuality:@"Minimum"]; - UITableView *tv = [self findTableView:@"Chat list"]; - // wait for ALL uploads to terminate... - for (int i = 0; i < 45; i++) { - [tester waitForTimeInterval:1.f]; - if ([tv numberOfRowsInSection:0] == 6) - break; - } - [tester waitForTimeInterval:.5f]; - ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0); - [tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:1.f]; - for (int i = 0; i < 3; i++) { - // messages order is not known: if upload bitrate is huge, first image can be uploaded before last started - while (![tester tryFindingTappableViewWithAccessibilityLabel:@"Download" error:nil]) { - [tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:-.1f]; - } - [tester waitForViewWithAccessibilityLabel:@"Download"]; - [tester tapViewWithAccessibilityLabel:@"Download"]; - [tester waitForTimeInterval:.2f]; // just wait a few secs to start download - } - while ([LinphoneManager instance].fileTransferDelegates.count > 0) { - [tester waitForTimeInterval:.5]; - } - [self goBackFromChat]; -} - -- (void)test3UploadsSimultanously { - [self startChatWith:[self me]]; - // use Maximum quality to be sure that first transfer is not terminated when the third begins - [self uploadImageWithQuality:@"Maximum"]; - [self uploadImageWithQuality:@"Average"]; - [self uploadImageWithQuality:@"Minimum"]; - UITableView *tv = [self findTableView:@"Chat list"]; - // wait for ALL uploads to terminate... - for (int i = 0; i < 45; i++) { - [tester waitForTimeInterval:1.f]; - if ([tv numberOfRowsInSection:0] == 6) - break; - } - [tester waitForTimeInterval:.5f]; - ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0); - ASSERT_EQ([tv numberOfRowsInSection:0], 6); - [self goBackFromChat]; -} - -- (void)testCancelDownloadImage { - [self downloadImage]; - [tester tapViewWithAccessibilityLabel:@"Cancel transfer"]; - ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0); -} - -- (void)testCancelUploadImage { - [self startChatWith:[self me]]; - [self uploadImageWithQuality:@"Minimum"]; - [tester tapViewWithAccessibilityLabel:@"Cancel transfer"]; - ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0); -} - - (void)testChatFromContactPhoneNumber { [tester tapViewWithAccessibilityLabel:@"New Discussion"]; [tester tapViewWithAccessibilityLabel:@"Anna Haro"]; @@ -180,10 +118,12 @@ traits:UIAccessibilityTraitStaticText]; } -- (void)testDownloadImage { - [self downloadImage]; - [tester waitForAbsenceOfViewWithAccessibilityLabel:@"Cancel transfer"]; - ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0); +- (void)testInvalidSIPAddress { + + [self startChatWith:@"sip://toto"]; + + [tester waitForViewWithAccessibilityLabel:@"Invalid address" traits:UIAccessibilityTraitStaticText]; + [tester tapViewWithAccessibilityLabel:@"Cancel"]; } - (void)testMessageRemoval { @@ -214,14 +154,6 @@ [self goBackFromChat]; } -- (void)testInvalidSIPAddress { - - [self startChatWith:@"sip://toto"]; - - [tester waitForViewWithAccessibilityLabel:@"Invalid address" traits:UIAccessibilityTraitStaticText]; - [tester tapViewWithAccessibilityLabel:@"Cancel"]; -} - - (void)testPerformanceHugeChatList { [tester tapViewWithAccessibilityLabel:@"Dialer"]; @@ -317,7 +249,75 @@ [self goBackFromChat]; } -- (void)testUploadImage { +- (void)testTransfer3DownloadsSimultanously { + [self startChatWith:[self me]]; + [self uploadImageWithQuality:@"Maximum"]; + [self uploadImageWithQuality:@"Average"]; + [self uploadImageWithQuality:@"Minimum"]; + UITableView *tv = [self findTableView:@"Chat list"]; + // wait for ALL uploads to terminate... + for (int i = 0; i < 45; i++) { + [tester waitForTimeInterval:1.f]; + if ([tv numberOfRowsInSection:0] == 6) + break; + } + [tester waitForTimeInterval:.5f]; + ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0); + [tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:1.f]; + for (int i = 0; i < 3; i++) { + // messages order is not known: if upload bitrate is huge, first image can be uploaded before last started + while (![tester tryFindingTappableViewWithAccessibilityLabel:@"Download" error:nil]) { + [tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:-.1f]; + } + [tester waitForViewWithAccessibilityLabel:@"Download"]; + [tester tapViewWithAccessibilityLabel:@"Download"]; + [tester waitForTimeInterval:.2f]; // just wait a few secs to start download + } + while ([LinphoneManager instance].fileTransferDelegates.count > 0) { + [tester waitForTimeInterval:.5]; + } + [self goBackFromChat]; +} + +- (void)testTransfer3UploadsSimultanously { + [self startChatWith:[self me]]; + // use Maximum quality to be sure that first transfer is not terminated when the third begins + [self uploadImageWithQuality:@"Maximum"]; + [self uploadImageWithQuality:@"Average"]; + [self uploadImageWithQuality:@"Minimum"]; + UITableView *tv = [self findTableView:@"Chat list"]; + // wait for ALL uploads to terminate... + for (int i = 0; i < 45; i++) { + [tester waitForTimeInterval:1.f]; + if ([tv numberOfRowsInSection:0] == 6) + break; + } + [tester waitForTimeInterval:.5f]; + ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0); + ASSERT_EQ([tv numberOfRowsInSection:0], 6); + [self goBackFromChat]; +} + +- (void)testTransferCancelDownloadImage { + [self downloadImage]; + [tester tapViewWithAccessibilityLabel:@"Cancel transfer"]; + ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0); +} + +- (void)testTransferCancelUploadImage { + [self startChatWith:[self me]]; + [self uploadImageWithQuality:@"Minimum"]; + [tester tapViewWithAccessibilityLabel:@"Cancel transfer"]; + ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0); +} + +- (void)testTransferDownloadImage { + [self downloadImage]; + [tester waitForAbsenceOfViewWithAccessibilityLabel:@"Cancel transfer"]; + ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0); +} + +- (void)testTransferUploadImage { [self startChatWith:[self me]]; ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0); diff --git a/TestsUI/WizardTester.m b/TestsUI/WizardTester.m index 313564fa7..3e39986fc 100644 --- a/TestsUI/WizardTester.m +++ b/TestsUI/WizardTester.m @@ -116,7 +116,8 @@ UIView *alertViewText = [tester waitForViewWithAccessibilityLabel:@"Registration failure" traits:UIAccessibilityTraitStaticText]; if (alertViewText) { - UIView *reason = [tester waitForViewWithAccessibilityLabel:@"Forbidden" traits:UIAccessibilityTraitStaticText]; + UIView *reason = [tester waitForViewWithAccessibilityLabel:@"Incorrect username or password." + traits:UIAccessibilityTraitStaticText]; if (reason == nil) { [tester fail]; } else {