From 50ebe553d8d64945941d128b97683cf8d8615848 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 26 Jun 2015 11:48:41 +0200 Subject: [PATCH] Tests: do not execute each test separately --- LinphoneTester/DetailViewController.m | 84 ++++++++++++--------------- submodules/belle-sip | 2 +- submodules/linphone | 2 +- 3 files changed, 40 insertions(+), 48 deletions(-) diff --git a/LinphoneTester/DetailViewController.m b/LinphoneTester/DetailViewController.m index c2aaf1eaa..3b443f88f 100644 --- a/LinphoneTester/DetailViewController.m +++ b/LinphoneTester/DetailViewController.m @@ -148,27 +148,13 @@ static NSString* const kAllTestsName = @"Run All tests"; - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the specified item to be editable. return NO; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:FALSE]; - if( !in_progress ){ - if( indexPath.row == 0 ){ - - // run all tests - NSMutableArray* paths = [[NSMutableArray alloc] init]; - for (int i = 1; i<_tests.count; i++) { - [paths addObject:[NSIndexPath indexPathForRow:i inSection:0]]; - } - [self launchTest:paths]; - - } else { - [self launchTest:@[indexPath]]; - } - } + [self launchTests:indexPath]; } @@ -177,38 +163,44 @@ static NSString* const kAllTestsName = @"Run All tests"; withRowAnimation:animate?UITableViewRowAnimationFade:UITableViewRowAnimationNone]; } +- (void)launchTests:(NSIndexPath *)index { + if (in_progress) { + LSLog(@"Test already in progress"); + return; + } + in_progress = TRUE; --(void)launchTest:(NSArray*)paths { - for (NSIndexPath* path in paths) { - TestItem *test = _tests[path.row]; - test.state = TestStateInProgress; - } - [self updateItem:paths withAnimation:FALSE]; - - dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - in_progress = TRUE; - - dispatch_async(queue, ^{ - for (NSIndexPath*path in paths) { - - TestItem *test = _tests[path.row]; - LSLog(@"Should launch test %@", test); - - BOOL fail = bc_tester_run_tests([test.suite UTF8String], [test.name UTF8String]); - if(fail){ - LSLog(@"Test Failed!"); - test.state = TestStateFailed; - } else { - LSLog(@"Test Passed!"); - test.state = TestStatePassed; - } - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self updateItem:@[path] withAnimation:TRUE]; - in_progress = FALSE; - }); - } - }); + TestItem *test = _tests[index.row]; + test.state = TestStateInProgress; + [self updateItem:@[ index ] withAnimation:FALSE]; + + dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + + dispatch_async(queue, ^{ + TestItem *test = _tests[index.row]; + LSLog(@"Should launch test %@", test); + NSString *testSuite = test.suite; + if ([test.suite isEqualToString:@"All"]) { + testSuite = nil; + } + NSString *testName = test.name; + if ([test.name isEqualToString:kAllTestsName]) { + testName = nil; + } + BOOL fail = bc_tester_run_tests([testSuite UTF8String], [testName UTF8String]); + if (fail) { + LSLog(@"Test Failed!"); + test.state = TestStateFailed; + } else { + LSLog(@"Test Passed!"); + test.state = TestStatePassed; + } + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self updateItem:@[ index ] withAnimation:TRUE]; + in_progress = FALSE; + }); + }); } diff --git a/submodules/belle-sip b/submodules/belle-sip index dd2d1ca8b..2f795533d 160000 --- a/submodules/belle-sip +++ b/submodules/belle-sip @@ -1 +1 @@ -Subproject commit dd2d1ca8b3f56044f9ff85f0647184204ae382b2 +Subproject commit 2f795533d68784ae58abd6a43b24281d33c5730d diff --git a/submodules/linphone b/submodules/linphone index 9c961d9e8..cb878f6c0 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 9c961d9e861dc3c687f21ac3806e4cbb60ffee08 +Subproject commit cb878f6c007cf87e0585edf7e3bc999dbe818c81