1// 2// main.m 3// codec_unittest 4// 5// Created by openh264 on 14-6-5. 6// Copyright (c) 2014年 com.cisco. All rights reserved. 7// 8 9 10#import <UIKit/UIKit.h> 11 12#import "AppDelegate.h" 13extern int CodecUtMain(int argc, char** argv); 14 15 16int DoTest(char *pPath, unsigned long *pLen) 17{ 18 if (!pLen) return 1; 19 unsigned long uPathLen = *pLen; 20 if(NULL == pPath || 0 == uPathLen) 21 { 22 return 1; 23 } 24 NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 25 if([paths count] == 0) 26 { 27 return 2; 28 } 29 NSString* document = [paths objectAtIndex:0]; 30 NSFileManager* manager = [NSFileManager defaultManager]; 31 [manager changeCurrentDirectoryPath:[document stringByExpandingTildeInPath]]; 32 NSString* escapedPath = [document stringByReplacingOccurrencesOfString:@" " withString:@"\\ "]; 33 unsigned long uDocumentPathLen = [escapedPath length]; 34 uPathLen= (uDocumentPathLen <= uPathLen) ? uDocumentPathLen : uPathLen; 35 memcpy(pPath,[escapedPath UTF8String],uPathLen); 36 char path[1024] = ""; 37 sprintf(path, "%s%s",pPath,"/codec_unittest.xml"); 38 int argc =2; 39 char* argv[]={(char*)"codec_unittest",path}; 40 CodecUtMain(argc,argv); 41 return 0; 42} 43 44 45 46 47int main(int argc, char * argv[]) 48{ 49 //Call the UT 50#ifdef IOS_SIMULATOR 51 const char* path="/tmp/codec_unittest.xml"; 52 argc =2; 53 argv[0]=(char*)"codec_unittest"; 54 argv[1]=path; 55 CodecUtMain(argc,argv); 56 abort(); 57#else 58 char xmlWritePath[1024] = ""; 59 unsigned long uPathLen = 1024; 60 if(DoTest(xmlWritePath,&uPathLen) == 0) 61 NSLog(@"Unit test running sucessfully on devices"); 62 else 63 NSLog(@"Unit test runing failed on devices"); 64 abort(); 65 66#endif 67 68 @autoreleasepool { 69 return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 70 } 71} 72