diff --git a/LinphoneTester/Base.lproj/Main_iPad.storyboard b/LinphoneTester/Base.lproj/Main_iPad.storyboard index d97e6f1c3..17746dea5 100644 --- a/LinphoneTester/Base.lproj/Main_iPad.storyboard +++ b/LinphoneTester/Base.lproj/Main_iPad.storyboard @@ -1,6 +1,7 @@ - + + @@ -27,6 +28,7 @@ + diff --git a/LinphoneTester/Base.lproj/Main_iPhone.storyboard b/LinphoneTester/Base.lproj/Main_iPhone.storyboard index 1834d0a0d..00ded41d0 100644 --- a/LinphoneTester/Base.lproj/Main_iPhone.storyboard +++ b/LinphoneTester/Base.lproj/Main_iPhone.storyboard @@ -1,6 +1,7 @@ - + + @@ -56,7 +57,21 @@ - + + + + + @@ -90,11 +105,70 @@ - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -102,4 +176,7 @@ + + + diff --git a/LinphoneTester/DetailViewController.h b/LinphoneTester/DetailViewController.h index 053821181..7564fe5e5 100644 --- a/LinphoneTester/DetailViewController.h +++ b/LinphoneTester/DetailViewController.h @@ -8,6 +8,25 @@ #import +typedef NS_ENUM(int, TestState) { + TestStateIdle, + TestStatePassed, + TestStateInProgress, + TestStateFailed +}; + +@interface TestItem : NSObject + + +@property (strong, nonatomic) NSString* suite; +@property (strong, nonatomic) NSString* name; +@property (nonatomic) TestState state; + +-(id)initWithName:(NSString*)name fromSuite:(NSString*)suite; ++(TestItem*)testWithName:(NSString*)name fromSuite:(NSString*)suite; + +@end + @interface DetailViewController : UITableViewController @property (strong, nonatomic) NSString* detailItem; diff --git a/LinphoneTester/DetailViewController.m b/LinphoneTester/DetailViewController.m index 492a1b195..17bb0d84b 100644 --- a/LinphoneTester/DetailViewController.m +++ b/LinphoneTester/DetailViewController.m @@ -7,10 +7,37 @@ // #import "DetailViewController.h" +#import "MasterViewController.h" +#import "LogsViewController.h" #include "linphone/liblinphone_tester.h" +static NSString* const kAllTestsName = @"Run All tests"; + +@implementation TestItem + +-(id)initWithName:(NSString *)name fromSuite:(NSString *)suite { + self = [super init]; + if( self ){ + self.name = name; + self.suite = suite; + self.state = TestStateIdle; + } + return self; +} + ++(TestItem *)testWithName:(NSString *)name fromSuite:(NSString *)suite{ + return [[TestItem alloc] initWithName:name fromSuite:suite]; +} + +-(NSString*)description { + return [NSString stringWithFormat:@"{suite:'%@', test:'%@', state:%d}", _suite, _name, _state]; +} + +@end + @interface DetailViewController () { NSMutableArray* _tests; + BOOL in_progress; } @property (strong, nonatomic) UIPopoverController *masterPopoverController; - (void)configureView; @@ -37,11 +64,16 @@ - (void)configureView { const char* suite = [self.detailItem UTF8String]; + NSString* nssuite = [NSString stringWithUTF8String:suite]; int count = liblinphone_tester_nb_tests(suite); _tests = [[NSMutableArray alloc] initWithCapacity:count]; + + [_tests addObject:[TestItem testWithName:kAllTestsName fromSuite:nssuite]]; + for (int i=0; i${PRODUCT_NAME} CFBundleExecutable ${EXECUTABLE_NAME} + CFBundleIcons + + CFBundleIcons~ipad + CFBundleIdentifier com.belledonne-communications.tester.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion diff --git a/LinphoneTester/LogsViewController.h b/LinphoneTester/LogsViewController.h new file mode 100644 index 000000000..f18bfbc47 --- /dev/null +++ b/LinphoneTester/LogsViewController.h @@ -0,0 +1,17 @@ +// +// LogsViewController.h +// linphone +// +// Created by Guillaume BIENKOWSKI on 01/06/2014. +// +// + +#import + + +@interface LogsViewController : UIViewController +@property (weak, nonatomic) IBOutlet UITextView *tview; + +- (IBAction)clearLogs:(id)sender; + +@end diff --git a/LinphoneTester/LogsViewController.m b/LinphoneTester/LogsViewController.m new file mode 100644 index 000000000..0d730098e --- /dev/null +++ b/LinphoneTester/LogsViewController.m @@ -0,0 +1,52 @@ +// +// LogsViewController.m +// linphone +// +// Created by Guillaume BIENKOWSKI on 01/06/2014. +// +// + +#import "LogsViewController.h" +#import "MasterViewController.h" + +@interface LogsViewController () { + NSString* txt; +} + +@end + +@implementation LogsViewController + + + +- (void)viewDidLoad +{ + [super viewDidLoad]; +} + +- (void)viewDidAppear:(BOOL)animated { + self.tview.textContainer.lineBreakMode = NSLineBreakByClipping; + self.tview.text = [lastLogs componentsJoinedByString:@"\n"]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(updateLogs:) + name:kLogsUpdateNotification + object:nil]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (IBAction)clearLogs:(id)sender { + + self.tview.text = nil; +} + +- (void)updateLogs:(NSNotification*)notif { + NSArray* newLogs = [notif.userInfo objectForKey:@"newlogs"]; + dispatch_async(dispatch_get_main_queue(), ^{ + self.tview.text = [self.tview.text stringByAppendingString:[newLogs componentsJoinedByString:@"\n"] ]; + }); +} + +@end diff --git a/LinphoneTester/MasterViewController.h b/LinphoneTester/MasterViewController.h index 84d6a9c16..63675b1b0 100644 --- a/LinphoneTester/MasterViewController.h +++ b/LinphoneTester/MasterViewController.h @@ -8,6 +8,11 @@ #import +void LSLog(NSString* fmt, ...); + +NSMutableArray* lastLogs; +NSString* const kLogsUpdateNotification; + @class DetailViewController; @interface MasterViewController : UITableViewController @@ -15,3 +20,4 @@ @property (strong, nonatomic) DetailViewController *detailViewController; @end + diff --git a/LinphoneTester/MasterViewController.m b/LinphoneTester/MasterViewController.m index 7a4015022..a05e0d081 100644 --- a/LinphoneTester/MasterViewController.m +++ b/LinphoneTester/MasterViewController.m @@ -7,13 +7,14 @@ // #import "MasterViewController.h" - +#import "LogsViewController.h" #import "DetailViewController.h" #include "linphone/liblinphone_tester.h" @interface MasterViewController () { NSMutableArray *_objects; + NSString* bundlePath; } @end @@ -28,18 +29,63 @@ [super awakeFromNib]; } +NSMutableArray* lastLogs = nil; +NSMutableArray* logsBuffer = nil; +static int const kLastLogsCapacity = 5000; +static int const kLogsBufferCapacity = 10; +NSString* const kLogsUpdateNotification = @"kLogsUpdateNotification"; + +void LSLog(NSString* fmt, ...){ + va_list args; + va_start(args, fmt); + linphone_log_function(ORTP_MESSAGE, [fmt UTF8String], args); + va_end(args); +} + +static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list args) { + NSString* log = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:fmt] arguments:args]; + //NSLog(@"%@",log); + + [logsBuffer addObject:log]; + + if (logsBuffer.count >= kLogsBufferCapacity ) { + [lastLogs addObjectsFromArray:logsBuffer]; + + if( lastLogs.count >= kLastLogsCapacity - kLogsBufferCapacity ){ + [lastLogs removeObjectsInRange:NSMakeRange(0, kLogsBufferCapacity)]; + } + [[NSNotificationCenter defaultCenter] postNotificationName:kLogsUpdateNotification + object:nil + userInfo:@{@"newlogs": [logsBuffer copy]}]; + [logsBuffer removeAllObjects]; + } + + +} + +- (void)setupLogging { + lastLogs = [[NSMutableArray alloc] initWithCapacity:kLastLogsCapacity]; + logsBuffer = [NSMutableArray arrayWithCapacity:kLogsBufferCapacity]; + + linphone_core_set_log_handler(linphone_log_function); + linphone_core_set_log_level(ORTP_DEBUG|ORTP_ERROR|ORTP_FATAL|ORTP_WARNING|ORTP_MESSAGE|ORTP_TRACE); + +} + + - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController]; - const char* prefix = strdup([[[NSBundle mainBundle] bundlePath] UTF8String]); + + [self setupLogging]; + + bundlePath = [[NSBundle mainBundle] bundlePath]; liblinphone_tester_init(); - liblinphone_tester_set_fileprefix(prefix); - - NSLog(@"Bundle path: %s", liblinphone_tester_file_prefix); - + liblinphone_tester_set_fileprefix([bundlePath UTF8String]); + LSLog(@"Bundle path: %@", bundlePath); int count = liblinphone_tester_nb_test_suites(); _objects = [[NSMutableArray alloc] initWithCapacity:count]; @@ -50,6 +96,11 @@ } +- (void)displayLogs { + LSLog(@"Should display logs"); + [self.navigationController performSegueWithIdentifier:@"viewLogs" sender:self]; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; @@ -126,4 +177,5 @@ } } + @end diff --git a/Resources/test_failed.png b/Resources/test_failed.png new file mode 100644 index 000000000..c174df390 Binary files /dev/null and b/Resources/test_failed.png differ diff --git a/Resources/test_inprogress.png b/Resources/test_inprogress.png new file mode 100644 index 000000000..f725a3eb9 Binary files /dev/null and b/Resources/test_inprogress.png differ diff --git a/Resources/test_passed.png b/Resources/test_passed.png new file mode 100644 index 000000000..f8edc012d Binary files /dev/null and b/Resources/test_passed.png differ diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index dbe638f49..508d09c44 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -1428,6 +1428,10 @@ F0BB8C4C193631D200974404 /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22276E8813C73DC000210156 /* CoreMedia.framework */; }; F0BB8C4D193631DF00974404 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 224567C1107B968500F10948 /* AVFoundation.framework */; }; F476004B147AAF2800FFF19B /* liblinphone.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2211DB911475562600DEE054 /* liblinphone.a */; }; + F84015BF1939FE37006ABAB5 /* test_failed.png in Resources */ = {isa = PBXBuildFile; fileRef = F84015BC1939FE37006ABAB5 /* test_failed.png */; }; + F84015C01939FE37006ABAB5 /* test_inprogress.png in Resources */ = {isa = PBXBuildFile; fileRef = F84015BD1939FE37006ABAB5 /* test_inprogress.png */; }; + F84015C11939FE37006ABAB5 /* test_passed.png in Resources */ = {isa = PBXBuildFile; fileRef = F84015BE1939FE37006ABAB5 /* test_passed.png */; }; + F84015C7193B4E34006ABAB5 /* LogsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F84015C6193B4E34006ABAB5 /* LogsViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -2372,6 +2376,11 @@ F0BB8C42193630CA00974404 /* tester_hosts */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tester_hosts; path = submodules/linphone/tester/tester_hosts; sourceTree = SOURCE_ROOT; }; F0BB8C43193630CA00974404 /* userdb.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = userdb.conf; path = submodules/linphone/tester/userdb.conf; sourceTree = SOURCE_ROOT; }; F0BB8C4A193631B300974404 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; + F84015BC1939FE37006ABAB5 /* test_failed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = test_failed.png; path = Resources/test_failed.png; sourceTree = ""; }; + F84015BD1939FE37006ABAB5 /* test_inprogress.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = test_inprogress.png; path = Resources/test_inprogress.png; sourceTree = ""; }; + F84015BE1939FE37006ABAB5 /* test_passed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = test_passed.png; path = Resources/test_passed.png; sourceTree = ""; }; + F84015C5193B4E34006ABAB5 /* LogsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogsViewController.h; sourceTree = ""; }; + F84015C6193B4E34006ABAB5 /* LogsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LogsViewController.m; sourceTree = ""; }; FD61C862169FC495001AA2D6 /* ru */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ru; path = ru.lproj/HistoryDetailsViewController.xib; sourceTree = ""; }; FD61C88216A00E69001AA2D6 /* ru */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ru; path = ru.lproj/UICallCell.xib; sourceTree = ""; }; FD979F30169E84670022A8B4 /* ru */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ru; path = Resources/ru.lproj/Localizable.strings; sourceTree = ""; }; @@ -3038,6 +3047,9 @@ F0B89C2318DC90850050B60E /* images */ = { isa = PBXGroup; children = ( + F84015BC1939FE37006ABAB5 /* test_failed.png */, + F84015BD1939FE37006ABAB5 /* test_inprogress.png */, + F84015BE1939FE37006ABAB5 /* test_passed.png */, 15AF3C4C16F37A3E00FC52EC /* route_bluetooth_off_default.png */, 1599104316F746B2007BF52B /* route_bluetooth_off_default_landscape.png */, 15AF3C4D16F37A3E00FC52EC /* route_bluetooth_off_disabled.png */, @@ -3532,14 +3544,16 @@ children = ( F0BB8BE21936208100974404 /* AppDelegate.h */, F0BB8BE31936208100974404 /* AppDelegate.m */, - F0BB8BE51936208100974404 /* Main_iPhone.storyboard */, - F0BB8BE81936208200974404 /* Main_iPad.storyboard */, - F0BB8BEB1936208200974404 /* MasterViewController.h */, - F0BB8BEC1936208200974404 /* MasterViewController.m */, F0BB8BEE1936208200974404 /* DetailViewController.h */, F0BB8BEF1936208200974404 /* DetailViewController.m */, F0BB8BF11936208200974404 /* Images.xcassets */, + F0BB8BE81936208200974404 /* Main_iPad.storyboard */, + F0BB8BE51936208100974404 /* Main_iPhone.storyboard */, + F0BB8BEB1936208200974404 /* MasterViewController.h */, + F0BB8BEC1936208200974404 /* MasterViewController.m */, F0BB8BDA1936208100974404 /* Supporting Files */, + F84015C5193B4E34006ABAB5 /* LogsViewController.h */, + F84015C6193B4E34006ABAB5 /* LogsViewController.m */, ); path = LinphoneTester; sourceTree = ""; @@ -4813,14 +4827,17 @@ buildActionMask = 2147483647; files = ( F0BB8C3819362C1500974404 /* rcfiles in Resources */, + F84015C11939FE37006ABAB5 /* test_passed.png in Resources */, F0BB8C44193630CA00974404 /* flexisip.conf in Resources */, F0BB8C46193630CA00974404 /* marie_xml in Resources */, F0BB8BEA1936208200974404 /* Main_iPad.storyboard in Resources */, F0BB8C48193630CA00974404 /* userdb.conf in Resources */, F0BB8C3E19362C2200974404 /* sounds in Resources */, + F84015BF1939FE37006ABAB5 /* test_failed.png in Resources */, F0BB8BF21936208200974404 /* Images.xcassets in Resources */, F0BB8BE71936208200974404 /* Main_iPhone.storyboard in Resources */, F0BB8C47193630CA00974404 /* tester_hosts in Resources */, + F84015C01939FE37006ABAB5 /* test_inprogress.png in Resources */, F0BB8C3C19362C2200974404 /* certificates in Resources */, F0BB8C45193630CA00974404 /* local_tester_hosts in Resources */, F0BB8C3D19362C2200974404 /* images in Resources */, @@ -5063,6 +5080,7 @@ buildActionMask = 2147483647; files = ( F0BB8BE41936208100974404 /* AppDelegate.m in Sources */, + F84015C7193B4E34006ABAB5 /* LogsViewController.m in Sources */, F0BB8BED1936208200974404 /* MasterViewController.m in Sources */, F0BB8BE01936208100974404 /* main.m in Sources */, F0BB8BF01936208200974404 /* DetailViewController.m in Sources */,