KifTests: remove LOCALIZED macro, we only support English yet (no method to get localized accessibility label)

This commit is contained in:
Gautier Pelloux-Prayer 2015-06-22 15:59:54 +02:00
parent 814825a4a1
commit 8ee40891ad
3 changed files with 111 additions and 112 deletions

View file

@ -22,16 +22,16 @@
- (void)beforeEach {
[super beforeEach];
if ([tester tryFindingTappableViewWithAccessibilityLabel:LOCALIZED(@"Back") error:nil]) {
if ([tester tryFindingTappableViewWithAccessibilityLabel:@"Back" error:nil]) {
[self goBackFromChat];
}
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Chat")];
[tester tapViewWithAccessibilityLabel:@"Chat"];
[self removeAllRooms];
}
- (void)afterAll {
// at the end of tests, go back to chat rooms to display main bar
if ([tester tryFindingTappableViewWithAccessibilityLabel:LOCALIZED(@"Back") error:nil]) {
if ([tester tryFindingTappableViewWithAccessibilityLabel:@"Back" error:nil]) {
[self goBackFromChat];
}
}
@ -49,17 +49,17 @@
}
- (void)goBackFromChat {
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Back")];
[tester tapViewWithAccessibilityLabel:@"Back"];
}
- (void)startChatWith:(NSString*)user {
[tester enterText:user intoViewWithAccessibilityLabel:LOCALIZED(@"Enter a address")];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"New Discussion")];
[tester enterText:user intoViewWithAccessibilityLabel:@"Enter a address"];
[tester tapViewWithAccessibilityLabel:@"New Discussion"];
}
- (void)sendMessage:(NSString*)message {
[tester enterText:message intoViewWithAccessibilityLabel:LOCALIZED(@"Message field")];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Send")];
[tester enterText:message intoViewWithAccessibilityLabel:@"Message field"];
[tester tapViewWithAccessibilityLabel:@"Send"];
}
@ -67,78 +67,76 @@
- (void)testSendMessageToMyself {
[self startChatWith:[self accountUsername]];
[self sendMessage:@"Hello"];
[tester waitForViewWithAccessibilityLabel:LOCALIZED(@"Outgoing message") value:@"Hello" traits:UIAccessibilityTraitStaticText];
[tester waitForViewWithAccessibilityLabel:LOCALIZED(@"Incoming message") value:@"Hello" traits:UIAccessibilityTraitStaticText];
[tester waitForViewWithAccessibilityLabel:LOCALIZED(@"Message status") value:@"delivered" traits:UIAccessibilityTraitImage];
[self goBackFromChat];
[self sendMessage:@"Hello"];
[tester waitForViewWithAccessibilityLabel:@"Outgoing message" value:@"Hello" traits:UIAccessibilityTraitStaticText];
[tester waitForViewWithAccessibilityLabel:@"Incoming message" value:@"Hello" traits:UIAccessibilityTraitStaticText];
[tester waitForViewWithAccessibilityLabel:@"Message status" value:@"delivered" traits:UIAccessibilityTraitImage];
[self goBackFromChat];
}
- (void)testInvalidSPAddress {
[self startChatWith:@"sip://toto"];
[tester waitForViewWithAccessibilityLabel:LOCALIZED(@"Invalid address") traits:UIAccessibilityTraitStaticText];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Cancel")];
[self startChatWith:@"sip://toto"];
[tester waitForViewWithAccessibilityLabel:@"Invalid address" traits:UIAccessibilityTraitStaticText];
[tester tapViewWithAccessibilityLabel:@"Cancel"];
}
-(void)testSendToSIPAddress{
NSString* sipAddr = [NSString stringWithFormat:@"sip:%@@%@", [self accountUsername], [self accountDomain]];
[self startChatWith:sipAddr];
[tester waitForViewWithAccessibilityLabel:LOCALIZED(@"Contact name") value:@"testios" traits:0];
[self goBackFromChat];
[self startChatWith:sipAddr];
[tester waitForViewWithAccessibilityLabel:@"Contact name" value:@"testios" traits:0];
[self goBackFromChat];
}
- (void)testChatMessageRemoval {
NSString* user = [self getUUID];
[self startChatWith:user];
[self sendMessage:user];
[tester tapViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton];
[tester tapViewWithAccessibilityLabel:@"Delete message"];
[tester tapViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton];
// check that the tableview is empty
UITableView* tv = nil;
NSError* err = nil;
if( [tester tryFindingAccessibilityElement:nil view:&tv withIdentifier:@"Chat list" tappable:false error:&err] ){
XCTAssert(tv != nil);
XCTAssert([tv numberOfRowsInSection:0] == 0); // no more messages
} else {
NSLog(@"Error: %@",err);
}
[self goBackFromChat];
NSString *user = [self getUUID];
[self startChatWith:user];
[self sendMessage:user];
[tester tapViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton];
[tester tapViewWithAccessibilityLabel:@"Delete message"];
[tester tapViewWithAccessibilityLabel:@"Edit" traits:UIAccessibilityTraitButton];
// check that the tableview is empty
UITableView *tv = nil;
NSError *err = nil;
if ([tester tryFindingAccessibilityElement:nil view:&tv withIdentifier:@"Chat list" tappable:false error:&err]) {
XCTAssert(tv != nil);
XCTAssert([tv numberOfRowsInSection:0] == 0); // no more messages
} else {
NSLog(@"Error: %@", err);
}
[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];
}
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];
}
[tester tapViewWithAccessibilityLabel:@"Edit"
traits:UIAccessibilityTraitButton]; // same as the first but it is "OK" on screen
@ -167,8 +165,8 @@
[self startChatWith:user];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Send picture")];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Photo library")];
[tester tapViewWithAccessibilityLabel:@"Send picture"];
[tester tapViewWithAccessibilityLabel:@"Photo library"];
// if popup "Linphone would access your photo" pops up, click OK.
if ([ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusNotDetermined) {
#if TARGET_IPHONE_SIMULATOR
@ -179,7 +177,7 @@
[tester choosePhotoInAlbum:@"Camera Roll" atRow:1 column:1];
// TODO: do not harcode size!
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Minimum (108.9 KB)")];
[tester tapViewWithAccessibilityLabel:@"Minimum (108.9 KB)"];
UITableView *tv = [self findTableView:@"Chat list"];
XCTAssertEqual([tv numberOfRowsInSection:0], 1);
@ -197,7 +195,7 @@
UITableView *tv = [self findTableView:@"Chat list"];
XCTAssertEqual([tv numberOfRowsInSection:0], 1);
[tester waitForViewWithAccessibilityLabel:LOCALIZED(@"Download")];
[tester waitForViewWithAccessibilityLabel:@"Download"];
XCTAssertEqual([tv numberOfRowsInSection:0], 2);
XCTAssertEqual([[[LinphoneManager instance] fileTransferDelegates] count], 0);
@ -205,7 +203,7 @@
- (void)testCancelUploadImage {
[self uploadImage];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Cancel transfer")];
[tester tapViewWithAccessibilityLabel:@"Cancel transfer"];
XCTAssertEqual([[[LinphoneManager instance] fileTransferDelegates] count], 0);
}
@ -217,8 +215,8 @@
if ([[[LinphoneManager instance] fileTransferDelegates] count] == 0)
break;
}
[tester waitForViewWithAccessibilityLabel:LOCALIZED(@"Download")];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Download")];
[tester waitForViewWithAccessibilityLabel:@"Download"];
[tester tapViewWithAccessibilityLabel:@"Download"];
[tester waitForTimeInterval:.5f]; // just wait a few secs to start download
XCTAssertEqual([[[LinphoneManager instance] fileTransferDelegates] count], 1);
}
@ -231,7 +229,7 @@
- (void)testCancelDownloadImage {
[self downloadImage];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Cancel transfer")];
[tester tapViewWithAccessibilityLabel:@"Cancel transfer"];
XCTAssertEqual([[[LinphoneManager instance] fileTransferDelegates] count], 0);
}

View file

@ -8,8 +8,6 @@
#import <KIF/KIF.h>
#define LOCALIZED(X) (X)
@interface LinphoneTestCase : KIFTestCase
@property BOOL invalidAccountSet;

View file

@ -18,6 +18,11 @@
// default is 0.01, which sometimes confuses the simulator to the point that
// it will miss some keys
[KIFTypist setKeystrokeDelay:0.05];
NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
if (!([language isEqualToString:@"en"] || [language containsString:@"en-"])) {
LOGF(@"Language must be en (English) instead of %@", language);
}
}
- (NSString *)accountUsername {
@ -69,49 +74,47 @@ static bool invalidAccount = true;
const char* identity = linphone_proxy_config_get_identity(cfg);
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)
&& ( domain && strcmp(domain, [[self accountDomain] UTF8String]) == 0 )
&& linphone_proxy_config_get_state(cfg) == LinphoneRegistrationOk )
{
isOK = true;
linphone_address_destroy(addr);
break;
} else if( addr ) {
linphone_address_destroy(addr);
}
proxies=proxies->next;
}
return isOK;
if (addr && (username && strcmp(username, [[self accountUsername] UTF8String]) == 0) &&
(domain && strcmp(domain, [[self accountDomain] UTF8String]) == 0) &&
linphone_proxy_config_get_state(cfg) == LinphoneRegistrationOk) {
isOK = true;
linphone_address_destroy(addr);
break;
} else if (addr) {
linphone_address_destroy(addr);
}
proxies = proxies->next;
}
return isOK;
}
- (void)switchToValidAccountIfNeeded {
[UIView setAnimationsEnabled:false];
if( invalidAccount && ! [self hasValidProxyConfig] ){
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Settings")];
if (invalidAccount && ![self hasValidProxyConfig]) {
[tester tapViewWithAccessibilityLabel:@"Settings"];
[tester tapViewWithAccessibilityLabel:@"Run assistant"];
[tester waitForTimeInterval:0.5];
if( [tester tryFindingViewWithAccessibilityLabel:LOCALIZED(@"Launch Wizard") error:nil]){
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Launch Wizard")];
[tester waitForTimeInterval:0.5];
}
NSLog(@"Switching to a valid account");
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Start")];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Sign in linphone.org account")];
[tester enterText:@"testios" intoViewWithAccessibilityLabel:LOCALIZED(@"Username")];
[tester enterText:@"testtest" intoViewWithAccessibilityLabel:LOCALIZED(@"Password")];
[tester tapViewWithAccessibilityLabel:LOCALIZED(@"Sign in")];
invalidAccount = false;
}
if ([tester tryFindingViewWithAccessibilityLabel:@"Launch Wizard" error:nil]) {
[tester tapViewWithAccessibilityLabel:@"Launch Wizard"];
[tester waitForTimeInterval:0.5];
}
NSLog(@"Switching to a valid account");
[tester tapViewWithAccessibilityLabel:@"Start"];
[tester tapViewWithAccessibilityLabel:@"Sign in linphone.org account"];
[tester enterText:@"testios" intoViewWithAccessibilityLabel:@"Username"];
[tester enterText:@"testtest" intoViewWithAccessibilityLabel:@"Password"];
[tester tapViewWithAccessibilityLabel:@"Sign in"];
invalidAccount = false;
}
}