From f564901ccd9fb0953b2bec8f61eb8e76543df8b3 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Fri, 21 Nov 2014 10:43:48 +0100 Subject: [PATCH] Add media streamer unit tests for Xcode, this allows to launch it from the command line --- .../liblinphone.xcodeproj/project.pbxproj | 249 ++++++++++++++++++ .../DTObjectBlockExecutor.h | 28 ++ .../DTObjectBlockExecutor.m | 30 +++ .../mediastream-tester Tests/Info.plist | 24 ++ .../NSObject+DTRuntime.h | 56 ++++ .../NSObject+DTRuntime.m | 101 +++++++ .../mediastream_tester_Tests.m | 84 ++++++ 7 files changed, 572 insertions(+) create mode 100644 submodules/mediastream-tester Tests/DTObjectBlockExecutor.h create mode 100644 submodules/mediastream-tester Tests/DTObjectBlockExecutor.m create mode 100644 submodules/mediastream-tester Tests/Info.plist create mode 100644 submodules/mediastream-tester Tests/NSObject+DTRuntime.h create mode 100644 submodules/mediastream-tester Tests/NSObject+DTRuntime.m create mode 100644 submodules/mediastream-tester Tests/mediastream_tester_Tests.m diff --git a/submodules/liblinphone.xcodeproj/project.pbxproj b/submodules/liblinphone.xcodeproj/project.pbxproj index 2413c9aa2..03d0fca91 100644 --- a/submodules/liblinphone.xcodeproj/project.pbxproj +++ b/submodules/liblinphone.xcodeproj/project.pbxproj @@ -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 = ""; }; F01223B01A1DEFB8008D16BA /* stream_regulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stream_regulator.h; sourceTree = ""; }; F01223BC1A1E4827008D16BA /* sounds */ = {isa = PBXFileReference; lastKnownFileType = folder; path = sounds; sourceTree = ""; }; + 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 = ""; }; + F01223D81A1F29AB008D16BA /* mediastream_tester_Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = mediastream_tester_Tests.m; sourceTree = ""; }; + F01223E01A1F29D6008D16BA /* DTObjectBlockExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DTObjectBlockExecutor.h; sourceTree = ""; }; + F01223E11A1F29D6008D16BA /* DTObjectBlockExecutor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DTObjectBlockExecutor.m; sourceTree = ""; }; + F01223E21A1F29D6008D16BA /* NSObject+DTRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+DTRuntime.h"; sourceTree = ""; }; + F01223E31A1F29D6008D16BA /* NSObject+DTRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+DTRuntime.m"; sourceTree = ""; }; F02538E71979481D002C30F3 /* vp8rtpfmt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vp8rtpfmt.c; sourceTree = ""; }; F02538E81979481D002C30F3 /* vp8rtpfmt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vp8rtpfmt.h; sourceTree = ""; }; F02538EB19794847002C30F3 /* g711.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g711.c; sourceTree = ""; }; @@ -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 = ""; @@ -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 = ""; }; + 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 = ""; + }; + F01223D61A1F29AB008D16BA /* Supporting Files */ = { + isa = PBXGroup; + children = ( + F01223D71A1F29AB008D16BA /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; 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 = ( diff --git a/submodules/mediastream-tester Tests/DTObjectBlockExecutor.h b/submodules/mediastream-tester Tests/DTObjectBlockExecutor.h new file mode 100644 index 000000000..3914485d4 --- /dev/null +++ b/submodules/mediastream-tester Tests/DTObjectBlockExecutor.h @@ -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 + +@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 diff --git a/submodules/mediastream-tester Tests/DTObjectBlockExecutor.m b/submodules/mediastream-tester Tests/DTObjectBlockExecutor.m new file mode 100644 index 000000000..4e9dfd0fd --- /dev/null +++ b/submodules/mediastream-tester Tests/DTObjectBlockExecutor.m @@ -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 diff --git a/submodules/mediastream-tester Tests/Info.plist b/submodules/mediastream-tester Tests/Info.plist new file mode 100644 index 000000000..2dd317366 --- /dev/null +++ b/submodules/mediastream-tester Tests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.belledonne-communications.tester.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/submodules/mediastream-tester Tests/NSObject+DTRuntime.h b/submodules/mediastream-tester Tests/NSObject+DTRuntime.h new file mode 100644 index 000000000..3e2ad6e04 --- /dev/null +++ b/submodules/mediastream-tester Tests/NSObject+DTRuntime.h @@ -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 diff --git a/submodules/mediastream-tester Tests/NSObject+DTRuntime.m b/submodules/mediastream-tester Tests/NSObject+DTRuntime.m new file mode 100644 index 000000000..54e69ec07 --- /dev/null +++ b/submodules/mediastream-tester Tests/NSObject+DTRuntime.m @@ -0,0 +1,101 @@ +// +// NSObject_DTRuntime.h +// DTFoundation +// +// Created by Oliver Drobnik on 4/25/12. +// Copyright (c) 2012 Cocoanetics. All rights reserved. +// + +#import +#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 diff --git a/submodules/mediastream-tester Tests/mediastream_tester_Tests.m b/submodules/mediastream-tester Tests/mediastream_tester_Tests.m new file mode 100644 index 000000000..9fd8cf8d9 --- /dev/null +++ b/submodules/mediastream-tester Tests/mediastream_tester_Tests.m @@ -0,0 +1,84 @@ +// +// mediastream_tester_Tests.m +// mediastream-tester Tests +// +// Created by guillaume on 21/11/2014. +// +// + +#import +#import +#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