diff --git a/Classes/ChatTableViewController.m b/Classes/ChatTableViewController.m index f47aca591..429209d86 100644 --- a/Classes/ChatTableViewController.m +++ b/Classes/ChatTableViewController.m @@ -38,11 +38,11 @@ [super dealloc]; } - #pragma mark - ViewController Functions - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + self.tableView.accessibilityIdentifier = @"ChatRoom list"; [self loadData]; } diff --git a/Classes/ContactDetailsTableViewController.h b/Classes/ContactDetailsTableViewController.h index d4ed1da3e..c51db7bab 100644 --- a/Classes/ContactDetailsTableViewController.h +++ b/Classes/ContactDetailsTableViewController.h @@ -25,6 +25,15 @@ #import "UIContactDetailsHeader.h" #import "UIContactDetailsFooter.h" + +typedef enum _ContactSections { + ContactSections_None = 0, + ContactSections_Number, + ContactSections_Sip, + ContactSections_Email, + ContactSections_MAX +} ContactSections_e; + @interface ContactDetailsTableViewController : UITableViewController { @private NSMutableArray *dataCache; diff --git a/Classes/ContactDetailsTableViewController.m b/Classes/ContactDetailsTableViewController.m index 9be9e4e48..a85bd9cad 100644 --- a/Classes/ContactDetailsTableViewController.m +++ b/Classes/ContactDetailsTableViewController.m @@ -55,14 +55,6 @@ @implementation ContactDetailsTableViewController -typedef enum _ContactSections { - ContactSections_None = 0, - ContactSections_Number, - ContactSections_Sip, - ContactSections_Email, - ContactSections_MAX -} ContactSections_e; - static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSections_None, ContactSections_Number, ContactSections_Sip, ContactSections_Email}; @synthesize footerController; @@ -124,6 +116,8 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe [super viewDidLoad]; [headerController view]; // Force view load [footerController view]; // Force view load + + self.tableView.accessibilityIdentifier = @"Contact numbers table"; } - (void)viewDidDisappear:(BOOL)animated { diff --git a/Classes/LinphoneUI/UIContactDetailsHeader.m b/Classes/LinphoneUI/UIContactDetailsHeader.m index f3787a4f8..376006b15 100644 --- a/Classes/LinphoneUI/UIContactDetailsHeader.m +++ b/Classes/LinphoneUI/UIContactDetailsHeader.m @@ -94,6 +94,7 @@ [normalView setAlpha:1.0f]; [editView setAlpha:0.0f]; [tableView setEditing:TRUE animated:false]; + tableView.accessibilityIdentifier = @"Contact Name Table"; } diff --git a/KifTests/ChatTester.m b/KifTests/ChatTester.m index 66e200519..3efa05abe 100644 --- a/KifTests/ChatTester.m +++ b/KifTests/ChatTester.m @@ -7,6 +7,7 @@ // #import "ChatTester.h" +#include "LinphoneManager.h" @implementation ChatTester @@ -98,5 +99,42 @@ [self goBackFromChat]; } +- (void)testRemoveAllChats { + NSArray* uuids = [self getUUIDArrayOfSize:5]; + + for( NSString* uuid in uuids ){ + [self startChatWith:uuid]; + [self sendMessage:@"Test"]; + [self goBackFromChat]; + } + + [tester tapViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton]; + + // we expect to be able to delete at least the amount of chatrooms we created + for( int i =0; i< uuids.count; i++){ + [tester tapViewWithAccessibilityLabel:@"Delete" traits:UIAccessibilityTraitButton]; + } + + // then we try to delete all the rest of chatrooms + while ( [tester tryFindingTappableViewWithAccessibilityLabel:@"Delete" traits:UIAccessibilityTraitButton error:nil] ) + { + [tester tapViewWithAccessibilityLabel:@"Delete" traits:UIAccessibilityTraitButton]; + NSLog(@"Deleting an extra chat"); + } + + // check that the tableview is empty + UITableView* tv = nil; + NSError* err = nil; + if( [tester tryFindingAccessibilityElement:nil view:&tv withIdentifier:@"ChatRoom list" tappable:false error:&err] ){ + XCTAssert(tv != nil); + XCTAssert([tv numberOfRowsInSection:0] == 0); // no more chat rooms + } else { + NSLog(@"Error: %@",err); + } + + // test that there's no more chatrooms in the core + XCTAssert(linphone_core_get_chat_rooms([LinphoneManager getLc]) == nil); +} + @end diff --git a/KifTests/ContactsTester.h b/KifTests/ContactsTester.h new file mode 100644 index 000000000..7c8e2f052 --- /dev/null +++ b/KifTests/ContactsTester.h @@ -0,0 +1,13 @@ +// +// ContactsTester.h +// linphone +// +// Created by Guillaume BIENKOWSKI on 17/02/2015. +// +// + +#import "LinphoneTestCase.h" + +@interface ContactsTester : LinphoneTestCase + +@end diff --git a/KifTests/ContactsTester.m b/KifTests/ContactsTester.m new file mode 100644 index 000000000..a0a9a7838 --- /dev/null +++ b/KifTests/ContactsTester.m @@ -0,0 +1,78 @@ +// +// ContactsTester.m +// linphone +// +// Created by Guillaume BIENKOWSKI on 17/02/2015. +// +// + +#import "ContactsTester.h" + +#import "ContactDetailsTableViewController.h" + +@implementation ContactsTester + +#pragma mark - Setup + +- (void)beforeAll { + [tester tapViewWithAccessibilityLabel:@"Contacts"]; +} + +#pragma mark - Utils + +- (void)setText:(NSString*)text forContactHeaderIndex:(NSInteger)idx { + [tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:0] inTableViewWithAccessibilityIdentifier:@"Contact Name Table"]; + [tester enterTextIntoCurrentFirstResponder:text]; +} + +- (void)setText:(NSString*)text forContactNumbersIndex:(NSInteger)idx inSection:(NSInteger)section { + [tester tapRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:section] inTableViewWithAccessibilityIdentifier:@"Contact numbers 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 forContactHeaderIndex:0]; + + // entering text should enable the "edit" button + [tester waitForViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton|UIAccessibilityTraitSelected]; + + if( lastName ) + [self setText:lastName forContactHeaderIndex:1]; + + if ( phone ) + [self setText:phone forContactNumbersIndex:0 inSection:ContactSections_Number]; + + if (sip) + [self setText:sip forContactNumbersIndex:0 inSection:ContactSections_Sip]; + + [tester tapViewWithAccessibilityLabel:@"Edit"]; + [tester tapViewWithAccessibilityLabel:@"Back"]; + +} + +#pragma mark - Tests + +- (void)testDeleteContact { + NSString* contactName = [self getUUID]; + [self createContact:contactName lastName:@"dummy" phoneNumber:@"0102030405" SIPAddress:@"testios"]; + + NSString* fullName = [contactName stringByAppendingString:@" dummy"]; + + [tester tapViewWithAccessibilityLabel:@"Firstname, Lastname" value: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]; +} + +@end diff --git a/KifTests/LinphoneTestCase.h b/KifTests/LinphoneTestCase.h index 1417de9ce..1bfd3beb5 100644 --- a/KifTests/LinphoneTestCase.h +++ b/KifTests/LinphoneTestCase.h @@ -16,5 +16,6 @@ - (NSString*)accountDomain; - (NSString*)getUUID; +- (NSArray*)getUUIDArrayOfSize:(size_t)size; @end diff --git a/KifTests/LinphoneTestCase.m b/KifTests/LinphoneTestCase.m index b0aa88ab9..5b39e5f31 100644 --- a/KifTests/LinphoneTestCase.m +++ b/KifTests/LinphoneTestCase.m @@ -17,7 +17,7 @@ + (void)initialize { // default is 0.01, which sometimes confuses the simulator to the point that // it will miss some keys - [KIFTypist setKeystrokeDelay:0.1]; + [KIFTypist setKeystrokeDelay:0.05]; } - (NSString *)accountUsername { @@ -32,6 +32,14 @@ return [[NSUUID UUID] UUIDString]; } +- (NSArray *)getUUIDArrayOfSize:(size_t)size { + NSMutableArray* array = [NSMutableArray arrayWithCapacity:size]; + for (NSInteger i=0; i