diff --git a/Classes/FirstLoginViewController.m b/Classes/FirstLoginViewController.m index 775601a25..d81c61b74 100644 --- a/Classes/FirstLoginViewController.m +++ b/Classes/FirstLoginViewController.m @@ -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]; }; } diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 1dda9470b..643bc2c46 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -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: diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index b79ac5886..2af127a7e 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -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; diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index f615b14e3..ec1dc22c1 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -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]; } } diff --git a/Classes/LinphoneUI/UIChatRoomCell.m b/Classes/LinphoneUI/UIChatRoomCell.m index b92ab009e..49f747e50 100644 --- a/Classes/LinphoneUI/UIChatRoomCell.m +++ b/Classes/LinphoneUI/UIChatRoomCell.m @@ -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]; } diff --git a/Classes/WizardViewController.m b/Classes/WizardViewController.m index 4b2250d9e..41745291f 100644 --- a/Classes/WizardViewController.m +++ b/Classes/WizardViewController.m @@ -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 { diff --git a/KifTests/ChatTester.m b/KifTests/ChatTester.m index 5b5387b51..ae7500274 100644 --- a/KifTests/ChatTester.m +++ b/KifTests/ChatTester.m @@ -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 diff --git a/KifTests/WizardTester.m b/KifTests/WizardTester.m index 19f9fd572..bd0f11947 100644 --- a/KifTests/WizardTester.m +++ b/KifTests/WizardTester.m @@ -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