From c75a000e9a05dc71e31e7857ad6073a4198d5f8b Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 1 Sep 2015 12:05:16 +0200 Subject: [PATCH] LinphoneUITester: add performance tests for big conversation and big chats list --- .../LinphoneUI/UICompositeViewController.m | 4 +- Classes/PhoneMainView.m | 46 ++++++++++------ TestsUI/ChatTester.m | 53 +++++++++++++++++-- linphone.xcodeproj/project.pbxproj | 2 + submodules/linphone | 2 +- 5 files changed, 84 insertions(+), 23 deletions(-) diff --git a/Classes/LinphoneUI/UICompositeViewController.m b/Classes/LinphoneUI/UICompositeViewController.m index c64726546..5fe8f8be4 100644 --- a/Classes/LinphoneUI/UICompositeViewController.m +++ b/Classes/LinphoneUI/UICompositeViewController.m @@ -425,7 +425,9 @@ UIViewController *newStateBarViewController = [self getCachedController:description.stateBar]; UIViewController *newTabBarViewController = [self getCachedController:description.tabBar]; - [UICompositeViewController removeSubView:oldContentViewController]; + if (oldContentViewController != newContentViewController) { + [UICompositeViewController removeSubView:oldContentViewController]; + } if (oldTabBarViewController != nil && oldTabBarViewController != newTabBarViewController) { [UICompositeViewController removeSubView:oldTabBarViewController]; } diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 407e5b599..c9d48d9e7 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -77,24 +77,36 @@ static RootViewManager *rootViewManagerInstance = nil; currentViewController = newMainView; LinphoneAppDelegate *delegate = (LinphoneAppDelegate *)[UIApplication sharedApplication].delegate; - [UIView transitionWithView:delegate.window - duration:0.3 - options:UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionAllowAnimatedContent - animations:^{ - delegate.window.rootViewController = newMainView; - // when going to landscape-enabled view, we have to get the current portrait frame and orientation, - // because it could still have landscape-based size - if (nextViewOrientation != previousOrientation && newMainView == self.rotatingViewController) { - newMainView.view.frame = previousMainView.view.frame; - [newMainView.mainViewController.view setFrame:previousMainView.mainViewController.view.frame]; - [newMainView willRotateToInterfaceOrientation:previousOrientation duration:0.3]; - [newMainView willAnimateRotationToInterfaceOrientation:previousOrientation duration:0.3]; - [newMainView didRotateFromInterfaceOrientation:nextViewOrientation]; - } - + if ([[LinphoneManager instance] lpConfigBoolForKey:@"animations_preference"] == true) { + [UIView transitionWithView:delegate.window + duration:0.3 + options:UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionAllowAnimatedContent + animations:^{ + delegate.window.rootViewController = newMainView; + // when going to landscape-enabled view, we have to get the current portrait frame and orientation, + // because it could still have landscape-based size + if (nextViewOrientation != previousOrientation && newMainView == self.rotatingViewController) { + newMainView.view.frame = previousMainView.view.frame; + [newMainView.mainViewController.view setFrame:previousMainView.mainViewController.view.frame]; + [newMainView willRotateToInterfaceOrientation:previousOrientation duration:0.3]; + [newMainView willAnimateRotationToInterfaceOrientation:previousOrientation duration:0.3]; + [newMainView didRotateFromInterfaceOrientation:nextViewOrientation]; + } + } + completion:^(BOOL finished){ + }]; + } else { + delegate.window.rootViewController = newMainView; + // when going to landscape-enabled view, we have to get the current portrait frame and orientation, + // because it could still have landscape-based size + if (nextViewOrientation != previousOrientation && newMainView == self.rotatingViewController) { + newMainView.view.frame = previousMainView.view.frame; + [newMainView.mainViewController.view setFrame:previousMainView.mainViewController.view.frame]; + [newMainView willRotateToInterfaceOrientation:previousOrientation duration:0.]; + [newMainView willAnimateRotationToInterfaceOrientation:previousOrientation duration:0.]; + [newMainView didRotateFromInterfaceOrientation:nextViewOrientation]; } - completion:^(BOOL finished){ - }]; + } } return currentViewController; } diff --git a/TestsUI/ChatTester.m b/TestsUI/ChatTester.m index 95a81c1cc..38005d81a 100644 --- a/TestsUI/ChatTester.m +++ b/TestsUI/ChatTester.m @@ -165,10 +165,6 @@ [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); } @@ -226,6 +222,55 @@ [tester tapViewWithAccessibilityLabel:@"Cancel"]; } +- (void)testPerformanceHugeChatList { + [tester tapViewWithAccessibilityLabel:@"Dialer"]; + + // create lots of chat rooms... + LinphoneCore *lc = [LinphoneManager getLc]; + for (int i = 0; i < 100; i++) { + LinphoneChatRoom *room = + linphone_core_get_chat_room_from_uri(lc, [[NSString stringWithFormat:@"%@ - %d", [self me], i] UTF8String]); + linphone_chat_room_send_message(room, "Hello"); + } + + [tester waitForTimeInterval:5]; // wait for all messages to be delivered + + NSTimeInterval before = [[NSDate date] timeIntervalSince1970]; + [tester tapViewWithAccessibilityLabel:@"Chat"]; + NSTimeInterval after = [[NSDate date] timeIntervalSince1970]; + + // delete all rooms from test because it takes time when done by tester + [tester tapViewWithAccessibilityLabel:@"Dialer"]; + for (MSList *it = linphone_core_get_chat_rooms(lc); it != NULL; it = it->next) { + linphone_chat_room_delete_history(it->data); + } + + // conversation loading MUST be less than 1 sec + XCTAssertLessThan(after - before, 1.); +} + +- (void)testPerformanceHugeConversation { + int count = 0; + LinphoneCore *lc = [LinphoneManager getLc]; + LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(lc, [[self me] UTF8String]); + // generate lots of messages... + for (; count < 100; count++) { + linphone_chat_room_send_message(room, [[NSString stringWithFormat:@"Message %d", count + 1] UTF8String]); + } + [tester waitForTimeInterval:5]; // wait for all messages to be delivered + // TODO: FIX below code: unread count is not always 100 messages while it should... + [tester waitForViewWithAccessibilityLabel:@"Contact name, Message, Unread message number" + value:[NSString stringWithFormat:@"%@ - Message %d (%d)", self.me, count, count] + traits:UIAccessibilityTraitStaticText]; + + NSTimeInterval before = [[NSDate date] timeIntervalSince1970]; + [self startChatWith:[self me]]; + NSTimeInterval after = [[NSDate date] timeIntervalSince1970]; + + // conversation loading MUST be less than 1 sec - opening an empty conversation is around 2.15 sec + XCTAssertLessThan(after - before, 2.15 + 1.); +} + - (void)testRemoveAllChats { NSArray *uuids = [self getUUIDArrayOfSize:5]; diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index f1cf39681..43aef7f4c 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -150,6 +150,7 @@ 631C4FB719D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m in Sources */ = {isa = PBXBuildFile; fileRef = 631C4FB619D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m */; }; 632DA24D1B43EE9400EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; 632DA24E1B43EEEF00EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; + 635ED88B1B95A3B500404347 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 152F22351B15E889008C0621 /* libxml2.dylib */; }; 636316D11A1DEBCB0009B839 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D31A1DEBCB0009B839 /* AboutViewController.xib */; }; 636316D41A1DEC650009B839 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D61A1DEC650009B839 /* SettingsViewController.xib */; }; 636316D91A1DECC90009B839 /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D71A1DECC90009B839 /* PhoneMainView.xib */; }; @@ -2013,6 +2014,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 635ED88B1B95A3B500404347 /* libxml2.dylib in Frameworks */, 63C5107C1B8DF3DF008A415A /* libbellesip.a in Frameworks */, 63C5107D1B8DF3DF008A415A /* liblinphonetester.a in Frameworks */, 63C5107E1B8DF3DF008A415A /* libmediastreamer_base.a in Frameworks */, diff --git a/submodules/linphone b/submodules/linphone index af43ad896..a722c7651 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit af43ad89650f70ce5e2fb4a45287aabbdd9b63d6 +Subproject commit a722c765153c7f0065ccca1137c7b4d97294477f