Tests: restructure tests folder to get a constistent name convention

parent 5c82d04b
This diff is collapsed.
......@@ -10,6 +10,6 @@
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property(strong, nonatomic) UIWindow *window;
@end
......@@ -8,27 +8,21 @@
#import <UIKit/UIKit.h>
typedef NS_ENUM(int, TestState) {
TestStateIdle,
TestStatePassed,
TestStateInProgress,
TestStateFailed
};
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;
@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;
- (id)initWithName:(NSString *)name fromSuite:(NSString *)suite;
+ (TestItem *)testWithName:(NSString *)name fromSuite:(NSString *)suite;
@end
@interface DetailViewController : UITableViewController
@property (strong, nonatomic) NSString* detailItem;
@property(strong, nonatomic) NSString *detailItem;
@end
......@@ -8,9 +8,8 @@
#import <UIKit/UIKit.h>
@interface LogsViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextView *tview;
@property(weak, nonatomic) IBOutlet UITextView *tview;
- (IBAction)clearLogs:(id)sender;
......
......@@ -8,14 +8,13 @@
#import <UIKit/UIKit.h>
NSMutableArray* lastLogs;
NSString* const kLogsUpdateNotification;
NSMutableArray *lastLogs;
NSString *const kLogsUpdateNotification;
@class DetailViewController;
@interface MasterViewController : UITableViewController
@property (strong, nonatomic) DetailViewController *detailViewController;
@property(strong, nonatomic) DetailViewController *detailViewController;
@end
......@@ -16,11 +16,11 @@
Convenience method to create a block executor with a deallocation block
@param block The block to execute when the created receiver is being deallocated
*/
+ (id)blockExecutorWithDeallocBlock:(void(^)())block;
+ (id)blockExecutorWithDeallocBlock:(void (^)())block;
/**
Block to execute when dealloc of the receiver is called
*/
@property (nonatomic, copy) void (^deallocBlock)();
@property(nonatomic, copy) void (^deallocBlock)();
@end
......@@ -21,17 +21,18 @@
Adds a block to be executed as soon as the receiver's memory is deallocated
@param block The block to execute when the receiver is being deallocated
*/
- (void)addDeallocBlock:(void(^)())block;
- (void)addDeallocBlock:(void (^)())block;
/**
Adds a new instance method to a class. All instances of this class will have this method.
The block captures `self` in the calling context. To allow access to the instance from within the block it is passed as parameter to the block.
The block captures `self` in the calling context. To allow access to the instance from within the block it is passed as
parameter to the block.
@param selectorName The name of the method.
@param block The block to execute for the instance method, a pointer to the instance is passed as the only parameter.
@returns `YES` if the operation was successful
*/
+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void(^)(id))block;
+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void (^)(id))block;
/**-------------------------------------------------------------------------------------
@name Method Swizzling
......@@ -39,15 +40,16 @@
*/
/**
Exchanges two method implementations. After the call methods to the first selector will now go to the second one and vice versa.
Exchanges two method implementations. After the call methods to the first selector will now go to the second one and
vice versa.
@param selector The first method
@param otherSelector The second method
*/
+ (void)swizzleMethod:(SEL)selector withMethod:(SEL)otherSelector;
/**
Exchanges two class method implementations. After the call methods to the first selector will now go to the second one and vice versa.
Exchanges two class method implementations. After the call methods to the first selector will now go to the second one
and vice versa.
@param selector The first method
@param otherSelector The second method
*/
......
......@@ -83,7 +83,7 @@ static char DTRuntimeDeallocBlocks;
// if (class_addMethod(c, selector, method_getImplementation(otherMethod), method_getTypeEncoding(otherMethod)))
// {
// class_replaceMethod(c, otherSelector, method_getImplementation(originalMethod),
//method_getTypeEncoding(originalMethod));
// method_getTypeEncoding(originalMethod));
// }
// else
// {
......
......@@ -14,10 +14,10 @@
- (void)switchToValidAccountIfNeeded;
- (NSString *)me;
- (NSString*)accountDomain;
- (NSString *)accountDomain;
- (NSString*)getUUID;
- (NSArray*)getUUIDArrayOfSize:(size_t)size;
- (NSString *)getUUID;
- (NSArray *)getUUIDArrayOfSize:(size_t)size;
- (UITableView *)findTableView:(NSString *)table;
......
This diff is collapsed.
......@@ -15,8 +15,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0BB8BD41936208100974404"
BuildableName = "LinphoneTester.app"
BlueprintName = "LinphoneTester"
BuildableName = "liblinphoneTester.app"
BlueprintName = "liblinphoneTester"
ReferencedContainer = "container:linphone.xcodeproj">
</BuildableReference>
</BuildActionEntry>
......@@ -33,8 +33,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F08F118319C09C6A007D70C2"
BuildableName = "LinphoneTester Tests.xctest"
BlueprintName = "LinphoneTester Tests"
BuildableName = "liblinphoneTester Tests.xctest"
BlueprintName = "liblinphoneTester Tests"
ReferencedContainer = "container:linphone.xcodeproj">
</BuildableReference>
</TestableReference>
......@@ -43,8 +43,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0BB8BD41936208100974404"
BuildableName = "LinphoneTester.app"
BlueprintName = "LinphoneTester"
BuildableName = "liblinphoneTester.app"
BlueprintName = "liblinphoneTester"
ReferencedContainer = "container:linphone.xcodeproj">
</BuildableReference>
</MacroExpansion>
......@@ -63,8 +63,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0BB8BD41936208100974404"
BuildableName = "LinphoneTester.app"
BlueprintName = "LinphoneTester"
BuildableName = "liblinphoneTester.app"
BlueprintName = "liblinphoneTester"
ReferencedContainer = "container:linphone.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
......@@ -82,8 +82,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0BB8BD41936208100974404"
BuildableName = "LinphoneTester.app"
BlueprintName = "LinphoneTester"
BuildableName = "liblinphoneTester.app"
BlueprintName = "liblinphoneTester"
ReferencedContainer = "container:linphone.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
......
......@@ -29,8 +29,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0F951FF1A6AEB1000254160"
BuildableName = "KifTests.xctest"
BlueprintName = "KifTests"
BuildableName = "linphone Tests.xctest"
BlueprintName = "linphone Tests"
ReferencedContainer = "container:linphone.xcodeproj">
</BuildableReference>
</BuildActionEntry>
......@@ -47,8 +47,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0F951FF1A6AEB1000254160"
BuildableName = "KifTests.xctest"
BlueprintName = "KifTests"
BuildableName = "linphone Tests.xctest"
BlueprintName = "linphone Tests"
ReferencedContainer = "container:linphone.xcodeproj">
</BuildableReference>
</TestableReference>
......
//
// mediastream_tester_Tests.m
// mediastream-tester Tests
//
// Created by guillaume on 21/11/2014.
//
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#include "ortp.h"
#import "NSObject+DTRuntime.h"
#include "mediastreamer2_tester.h"
@interface mediastream_tester_Tests : XCTestCase
@property (nonatomic,retain) NSString* bundlePath;
@property (nonatomic,retain) NSString* documentPath;
@property (nonatomic,retain) NSString* staticImagePath;
@end
@implementation mediastream_tester_Tests
+ (NSArray*)skippedSuites {
NSArray* skipped_suites = @[];
return skipped_suites;
}
+ (NSString*)safeifyTestString:(NSString*)testString{
NSArray* invalidChars= @[@"[", @"]", @" ", @"-", @"."];
NSString* safeString = testString;
for (NSString* c in invalidChars) {
safeString = [safeString stringByReplacingOccurrencesOfString:c withString:@"_"];
}
return safeString;
}
static void log_handler(int lev, const char *fmt, va_list args) {
va_list cap;
va_copy(cap,args);
/* Otherwise, we must use stdio to avoid log formatting (for autocompletion etc.) */
vfprintf(lev == ORTP_ERROR ? stderr : stdout, fmt, cap);
fprintf(lev == ORTP_ERROR ? stderr : stdout, "\n");
va_end(cap);
}
+ (void)initialize {
bc_tester_init(log_handler, ORTP_MESSAGE, ORTP_ERROR);
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
int count = bc_tester_nb_suites();
for (int i=0; i<count; i++) {
const char* suite = bc_tester_suite_name(i);
int test_count = bc_tester_nb_tests(suite);
for( int k = 0; k<test_count; k++){
const char* test = bc_tester_test_name(suite, k);
NSString* sSuite = [NSString stringWithUTF8String:suite];
NSString* sTest = [NSString stringWithUTF8String:test];
if( [[mediastream_tester_Tests skippedSuites] containsObject:sSuite] ) continue;
// prepend test_ so that it gets found by introspection
NSString* safesTest = [self safeifyTestString:sTest];
NSString* safesSuite = [self safeifyTestString:sSuite];
NSString *selectorName = [NSString stringWithFormat:@"test_%@__%@", safesSuite, safesTest];
NSLog(@"Adding test: %@", selectorName);
[mediastream_tester_Tests addInstanceMethodWithSelectorName:selectorName block:^(mediastream_tester_Tests* myself) {
[myself testForSuite:sSuite andTest:sTest];
}];
}
}
}
- (void)setUp {
[super setUp];
self.bundlePath = [[NSBundle mainBundle] bundlePath];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
self.documentPath = [paths objectAtIndex:0];
self.staticImagePath = [[self.bundlePath stringByAppendingString:@"/"] stringByAppendingString:@"nowebcamCIF.jpg"];
NSLog(@"Bundle path: %@", self.bundlePath);
NSLog(@"Document path: %@", self.documentPath);
bc_tester_writable_dir_prefix = [self.documentPath UTF8String];
bc_tester_read_dir_prefix = [self.bundlePath UTF8String];
ms_static_image_set_default_image( [self.staticImagePath UTF8String]);
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testForSuite:(NSString*)suite andTest:(NSString*)test
{
NSLog(@"Launching test %@ from suite %@", test, suite);
XCTAssertFalse(bc_tester_run_tests([suite UTF8String], [test UTF8String]), @"Suite '%@' / Test '%@' failed", suite, test);
}
@end
......@@ -18,11 +18,11 @@
Convenience method to create a block executor with a deallocation block
@param block The block to execute when the created receiver is being deallocated
*/
+ (id)blockExecutorWithDeallocBlock:(void(^)())block;
+ (id)blockExecutorWithDeallocBlock:(void (^)())block;
/**
Block to execute when dealloc of the receiver is called
*/
@property (nonatomic, copy) void (^deallocBlock)();
@property(nonatomic, copy) void (^deallocBlock)();
@end
......@@ -8,23 +8,19 @@
#import "DTObjectBlockExecutor.h"
@implementation DTObjectBlockExecutor
+ (id)blockExecutorWithDeallocBlock:(void(^)())block
{
DTObjectBlockExecutor *executor = [[DTObjectBlockExecutor alloc] init];
executor.deallocBlock = block; // copy
return executor;
+ (id)blockExecutorWithDeallocBlock:(void (^)())block {
DTObjectBlockExecutor *executor = [[DTObjectBlockExecutor alloc] init];
executor.deallocBlock = block; // copy
return executor;
}
- (void)dealloc
{
if (_deallocBlock)
{
_deallocBlock();
_deallocBlock = nil;
}
- (void)dealloc {
if (_deallocBlock) {
_deallocBlock();
_deallocBlock = nil;
}
}
@end
......@@ -21,17 +21,18 @@
Adds a block to be executed as soon as the receiver's memory is deallocated
@param block The block to execute when the receiver is being deallocated
*/
- (void)addDeallocBlock:(void(^)())block;
- (void)addDeallocBlock:(void (^)())block;
/**
Adds a new instance method to a class. All instances of this class will have this method.
The block captures `self` in the calling context. To allow access to the instance from within the block it is passed as parameter to the block.
The block captures `self` in the calling context. To allow access to the instance from within the block it is passed as
parameter to the block.
@param selectorName The name of the method.
@param block The block to execute for the instance method, a pointer to the instance is passed as the only parameter.
@returns `YES` if the operation was successful
*/
+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void(^)(id))block;
+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void (^)(id))block;
/**-------------------------------------------------------------------------------------
@name Method Swizzling
......@@ -39,15 +40,16 @@
*/
/**
Exchanges two method implementations. After the call methods to the first selector will now go to the second one and vice versa.
Exchanges two method implementations. After the call methods to the first selector will now go to the second one and
vice versa.
@param selector The first method
@param otherSelector The second method
*/
+ (void)swizzleMethod:(SEL)selector withMethod:(SEL)otherSelector;
/**
Exchanges two class method implementations. After the call methods to the first selector will now go to the second one and vice versa.
Exchanges two class method implementations. After the call methods to the first selector will now go to the second one
and vice versa.
@param selector The first method
@param otherSelector The second method
*/
......
......@@ -15,87 +15,80 @@ static char DTRuntimeDeallocBlocks;
#pragma mark - Blocks
- (void)addDeallocBlock:(void(^)())block
{
// don't accept NULL block
NSParameterAssert(block);
NSMutableArray *deallocBlocks = objc_getAssociatedObject(self, &DTRuntimeDeallocBlocks);
// add array of dealloc blocks if not existing yet
if (!deallocBlocks)
{
deallocBlocks = [[NSMutableArray alloc] init];
objc_setAssociatedObject(self, &DTRuntimeDeallocBlocks, deallocBlocks, OBJC_ASSOCIATION_RETAIN);
}
DTObjectBlockExecutor *executor = [DTObjectBlockExecutor blockExecutorWithDeallocBlock:block];
[deallocBlocks addObject:executor];
- (void)addDeallocBlock:(void (^)())block {
// don't accept NULL block
NSParameterAssert(block);
NSMutableArray *deallocBlocks = objc_getAssociatedObject(self, &DTRuntimeDeallocBlocks);
// add array of dealloc blocks if not existing yet
if (!deallocBlocks) {
deallocBlocks = [[NSMutableArray alloc] init];
objc_setAssociatedObject(self, &DTRuntimeDeallocBlocks, deallocBlocks, OBJC_ASSOCIATION_RETAIN);
}
DTObjectBlockExecutor *executor = [DTObjectBlockExecutor blockExecutorWithDeallocBlock:block];
[deallocBlocks addObject:executor];
}
+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void(^)(id))block
{
// don't accept nil name
NSParameterAssert(selectorName);
// don't accept NULL block
NSParameterAssert(block);
// See http://stackoverflow.com/questions/6357663/casting-a-block-to-a-void-for-dynamic-class-method-resolution
+ (BOOL)addInstanceMethodWithSelectorName:(NSString *)selectorName block:(void (^)(id))block {
// don't accept nil name
NSParameterAssert(selectorName);
// don't accept NULL block
NSParameterAssert(block);
// See http://stackoverflow.com/questions/6357663/casting-a-block-to-a-void-for-dynamic-class-method-resolution
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_7
void *impBlockForIMP = (void *)objc_unretainedPointer(block);
void *impBlockForIMP = (void *)objc_unretainedPointer(block);
#else
id impBlockForIMP = (__bridge id)objc_unretainedPointer(block);
id impBlockForIMP = (__bridge id)objc_unretainedPointer(block);
#endif
IMP myIMP = imp_implementationWithBlock(impBlockForIMP);
SEL selector = NSSelectorFromString(selectorName);
return class_addMethod(self, selector, myIMP, "v@:");
IMP myIMP = imp_implementationWithBlock(impBlockForIMP);
SEL selector = NSSelectorFromString(selectorName);
return class_addMethod(self, selector, myIMP, "v@:");
}
#pragma mark - Method Swizzling
+ (void)swizzleMethod:(SEL)selector withMethod:(SEL)otherSelector
{
+ (void)swizzleMethod:(SEL)selector withMethod:(SEL)otherSelector {
// my own class is being targetted
Class c = [self class];
// get the methods from the selectors
Method originalMethod = class_getInstanceMethod(c, selector);
Method otherMethod = class_getInstanceMethod(c, otherSelector);
if (class_addMethod(c, selector, method_getImplementation(otherMethod), method_getTypeEncoding(otherMethod)))
{
class_replaceMethod(c, otherSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
}
else
{
Method otherMethod = class_getInstanceMethod(c, otherSelector);
if (class_addMethod(c, selector, method_getImplementation(otherMethod), method_getTypeEncoding(otherMethod))) {
class_replaceMethod(c, otherSelector, method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, otherMethod);
}
}
+ (void)swizzleClassMethod:(SEL)selector withMethod:(SEL)otherSelector
{
+ (void)swizzleClassMethod:(SEL)selector withMethod:(SEL)otherSelector {
// my own class is being targetted
Class c = [self class];
// get the methods from the selectors
Method originalMethod = class_getClassMethod(c, selector);
Method otherMethod = class_getClassMethod(c, otherSelector);
// if (class_addMethod(c, selector, method_getImplementation(otherMethod), method_getTypeEncoding(otherMethod)))
// {
// class_replaceMethod(c, otherSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
// }
// else
// {
method_exchangeImplementations(originalMethod, otherMethod);
// }
Method otherMethod = class_getClassMethod(c, otherSelector);
// if (class_addMethod(c, selector, method_getImplementation(otherMethod), method_getTypeEncoding(otherMethod)))
// {
// class_replaceMethod(c, otherSelector, method_getImplementation(originalMethod),
// method_getTypeEncoding(originalMethod));
// }
// else
// {
method_exchangeImplementations(originalMethod, otherMethod);
// }
}
@end
//
// mediastream_tester_Tests.m
// mediastream-tester Tests
//
// Created by guillaume on 21/11/2014.
//
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#include "ortp.h"
#import "NSObject+DTRuntime.h"
#include "mediastreamer2_tester.h"
@interface mediastream_tester_Tests : XCTestCase
@property(nonatomic, retain) NSString *bundlePath;
@property(nonatomic, retain) NSString *documentPath;
@property(nonatomic, retain) NSString *staticImagePath;
@end
@implementation mediastream_tester_Tests
+ (NSArray *)skippedSuites {
NSArray *skipped_suites = @[];
return skipped_suites;
}
+ (NSString *)safeifyTestString:(NSString *)testString {
NSArray *invalidChars = @[ @"[", @"]", @" ", @"-", @"." ];
NSString *safeString = testString;
for (NSString *c in invalidChars) {
safeString = [safeString stringByReplacingOccurrencesOfString:c withString:@"_"];
}
return safeString;
}
static void log_handler(int lev, const char *fmt, va_list args) {
va_list cap;
va_copy(cap, args);
/* Otherwise, we must use stdio to avoid log formatting (for autocompletion etc.) */
vfprintf(lev == ORTP_ERROR ? stderr : stdout, fmt, cap);
fprintf(lev == ORTP_ERROR ? stderr : stdout, "\n");
va_end(cap);
}
+ (void)initialize {
bc_tester_init(log_handler, ORTP_MESSAGE, ORTP_ERROR);
ortp_set_log_level_mask(ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL);