LinphoneUITester: add performance tests for big conversation and big chats list

This commit is contained in:
Gautier Pelloux-Prayer 2015-09-01 12:05:16 +02:00
parent 8a8cb70c92
commit c75a000e9a
5 changed files with 84 additions and 23 deletions

View file

@ -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];
}

View file

@ -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;
}

View file

@ -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];

View file

@ -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 */,

@ -1 +1 @@
Subproject commit af43ad89650f70ce5e2fb4a45287aabbdd9b63d6
Subproject commit a722c765153c7f0065ccca1137c7b4d97294477f