forked from mirrors/linphone-iphone
Tests: fix contact edition test by handling """propertly""" tableview edit button
This commit is contained in:
parent
9d000cdfb9
commit
f1243168ed
8 changed files with 121 additions and 120 deletions
|
|
@ -108,10 +108,6 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe
|
|||
self.tableView.accessibilityIdentifier = @"Contact numbers table";
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
[super viewDidDisappear:animated];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (BOOL)isValid {
|
||||
|
|
|
|||
|
|
@ -205,13 +205,6 @@ static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef inf
|
|||
[controller loadData];
|
||||
}
|
||||
|
||||
#pragma mark - ViewController Functions
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UITableViewDataSource Functions
|
||||
|
||||
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
#import "ChatTester.h"
|
||||
#include "LinphoneManager.h"
|
||||
#import "UIChatRoomCell.h"
|
||||
|
||||
#import "KIF/UIApplication-KIFAdditions.h"
|
||||
|
||||
@implementation ChatTester
|
||||
|
||||
|
|
@ -67,7 +64,7 @@
|
|||
#pragma mark - tests
|
||||
|
||||
- (void)testSendMessageToMyself {
|
||||
[self startChatWith:[self accountUsername]];
|
||||
[self startChatWith:[self me]];
|
||||
|
||||
[self sendMessage:@"Hello"];
|
||||
|
||||
|
|
@ -88,11 +85,11 @@
|
|||
}
|
||||
|
||||
- (void)testSendToSIPAddress {
|
||||
NSString *sipAddr = [NSString stringWithFormat:@"sip:%@@%@", [self accountUsername], [self accountDomain]];
|
||||
NSString *sipAddr = [NSString stringWithFormat:@"sip:%@@%@", [self me], [self accountDomain]];
|
||||
|
||||
[self startChatWith:sipAddr];
|
||||
|
||||
[tester waitForViewWithAccessibilityLabel:@"Contact name" value:@"testios" traits:0];
|
||||
[tester waitForViewWithAccessibilityLabel:@"Contact name" value:[self me] traits:0];
|
||||
|
||||
[self goBackFromChat];
|
||||
}
|
||||
|
|
@ -153,17 +150,6 @@
|
|||
ASSERT_EQ(linphone_core_get_chat_rooms([LinphoneManager getLc]), NULL);
|
||||
}
|
||||
|
||||
- (UITableView *)findTableView:(NSString *)table {
|
||||
UITableView *tv = nil;
|
||||
NSError *err = nil;
|
||||
if ([tester tryFindingAccessibilityElement:nil view:&tv withIdentifier:table tappable:false error:&err]) {
|
||||
XCTAssertNotNil(tv);
|
||||
} else {
|
||||
XCTFail(@"Error: %@", err);
|
||||
}
|
||||
return tv;
|
||||
}
|
||||
|
||||
- (void)uploadImageWithQuality:(NSString *)quality {
|
||||
UITableView *tv = [self findTableView:@"Chat list"];
|
||||
|
||||
|
|
@ -195,8 +181,7 @@
|
|||
}
|
||||
|
||||
- (void)testUploadImage {
|
||||
NSString *myself = @"testios";
|
||||
[self startChatWith:myself];
|
||||
[self startChatWith:[self me]];
|
||||
|
||||
ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0);
|
||||
[self uploadImageWithQuality:@"Minimum"];
|
||||
|
|
@ -204,7 +189,7 @@
|
|||
[self goBackFromChat];
|
||||
|
||||
// if we go back to the same chatroom, the message should be still there
|
||||
[self startChatWith:myself];
|
||||
[self startChatWith:[self me]];
|
||||
UITableView *tv = [self findTableView:@"Chat list"];
|
||||
ASSERT_EQ([tv numberOfRowsInSection:0], 1);
|
||||
|
||||
|
|
@ -221,8 +206,7 @@
|
|||
}
|
||||
|
||||
- (void)testCancelUploadImage {
|
||||
NSString *myself = @"testios";
|
||||
[self startChatWith:myself];
|
||||
[self startChatWith:[self me]];
|
||||
[self uploadImageWithQuality:@"Minimum"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Cancel transfer"];
|
||||
if ([[[LinphoneManager instance] fileTransferDelegates] count] != 0) {
|
||||
|
|
@ -233,8 +217,7 @@
|
|||
}
|
||||
|
||||
- (void)test3UploadsSimultanously {
|
||||
NSString *myself = @"testios";
|
||||
[self startChatWith:myself];
|
||||
[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:@"Maximum"];
|
||||
|
|
@ -252,8 +235,7 @@
|
|||
}
|
||||
|
||||
- (void)downloadImage {
|
||||
NSString *myself = @"testios";
|
||||
[self startChatWith:myself];
|
||||
[self startChatWith:[self me]];
|
||||
[self uploadImageWithQuality:@"Minimum"];
|
||||
// wait for the upload to terminate...
|
||||
for (int i = 0; i < 15; i++) {
|
||||
|
|
|
|||
|
|
@ -63,35 +63,50 @@
|
|||
|
||||
- (void)testDeleteContact {
|
||||
NSString* contactName = [self getUUID];
|
||||
[self createContact:contactName lastName:@"dummy" phoneNumber:@"0102030405" SIPAddress:@"testios"];
|
||||
|
||||
NSString* fullName = [contactName stringByAppendingString:@" dummy"];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:fullName traits:UIAccessibilityTraitStaticText];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
[tester scrollViewWithAccessibilityIdentifier:@"Contact numbers table" byFractionOfSizeHorizontal:0 vertical:-0.9];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Remove"];
|
||||
|
||||
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Firstname, Lastname" value:fullName traits:UIAccessibilityTraitStaticText];
|
||||
[self createContact:contactName lastName:@"dummy" phoneNumber:@"0102030405" SIPAddress:[self me]];
|
||||
|
||||
NSString *fullName = [contactName stringByAppendingString:@" dummy"];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:fullName traits:UIAccessibilityTraitStaticText];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
[tester scrollViewWithAccessibilityIdentifier:@"Contact numbers table" byFractionOfSizeHorizontal:0 vertical:-0.9];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Remove"];
|
||||
|
||||
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Firstname, Lastname"
|
||||
value:fullName
|
||||
traits:UIAccessibilityTraitStaticText];
|
||||
}
|
||||
|
||||
- (void)addNumbersToSection:(NSInteger)section numbers:(NSArray*)numbers {
|
||||
- (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 :)
|
||||
UITableView *tv = [self findTableView:@"Contact numbers table"];
|
||||
NSIndexPath *path = [NSIndexPath indexPathForRow:idx inSection:section];
|
||||
UITableViewCell *last =
|
||||
[tester waitForCellAtIndexPath:path inTableViewWithAccessibilityIdentifier:@"Contact numbers table"];
|
||||
XCTAssertNotNil(last);
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
for(NSInteger i = 0; i<numbers.count;i++){
|
||||
[self setText:[numbers objectAtIndex:i] forContactNumbersIndex:i inSection:section];
|
||||
// now tap the "+" to add a new item. This is not optimal, since it will tap the first instance with that name.
|
||||
// we should do something like "[tester tapViewWithAccessibilityLabel:@"Insert linphone" atRowIndex:i inSection:section]"
|
||||
[tester tapViewWithAccessibilityLabel:@"Insert Linphone"];
|
||||
}
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
|
||||
for(NSInteger i = 0; i<numbers.count;i++){
|
||||
[tester waitForViewWithAccessibilityLabel:[@"Linphone, " stringByAppendingString:[numbers objectAtIndex:i]]
|
||||
traits:UIAccessibilityTraitStaticText];
|
||||
}
|
||||
CGRect cellFrame = [last.contentView convertRect:last.contentView.frame toView:tv];
|
||||
[tv tapAtPoint:CGPointMake(10, cellFrame.origin.y + cellFrame.size.height / 2.)];
|
||||
[tester waitForAnimationsToFinish];
|
||||
}
|
||||
|
||||
- (void)addEntries:(NSArray *)numbers inSection:(NSInteger)section {
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
[self setText:[numbers objectAtIndex:0] forContactNumbersIndex:0 inSection:section];
|
||||
for (NSInteger i = 1; i < numbers.count; i++) {
|
||||
[self tapEditButtonForRowAtIndexPath:i - 1 inSection:section];
|
||||
[self setText:[numbers objectAtIndex:i] forContactNumbersIndex:i inSection:section];
|
||||
}
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
|
||||
for (NSInteger i = 0; i < numbers.count; i++) {
|
||||
[tester waitForViewWithAccessibilityLabel:[@"Linphone, " stringByAppendingString:[numbers objectAtIndex:i]]
|
||||
traits:UIAccessibilityTraitStaticText];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testEditContact {
|
||||
|
|
@ -103,24 +118,25 @@
|
|||
|
||||
/* Phone number */
|
||||
NSArray* phones = @[@"01234", @"56789"];
|
||||
NSLog(@"add phones");
|
||||
[self addNumbersToSection:ContactSections_Number numbers:phones];
|
||||
|
||||
NSArray* SIPs = @[@"sip1", @"sip2"];
|
||||
[self addNumbersToSection:ContactSections_Sip numbers:SIPs];
|
||||
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
// remove all these numbers, doesn't quite work today due to tableview:
|
||||
[self addEntries:phones inSection:ContactSections_Number];
|
||||
NSArray *SIPs = @[ @"sip1", @"sip2" ];
|
||||
[self addEntries:SIPs inSection:ContactSections_Sip];
|
||||
|
||||
// for(NSInteger i = 0; i< (phones.count+SIPs.count)-1; i++){
|
||||
// [tester tapViewWithAccessibilityLabel:@"Delete Linphone"];
|
||||
// [tester tapViewWithAccessibilityLabel:@"Delete"];
|
||||
// }
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
|
||||
// then remove the contact
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
// remove all numbers
|
||||
for (NSInteger i = 0; i < phones.count; i++) {
|
||||
[self tapEditButtonForRowAtIndexPath:0 inSection:ContactSections_Number];
|
||||
[tester tapViewWithAccessibilityLabel:@"Delete"];
|
||||
}
|
||||
// remove all SIPs
|
||||
for (NSInteger i = 0; i < SIPs.count; i++) {
|
||||
[self tapEditButtonForRowAtIndexPath:0 inSection:ContactSections_Sip];
|
||||
[tester tapViewWithAccessibilityLabel:@"Delete"];
|
||||
}
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
|
||||
// then remove the contact
|
||||
[tester tapViewWithAccessibilityLabel:@"Edit"];
|
||||
|
||||
[tester scrollViewWithAccessibilityIdentifier:@"Contact numbers table" byFractionOfSizeHorizontal:0 vertical:-0.9];
|
||||
|
||||
|
|
|
|||
|
|
@ -7,17 +7,20 @@
|
|||
//
|
||||
|
||||
#import <KIF/KIF.h>
|
||||
#import <KIF/UIApplication-KIFAdditions.h>
|
||||
|
||||
@interface LinphoneTestCase : KIFTestCase
|
||||
@property BOOL invalidAccountSet;
|
||||
|
||||
- (void)switchToValidAccountIfNeeded;
|
||||
- (NSString*)accountUsername;
|
||||
- (NSString *)me;
|
||||
- (NSString*)accountDomain;
|
||||
|
||||
- (NSString*)getUUID;
|
||||
- (NSArray*)getUUIDArrayOfSize:(size_t)size;
|
||||
|
||||
- (UITableView *)findTableView:(NSString *)table;
|
||||
|
||||
@end
|
||||
|
||||
#define ASSERT_EQ(actual, expected) \
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (NSString *)accountUsername {
|
||||
return @"testios";
|
||||
- (NSString *)me {
|
||||
return @"testios";
|
||||
}
|
||||
|
||||
- (NSString *)accountDomain {
|
||||
|
|
@ -74,7 +74,7 @@ static bool invalidAccount = true;
|
|||
LinphoneAddress* addr = linphone_core_interpret_url(lc, identity);
|
||||
const char* username = linphone_address_get_username(addr);
|
||||
|
||||
if (addr && (username && strcmp(username, [[self accountUsername] UTF8String]) == 0) &&
|
||||
if (addr && (username && strcmp(username, [[self me] UTF8String]) == 0) &&
|
||||
(domain && strcmp(domain, [[self accountDomain] UTF8String]) == 0) &&
|
||||
linphone_proxy_config_get_state(cfg) == LinphoneRegistrationOk) {
|
||||
isOK = true;
|
||||
|
|
@ -107,7 +107,7 @@ static bool invalidAccount = true;
|
|||
[tester tapViewWithAccessibilityLabel:@"Start"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Sign in linphone.org account"];
|
||||
|
||||
[tester enterText:@"testios" intoViewWithAccessibilityLabel:@"Username"];
|
||||
[tester enterText:[self me] intoViewWithAccessibilityLabel:@"Username"];
|
||||
[tester enterText:@"testtest" intoViewWithAccessibilityLabel:@"Password"];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Sign in"];
|
||||
|
|
@ -116,5 +116,15 @@ static bool invalidAccount = true;
|
|||
}
|
||||
}
|
||||
|
||||
- (UITableView *)findTableView:(NSString *)table {
|
||||
UITableView *tv = nil;
|
||||
NSError *err = nil;
|
||||
if ([tester tryFindingAccessibilityElement:nil view:&tv withIdentifier:table tappable:false error:&err]) {
|
||||
XCTAssertNotNil(tv);
|
||||
} else {
|
||||
XCTFail(@"Error: %@", err);
|
||||
}
|
||||
return tv;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -52,49 +52,50 @@
|
|||
[self setInvalidAccountSet:true];
|
||||
[tester tapViewWithAccessibilityLabel:@"Start"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Sign in SIP account"];
|
||||
|
||||
[tester enterText:@"testios" intoViewWithAccessibilityLabel:@"Username"];
|
||||
[tester enterText:@"testtest" intoViewWithAccessibilityLabel:@"Password"];
|
||||
[tester enterText:@"sip.linphone.org" intoViewWithAccessibilityLabel:@"Domain"];
|
||||
[tester tapViewWithAccessibilityLabel:protocol];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Sign in"];
|
||||
|
||||
// check the registration state
|
||||
UIView* regState = [tester waitForViewWithAccessibilityLabel:@"Registration state"];
|
||||
[tester waitForTimeInterval:1];
|
||||
[tester expectView:regState toContainText:@"Registered"];
|
||||
|
||||
[tester enterText:[self me] intoViewWithAccessibilityLabel:@"Username"];
|
||||
[tester enterText:@"testtest" intoViewWithAccessibilityLabel:@"Password"];
|
||||
[tester enterText:[self accountDomain] intoViewWithAccessibilityLabel:@"Domain"];
|
||||
[tester tapViewWithAccessibilityLabel:protocol];
|
||||
|
||||
[tester tapViewWithAccessibilityLabel:@"Sign in"];
|
||||
|
||||
// check the registration state
|
||||
UIView *regState = [tester waitForViewWithAccessibilityLabel:@"Registration state"];
|
||||
[tester waitForTimeInterval:1];
|
||||
[tester expectView:regState toContainText:@"Registered"];
|
||||
}
|
||||
|
||||
#pragma mark - Tests
|
||||
|
||||
- (void)testLinphoneLogin {
|
||||
|
||||
[self _linphoneLogin:@"testios" withPW:@"testtest"];
|
||||
|
||||
// check the registration state
|
||||
UIView* regState = [tester waitForViewWithAccessibilityLabel:@"Registration state"];
|
||||
[tester waitForTimeInterval:1];
|
||||
[tester expectView:regState toContainText:@"Registered"];
|
||||
|
||||
[self _linphoneLogin:[self me] withPW:@"testtest"];
|
||||
|
||||
// check the registration state
|
||||
UIView *regState = [tester waitForViewWithAccessibilityLabel:@"Registration state"];
|
||||
[tester waitForTimeInterval:1];
|
||||
[tester expectView:regState toContainText:@"Registered"];
|
||||
}
|
||||
|
||||
- (void)testLinphoneLoginWithBadPassword {
|
||||
[self _linphoneLogin:@"testios" withPW:@"badPass"];
|
||||
|
||||
[self setInvalidAccountSet:true];
|
||||
|
||||
UIView* alertViewText = [tester waitForViewWithAccessibilityLabel:@"Registration failure" traits:UIAccessibilityTraitStaticText];
|
||||
if( alertViewText ){
|
||||
UIView *reason = [tester waitForViewWithAccessibilityLabel:@"Forbidden" traits:UIAccessibilityTraitStaticText];
|
||||
if( reason == nil ){ [tester fail];
|
||||
} else {
|
||||
[tester tapViewWithAccessibilityLabel:@"OK"]; // alertview
|
||||
[tester tapViewWithAccessibilityLabel:@"Cancel"]; // cancel wizard
|
||||
}
|
||||
} else {
|
||||
[tester fail];
|
||||
}
|
||||
[self _linphoneLogin:[self me] withPW:@"badPass"];
|
||||
|
||||
[self setInvalidAccountSet:true];
|
||||
|
||||
UIView *alertViewText =
|
||||
[tester waitForViewWithAccessibilityLabel:@"Registration failure" traits:UIAccessibilityTraitStaticText];
|
||||
if (alertViewText) {
|
||||
UIView *reason = [tester waitForViewWithAccessibilityLabel:@"Forbidden" traits:UIAccessibilityTraitStaticText];
|
||||
if (reason == nil) {
|
||||
[tester fail];
|
||||
} else {
|
||||
[tester tapViewWithAccessibilityLabel:@"OK"]; // alertview
|
||||
[tester tapViewWithAccessibilityLabel:@"Cancel"]; // cancel wizard
|
||||
}
|
||||
} else {
|
||||
[tester fail];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testExternalLoginWithUDP {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit cb878f6c007cf87e0585edf7e3bc999dbe818c81
|
||||
Subproject commit fb74ece02a13e2474acd87071c98c9c7622bc252
|
||||
Loading…
Add table
Reference in a new issue