Add media streamer unit tests for Xcode, this allows to launch it from the command line

This commit is contained in:
Guillaume BIENKOWSKI 2014-11-21 10:43:48 +01:00
parent fb9bda891f
commit f564901ccd
7 changed files with 572 additions and 0 deletions

View file

@ -333,6 +333,10 @@
70E542F113E147CE002BA2C0 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 70E542F013E147CE002BA2C0 /* QuartzCore.framework */; };
F01223B51A1DEFCE008D16BA /* stream_regulator.c in Sources */ = {isa = PBXBuildFile; fileRef = F01223AF1A1DEFB8008D16BA /* stream_regulator.c */; };
F01223BD1A1E4827008D16BA /* sounds in Resources */ = {isa = PBXBuildFile; fileRef = F01223BC1A1E4827008D16BA /* sounds */; };
F01223D91A1F29AB008D16BA /* mediastream_tester_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = F01223D81A1F29AB008D16BA /* mediastream_tester_Tests.m */; };
F01223E41A1F29D6008D16BA /* DTObjectBlockExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = F01223E11A1F29D6008D16BA /* DTObjectBlockExecutor.m */; };
F01223E51A1F29D6008D16BA /* NSObject+DTRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = F01223E31A1F29D6008D16BA /* NSObject+DTRuntime.m */; };
F01223EC1A1F3476008D16BA /* nowebcamCIF.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2206D2E0177ACF5700C40726 /* nowebcamCIF.jpg */; };
F02538E91979481D002C30F3 /* vp8rtpfmt.c in Sources */ = {isa = PBXBuildFile; fileRef = F02538E71979481D002C30F3 /* vp8rtpfmt.c */; };
F02538EA1979481D002C30F3 /* vp8rtpfmt.h in Headers */ = {isa = PBXBuildFile; fileRef = F02538E81979481D002C30F3 /* vp8rtpfmt.h */; };
F02538ED19794847002C30F3 /* g711.c in Sources */ = {isa = PBXBuildFile; fileRef = F02538EB19794847002C30F3 /* g711.c */; };
@ -486,6 +490,13 @@
remoteGlobalIDString = 225D64FA1521C009008B2E81;
remoteInfo = libortp;
};
F01223DA1A1F29AB008D16BA /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = F0ED99531A16464D00A788CE;
remoteInfo = "mediastream-tester";
};
F0ED99551A16464D00A788CE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
@ -736,6 +747,13 @@
F01223AF1A1DEFB8008D16BA /* stream_regulator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stream_regulator.c; sourceTree = "<group>"; };
F01223B01A1DEFB8008D16BA /* stream_regulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stream_regulator.h; sourceTree = "<group>"; };
F01223BC1A1E4827008D16BA /* sounds */ = {isa = PBXFileReference; lastKnownFileType = folder; path = sounds; sourceTree = "<group>"; };
F01223D41A1F29AB008D16BA /* mediastream-tester Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "mediastream-tester Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
F01223D71A1F29AB008D16BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F01223D81A1F29AB008D16BA /* mediastream_tester_Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = mediastream_tester_Tests.m; sourceTree = "<group>"; };
F01223E01A1F29D6008D16BA /* DTObjectBlockExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DTObjectBlockExecutor.h; sourceTree = "<group>"; };
F01223E11A1F29D6008D16BA /* DTObjectBlockExecutor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DTObjectBlockExecutor.m; sourceTree = "<group>"; };
F01223E21A1F29D6008D16BA /* NSObject+DTRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+DTRuntime.h"; sourceTree = "<group>"; };
F01223E31A1F29D6008D16BA /* NSObject+DTRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+DTRuntime.m"; sourceTree = "<group>"; };
F02538E71979481D002C30F3 /* vp8rtpfmt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vp8rtpfmt.c; sourceTree = "<group>"; };
F02538E81979481D002C30F3 /* vp8rtpfmt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vp8rtpfmt.h; sourceTree = "<group>"; };
F02538EB19794847002C30F3 /* g711.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g711.c; sourceTree = "<group>"; };
@ -847,6 +865,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F01223D11A1F29AB008D16BA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F0ED99671A16464D00A788CE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@ -891,6 +916,7 @@
225D65C51521C009008B2E81 /* libortp.a */,
22C8D0E91769F8FF00DAFB4E /* libmediastreamer_voip.a */,
F0ED999F1A16464D00A788CE /* mediastream-tester.app */,
F01223D41A1F29AB008D16BA /* mediastream-tester Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
@ -899,6 +925,7 @@
isa = PBXGroup;
children = (
F0ED99521A1645CD00A788CE /* Frameworks */,
F01223D51A1F29AB008D16BA /* mediastream-tester Tests */,
222CA4CF11F6CF2000621220 /* mediastreamer2 */,
222CA4CE11F6CF1900621220 /* oRTP */,
32C88DFF0371C24200C91783 /* Other Sources */,
@ -1262,6 +1289,27 @@
name = "Other Sources";
sourceTree = "<group>";
};
F01223D51A1F29AB008D16BA /* mediastream-tester Tests */ = {
isa = PBXGroup;
children = (
F01223D81A1F29AB008D16BA /* mediastream_tester_Tests.m */,
F01223E01A1F29D6008D16BA /* DTObjectBlockExecutor.h */,
F01223E11A1F29D6008D16BA /* DTObjectBlockExecutor.m */,
F01223E21A1F29D6008D16BA /* NSObject+DTRuntime.h */,
F01223E31A1F29D6008D16BA /* NSObject+DTRuntime.m */,
F01223D61A1F29AB008D16BA /* Supporting Files */,
);
path = "mediastream-tester Tests";
sourceTree = "<group>";
};
F01223D61A1F29AB008D16BA /* Supporting Files */ = {
isa = PBXGroup;
children = (
F01223D71A1F29AB008D16BA /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
F0ED99161A1645C200A788CE /* tester */ = {
isa = PBXGroup;
children = (
@ -1637,6 +1685,24 @@
productReference = 22DD19BE13A8D7FA0018ECD4 /* mediastream.app */;
productType = "com.apple.product-type.application";
};
F01223D31A1F29AB008D16BA /* mediastream-tester Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = F01223DF1A1F29AB008D16BA /* Build configuration list for PBXNativeTarget "mediastream-tester Tests" */;
buildPhases = (
F01223D01A1F29AB008D16BA /* Sources */,
F01223D11A1F29AB008D16BA /* Frameworks */,
F01223D21A1F29AB008D16BA /* Resources */,
);
buildRules = (
);
dependencies = (
F01223DB1A1F29AB008D16BA /* PBXTargetDependency */,
);
name = "mediastream-tester Tests";
productName = "mediastream-tester Tests";
productReference = F01223D41A1F29AB008D16BA /* mediastream-tester Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
F0ED99531A16464D00A788CE /* mediastream-tester */ = {
isa = PBXNativeTarget;
buildConfigurationList = F0ED999B1A16464D00A788CE /* Build configuration list for PBXNativeTarget "mediastream-tester" */;
@ -1664,6 +1730,10 @@
attributes = {
LastUpgradeCheck = 0610;
TargetAttributes = {
F01223D31A1F29AB008D16BA = {
CreatedOnToolsVersion = 6.1;
TestTargetID = F0ED99531A16464D00A788CE;
};
F0ED99531A16464D00A788CE = {
DevelopmentTeam = Z2V957B3D6;
};
@ -1690,6 +1760,7 @@
225D64FA1521C009008B2E81 /* libortp */,
22C8D0401769F8FF00DAFB4E /* libmediastreamer_voip */,
F0ED99531A16464D00A788CE /* mediastream-tester */,
F01223D31A1F29AB008D16BA /* mediastream-tester Tests */,
);
};
/* End PBXProject section */
@ -1724,6 +1795,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F01223D21A1F29AB008D16BA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F01223EC1A1F3476008D16BA /* nowebcamCIF.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F0ED99831A16464D00A788CE /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@ -1899,6 +1978,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
F01223D01A1F29AB008D16BA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F01223D91A1F29AB008D16BA /* mediastream_tester_Tests.m in Sources */,
F01223E41A1F29D6008D16BA /* DTObjectBlockExecutor.m in Sources */,
F01223E51A1F29D6008D16BA /* NSObject+DTRuntime.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F0ED99581A16464D00A788CE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@ -1944,6 +2033,11 @@
target = 225D64FA1521C009008B2E81 /* libortp */;
targetProxy = 22C8D0421769F8FF00DAFB4E /* PBXContainerItemProxy */;
};
F01223DB1A1F29AB008D16BA /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F0ED99531A16464D00A788CE /* mediastream-tester */;
targetProxy = F01223DA1A1F29AB008D16BA /* PBXContainerItemProxy */;
};
F0ED99541A16464D00A788CE /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 22C8D0401769F8FF00DAFB4E /* libmediastreamer_voip */;
@ -2784,6 +2878,152 @@
};
name = Release;
};
F01223DC1A1F29AB008D16BA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
HEADER_SEARCH_PATHS = (
linphone/mediastreamer2/build/iphone,
linphone/mediastreamer2/include,
linphone/oRTP/include,
"$(SRCROOT)/../liblinphone-sdk/apple-darwin/include",
);
INFOPLIST_FILE = "mediastream-tester Tests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mediastream-tester.app/mediastream-tester";
};
name = Debug;
};
F01223DD1A1F29AB008D16BA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
HEADER_SEARCH_PATHS = (
linphone/mediastreamer2/build/iphone,
linphone/mediastreamer2/include,
linphone/oRTP/include,
"$(SRCROOT)/../liblinphone-sdk/apple-darwin/include",
);
INFOPLIST_FILE = "mediastream-tester Tests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mediastream-tester.app/mediastream-tester";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
F01223DE1A1F29AB008D16BA /* DistributionAdhoc */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
HEADER_SEARCH_PATHS = (
linphone/mediastreamer2/build/iphone,
linphone/mediastreamer2/include,
linphone/oRTP/include,
"$(SRCROOT)/../liblinphone-sdk/apple-darwin/include",
);
INFOPLIST_FILE = "mediastream-tester Tests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/mediastream-tester.app/mediastream-tester";
VALIDATE_PRODUCT = YES;
};
name = DistributionAdhoc;
};
F0ED999C1A16464D00A788CE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@ -3029,6 +3269,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F01223DF1A1F29AB008D16BA /* Build configuration list for PBXNativeTarget "mediastream-tester Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F01223DC1A1F29AB008D16BA /* Debug */,
F01223DD1A1F29AB008D16BA /* Release */,
F01223DE1A1F29AB008D16BA /* DistributionAdhoc */,
);
defaultConfigurationIsVisible = 0;
};
F0ED999B1A16464D00A788CE /* Build configuration list for PBXNativeTarget "mediastream-tester" */ = {
isa = XCConfigurationList;
buildConfigurations = (

View file

@ -0,0 +1,28 @@
//
// DTObjectBlockExecutor.h
// DTFoundation
//
// Created by Oliver Drobnik on 12.02.13.
// Copyright (c) 2013 Cocoanetics. All rights reserved.
//
/**
This class is used by [NSObject addDeallocBlock:] to execute blocks on dealloc
*/
#import <Foundation/Foundation.h>
@interface DTObjectBlockExecutor : NSObject
/**
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;
/**
Block to execute when dealloc of the receiver is called
*/
@property (nonatomic, copy) void (^deallocBlock)();
@end

View file

@ -0,0 +1,30 @@
//
// DTObjectBlockExecutor.m
// DTFoundation
//
// Created by Oliver Drobnik on 12.02.13.
// Copyright (c) 2013 Cocoanetics. All rights reserved.
//
#import "DTObjectBlockExecutor.h"
@implementation DTObjectBlockExecutor
+ (id)blockExecutorWithDeallocBlock:(void(^)())block
{
DTObjectBlockExecutor *executor = [[DTObjectBlockExecutor alloc] init];
executor.deallocBlock = block; // copy
return executor;
}
- (void)dealloc
{
if (_deallocBlock)
{
_deallocBlock();
_deallocBlock = nil;
}
}
@end

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.belledonne-communications.tester.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View file

@ -0,0 +1,56 @@
//
// NSObject+DTRuntime.h
// DTFoundation
//
// Created by Oliver Drobnik on 4/25/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
/**
Methods to dynamically modify objects at runtime
*/
@interface NSObject (DTRuntime)
/**-------------------------------------------------------------------------------------
@name Blocks
---------------------------------------------------------------------------------------
*/
/**
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;
/**
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.
@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;
/**-------------------------------------------------------------------------------------
@name Method Swizzling
---------------------------------------------------------------------------------------
*/
/**
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.
@param selector The first method
@param otherSelector The second method
*/
+ (void)swizzleClassMethod:(SEL)selector withMethod:(SEL)otherSelector;
@end

View file

@ -0,0 +1,101 @@
//
// NSObject_DTRuntime.h
// DTFoundation
//
// Created by Oliver Drobnik on 4/25/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
#import <objc/runtime.h>
#import "DTObjectBlockExecutor.h"
@implementation NSObject (DTRuntime)
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];
}
+ (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);
#else
id impBlockForIMP = (__bridge id)objc_unretainedPointer(block);
#endif
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
{
// 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_exchangeImplementations(originalMethod, otherMethod);
}
}
+ (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);
// }
}
@end

View file

@ -0,0 +1,84 @@
//
// mediastream_tester_Tests.m
// mediastream-tester Tests
//
// Created by guillaume on 21/11/2014.
//
//
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.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;
}
+ (void)initialize {
mediastreamer2_tester_init();
int count = mediastreamer2_tester_nb_test_suites();
for (int i=0; i<count; i++) {
const char* suite = mediastreamer2_tester_test_suite_name(i);
int test_count = mediastreamer2_tester_nb_tests(suite);
for( int k = 0; k<test_count; k++){
const char* test =mediastreamer2_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 = [sTest stringByReplacingOccurrencesOfString:@" " withString:@"_"];
NSString* safesSuite = [sSuite stringByReplacingOccurrencesOfString:@" " withString:@"_"];
NSString *selectorName = [NSString stringWithFormat:@"test_%@__%@", safesSuite, safesTest];
[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);
mediastreamer2_tester_set_file_root( [self.bundlePath UTF8String] );
mediastreamer2_tester_set_writable_dir( [self.documentPath 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(mediastreamer2_tester_run_tests([suite UTF8String], [test UTF8String]), @"Suite '%@' / Test '%@' failed", suite, test);
}
@end