mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
LinphoneUITester: fix broken UI tests and reorder tests in execution order (eg alphabetical)
This commit is contained in:
parent
cb37695d86
commit
1689b30026
8 changed files with 175 additions and 165 deletions
|
|
@ -184,6 +184,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
linphone_core_add_auth_info([LinphoneManager getLc], auth_info);
|
||||
linphone_core_add_proxy_config([LinphoneManager getLc], proxyCfg);
|
||||
linphone_core_set_default_proxy_config([LinphoneManager getLc], proxyCfg);
|
||||
// reload address book to prepend proxy config domain to contacts' phone number
|
||||
[[[LinphoneManager instance] fastAddressBook] reload];
|
||||
[self.waitView setHidden:false];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -511,6 +511,8 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
|||
// was a new proxy config, add it
|
||||
linphone_core_add_proxy_config(lc, proxyCfg);
|
||||
linphone_core_set_default_proxy_config(lc, proxyCfg);
|
||||
// reload address book to prepend proxy config domain to contacts' phone number
|
||||
[[[LinphoneManager instance] fastAddressBook] reload];
|
||||
}
|
||||
|
||||
bad_proxy:
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#import "LinphoneManager.h"
|
||||
#import "LinphoneCoreSettingsStore.h"
|
||||
#import "Utils/FileTransferDelegate.h"
|
||||
|
||||
#include "linphone/linphonecore_utils.h"
|
||||
#include "linphone/lpconfig.h"
|
||||
|
|
@ -1453,6 +1454,12 @@ static BOOL libStarted = FALSE;
|
|||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
if (theLinphoneCore != nil) { //just in case application terminate before linphone core initialization
|
||||
|
||||
for (FileTransferDelegate *ftd in _fileTransferDelegates) {
|
||||
[ftd stopAndDestroy];
|
||||
}
|
||||
[_fileTransferDelegates removeAllObjects];
|
||||
|
||||
LOGI(@"Destroy linphonecore");
|
||||
linphone_core_destroy(theLinphoneCore);
|
||||
theLinphoneCore = nil;
|
||||
|
|
|
|||
|
|
@ -127,14 +127,11 @@
|
|||
}
|
||||
|
||||
int count = linphone_chat_room_get_unread_messages_count(chatRoom);
|
||||
if (count > 0) {
|
||||
[unreadMessageView setHidden:FALSE];
|
||||
unreadMessageLabel.text = [NSString stringWithFormat:@"%i", count];
|
||||
} else {
|
||||
[unreadMessageView setHidden:TRUE];
|
||||
}
|
||||
unreadMessageLabel.text = [NSString stringWithFormat:@"%i", count];
|
||||
[unreadMessageView setHidden:(count <= 0)];
|
||||
} else {
|
||||
chatContentLabel.text = nil;
|
||||
unreadMessageLabel.text = [NSString stringWithFormat:@"0"];
|
||||
[unreadMessageView setHidden:TRUE];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -456,11 +456,12 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
|
|||
// the transient message will not be found and it will not appear in the list of
|
||||
// message, so we must refresh the table when we change to this state to ensure that
|
||||
// all transient messages apppear
|
||||
ChatRoomViewController *controller = DYNAMIC_CAST(
|
||||
[[PhoneMainView instance] changeCurrentView:[ChatRoomViewController compositeViewDescription] push:TRUE],
|
||||
ChatRoomViewController);
|
||||
[controller.tableController setChatRoom:linphone_chat_message_get_chat_room(msg)];
|
||||
// UGLY HACK, must be fixed in file transfer cb
|
||||
// ChatRoomViewController *controller = DYNAMIC_CAST(
|
||||
// [[PhoneMainView instance] changeCurrentView:[ChatRoomViewController compositeViewDescription]
|
||||
// push:TRUE],
|
||||
// ChatRoomViewController);
|
||||
// [controller.tableController setChatRoom:linphone_chat_message_get_chat_room(msg)];
|
||||
// This is breaking interface too much, it must be fixed in file transfer cb.. meanwhile, disabling it.
|
||||
}
|
||||
[thiz update];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -505,6 +505,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
linphone_core_add_auth_info(lc, info);
|
||||
linphone_core_add_proxy_config(lc, proxyCfg);
|
||||
linphone_core_set_default_proxy_config(lc, proxyCfg);
|
||||
// reload address book to prepend proxy config domain to contacts' phone number
|
||||
[[[LinphoneManager instance] fastAddressBook] reload];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -534,6 +536,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
linphone_core_add_auth_info([LinphoneManager getLc], info);
|
||||
linphone_core_add_proxy_config([LinphoneManager getLc], proxyCfg);
|
||||
linphone_core_set_default_proxy_config([LinphoneManager getLc], proxyCfg);
|
||||
// reload address book to prepend proxy config domain to contacts' phone number
|
||||
[[[LinphoneManager instance] fastAddressBook] reload];
|
||||
}
|
||||
|
||||
- (NSString*)identityFromUsername:(NSString*)username {
|
||||
|
|
|
|||
|
|
@ -61,41 +61,130 @@
|
|||
[tester tapViewWithAccessibilityLabel:@"Send"];
|
||||
}
|
||||
|
||||
- (void)uploadImageWithQuality:(NSString *)quality {
|
||||
UITableView *tv = [self findTableView:@"Chat list"];
|
||||
|
||||
long messagesCount = [tv numberOfRowsInSection:0];
|
||||
[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
|
||||
[tester acknowledgeSystemAlert];
|
||||
[tester waitForTimeInterval:1];
|
||||
#endif
|
||||
}
|
||||
|
||||
// select random photo to avoid having the same multiple times
|
||||
[tester choosePhotoInAlbum:@"Camera Roll" atRow:1 column:1 + messagesCount % 4];
|
||||
|
||||
// wait for the quality popup to show up
|
||||
[tester waitForTimeInterval:1];
|
||||
|
||||
UIAccessibilityElement *element =
|
||||
[[UIApplication sharedApplication] accessibilityElementMatchingBlock:^BOOL(UIAccessibilityElement *element) {
|
||||
return [element.accessibilityLabel containsString:quality];
|
||||
}];
|
||||
[tester tapViewWithAccessibilityLabel:element.accessibilityLabel];
|
||||
}
|
||||
|
||||
- (void)downloadImage {
|
||||
[self startChatWith:[self me]];
|
||||
[self uploadImageWithQuality:@"Minimum"];
|
||||
// wait for the upload to terminate...
|
||||
for (int i = 0; i < 15; i++) {
|
||||
[tester waitForTimeInterval:1.f];
|
||||
if ([[[LinphoneManager instance] fileTransferDelegates] count] == 0)
|
||||
break;
|
||||
}
|
||||
[tester waitForViewWithAccessibilityLabel:@"Download"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Download"];
|
||||
[tester waitForTimeInterval:.5f]; // just wait a few secs to start download
|
||||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 1);
|
||||
}
|
||||
|
||||
#pragma mark - tests
|
||||
|
||||
- (void)testSendMessageToMyself {
|
||||
- (void)test3DownloadsSimultanously {
|
||||
[self startChatWith:[self me]];
|
||||
|
||||
[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 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;
|
||||
}
|
||||
ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
[tester waitForViewWithAccessibilityLabel:@"Download"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Download"];
|
||||
[tester waitForTimeInterval:.2f]; // just wait a few secs to start download
|
||||
if (i != 2)
|
||||
[tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:-.5f];
|
||||
}
|
||||
while ([LinphoneManager instance].fileTransferDelegates.count > 0) {
|
||||
[tester waitForTimeInterval:.5];
|
||||
}
|
||||
[self goBackFromChat];
|
||||
}
|
||||
|
||||
- (void)testInvalidSIPAddress {
|
||||
|
||||
[self startChatWith:@"sip://toto"];
|
||||
|
||||
[tester waitForViewWithAccessibilityLabel:@"Invalid address" traits:UIAccessibilityTraitStaticText];
|
||||
[tester tapViewWithAccessibilityLabel:@"Cancel"];
|
||||
}
|
||||
|
||||
- (void)testSendToSIPAddress {
|
||||
NSString *sipAddr = [NSString stringWithFormat:@"sip:%@@%@", [self me], [self accountDomain]];
|
||||
|
||||
[self startChatWith:sipAddr];
|
||||
|
||||
[tester waitForViewWithAccessibilityLabel:@"Contact name" value:[self me] traits:0];
|
||||
|
||||
- (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:@"Maximum"];
|
||||
[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;
|
||||
}
|
||||
ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0);
|
||||
ASSERT_EQ([tv numberOfRowsInSection:0], 6);
|
||||
[self goBackFromChat];
|
||||
}
|
||||
|
||||
- (void)testChatMessageRemoval {
|
||||
- (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"];
|
||||
if ([[[LinphoneManager instance] fileTransferDelegates] count] != 0) {
|
||||
[[UIApplication sharedApplication] writeScreenshotForLine:__LINE__ inFile:@__FILE__ description:nil error:NULL];
|
||||
;
|
||||
}
|
||||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0);
|
||||
}
|
||||
|
||||
- (void)testChatFromContactPhoneNumber {
|
||||
[tester tapViewWithAccessibilityLabel:@"New Discussion"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Anna Haro"];
|
||||
[tester tapViewWithAccessibilityLabel:@"home, 555-522-8243"];
|
||||
[self goBackFromChat];
|
||||
UITableView *tv = [self findTableView:@"ChatRoom list"];
|
||||
ASSERT_EQ([tv numberOfRowsInSection:0], 1);
|
||||
[tester waitForViewWithAccessibilityLabel:@"Contact name, Message"
|
||||
value:@"Anna Haro (0)"
|
||||
traits:UIAccessibilityTraitStaticText];
|
||||
}
|
||||
|
||||
- (void)testDownloadImage {
|
||||
[self downloadImage];
|
||||
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Cancel transfer"];
|
||||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0);
|
||||
}
|
||||
|
||||
- (void)testMessageRemoval {
|
||||
NSString *user = [self getUUID];
|
||||
|
||||
[self startChatWith:user];
|
||||
|
|
@ -123,6 +212,14 @@
|
|||
[self goBackFromChat];
|
||||
}
|
||||
|
||||
- (void)testInvalidSIPAddress {
|
||||
|
||||
[self startChatWith:@"sip://toto"];
|
||||
|
||||
[tester waitForViewWithAccessibilityLabel:@"Invalid address" traits:UIAccessibilityTraitStaticText];
|
||||
[tester tapViewWithAccessibilityLabel:@"Cancel"];
|
||||
}
|
||||
|
||||
- (void)testRemoveAllChats {
|
||||
NSArray *uuids = [self getUUIDArrayOfSize:5];
|
||||
|
||||
|
|
@ -150,31 +247,27 @@
|
|||
ASSERT_EQ(linphone_core_get_chat_rooms([LinphoneManager getLc]), NULL);
|
||||
}
|
||||
|
||||
- (void)uploadImageWithQuality:(NSString *)quality {
|
||||
UITableView *tv = [self findTableView:@"Chat list"];
|
||||
- (void)testSendMessageToMyself {
|
||||
[self startChatWith:[self me]];
|
||||
|
||||
long messagesCount = [tv numberOfRowsInSection:0];
|
||||
[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
|
||||
[tester acknowledgeSystemAlert];
|
||||
[tester waitForTimeInterval:1];
|
||||
#endif
|
||||
}
|
||||
[self sendMessage:@"Hello"];
|
||||
|
||||
// select random photo to avoid having the same multiple times
|
||||
[tester choosePhotoInAlbum:@"Camera Roll" atRow:1 column:1 + messagesCount % 4];
|
||||
[tester waitForViewWithAccessibilityLabel:@"Outgoing message" value:@"Hello" traits:UIAccessibilityTraitStaticText];
|
||||
[tester waitForViewWithAccessibilityLabel:@"Incoming message" value:@"Hello" traits:UIAccessibilityTraitStaticText];
|
||||
|
||||
// wait for the quality popup to show up
|
||||
[tester waitForTimeInterval:1];
|
||||
[tester waitForViewWithAccessibilityLabel:@"Message status" value:@"delivered" traits:UIAccessibilityTraitImage];
|
||||
|
||||
UIAccessibilityElement *element =
|
||||
[[UIApplication sharedApplication] accessibilityElementMatchingBlock:^BOOL(UIAccessibilityElement *element) {
|
||||
return [element.accessibilityLabel containsString:quality];
|
||||
}];
|
||||
[tester tapViewWithAccessibilityLabel:element.accessibilityLabel];
|
||||
[self goBackFromChat];
|
||||
}
|
||||
|
||||
- (void)testSendToSIPAddress {
|
||||
NSString *sipAddr = [NSString stringWithFormat:@"sip:%@@%@", [self me], [self accountDomain]];
|
||||
|
||||
[self startChatWith:sipAddr];
|
||||
|
||||
[tester waitForViewWithAccessibilityLabel:@"Contact name" value:[self me] traits:0];
|
||||
|
||||
[self goBackFromChat];
|
||||
}
|
||||
|
||||
- (void)testUploadImage {
|
||||
|
|
@ -202,96 +295,4 @@
|
|||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0);
|
||||
}
|
||||
|
||||
- (void)testCancelUploadImage {
|
||||
[self startChatWith:[self me]];
|
||||
[self uploadImageWithQuality:@"Minimum"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Cancel transfer"];
|
||||
if ([[[LinphoneManager instance] fileTransferDelegates] count] != 0) {
|
||||
[[UIApplication sharedApplication] writeScreenshotForLine:__LINE__ inFile:@__FILE__ description:nil error:NULL];
|
||||
;
|
||||
}
|
||||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0);
|
||||
}
|
||||
|
||||
- (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:@"Maximum"];
|
||||
[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;
|
||||
}
|
||||
ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0);
|
||||
ASSERT_EQ([tv numberOfRowsInSection:0], 6);
|
||||
[self goBackFromChat];
|
||||
}
|
||||
|
||||
- (void)downloadImage {
|
||||
[self startChatWith:[self me]];
|
||||
[self uploadImageWithQuality:@"Minimum"];
|
||||
// wait for the upload to terminate...
|
||||
for (int i = 0; i < 15; i++) {
|
||||
[tester waitForTimeInterval:1.f];
|
||||
if ([[[LinphoneManager instance] fileTransferDelegates] count] == 0)
|
||||
break;
|
||||
}
|
||||
[tester waitForViewWithAccessibilityLabel:@"Download"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Download"];
|
||||
[tester waitForTimeInterval:.5f]; // just wait a few secs to start download
|
||||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 1);
|
||||
}
|
||||
|
||||
- (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;
|
||||
}
|
||||
ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0);
|
||||
[tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:1];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
[tester waitForViewWithAccessibilityLabel:@"Download"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Download"];
|
||||
[tester waitForTimeInterval:.5f]; // just wait a few secs to start download
|
||||
if (i != 2)
|
||||
[tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:-.5f];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testDownloadImage {
|
||||
[self downloadImage];
|
||||
[tester waitForAbsenceOfViewWithAccessibilityLabel:@"Cancel transfer"];
|
||||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0);
|
||||
}
|
||||
|
||||
- (void)testCancelDownloadImage {
|
||||
[self downloadImage];
|
||||
[tester tapViewWithAccessibilityLabel:@"Cancel transfer"];
|
||||
ASSERT_EQ([[[LinphoneManager instance] fileTransferDelegates] count], 0);
|
||||
}
|
||||
|
||||
- (void)testChatFromContactPhoneNumber {
|
||||
[tester tapViewWithAccessibilityLabel:@"New Discussion"];
|
||||
[tester tapViewWithAccessibilityLabel:@"Anna Haro"];
|
||||
[tester tapViewWithAccessibilityLabel:@"home, 555-522-8243"];
|
||||
[self goBackFromChat];
|
||||
UITableView *tv = [self findTableView:@"ChatRoom list"];
|
||||
ASSERT_EQ([tv numberOfRowsInSection:0], 1);
|
||||
[tester waitForViewWithAccessibilityLabel:@"Contact name, Message"
|
||||
value:@"Anna Haro (0)"
|
||||
traits:UIAccessibilityTraitStaticText];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -68,6 +68,18 @@
|
|||
|
||||
#pragma mark - Tests
|
||||
|
||||
- (void)testExternalLoginWithUDP {
|
||||
[self _externalLoginWithProtocol:@"UDP"];
|
||||
}
|
||||
|
||||
- (void)testExternalLoginWithTCP {
|
||||
[self _externalLoginWithProtocol:@"TCP"];
|
||||
}
|
||||
|
||||
- (void)testExternalLoginWithTLS {
|
||||
[self _externalLoginWithProtocol:@"TLS"];
|
||||
}
|
||||
|
||||
- (void)testLinphoneLogin {
|
||||
|
||||
[self _linphoneLogin:[self me] withPW:@"testtest"];
|
||||
|
|
@ -98,20 +110,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void)testExternalLoginWithUDP {
|
||||
[self _externalLoginWithProtocol:@"UDP"];
|
||||
}
|
||||
|
||||
- (void)testExternalLoginWithTCP {
|
||||
[self _externalLoginWithProtocol:@"TCP"];
|
||||
}
|
||||
|
||||
- (void)testExternalLoginWithTLS {
|
||||
[self _externalLoginWithProtocol:@"TLS"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue