-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59b2bde
commit 3562107
Showing
78 changed files
with
2,260 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'UnityAds' | ||
s.version = '3.6.0' | ||
s.version = '3.6.2' | ||
s.license = { :type => 'Unity License', :file => 'LICENSE' } | ||
s.author = { 'UnityAds' => '[email protected]' } | ||
s.homepage = 'https://unity3d.com/services/ads' | ||
s.summary = 'Monetize your entire player base and reach new audiences with video ads.' | ||
s.platform = :ios | ||
s.source = { :http => 'https://github.com/Unity-Technologies/unity-ads-ios/releases/download/3.6.0/UnityAds.framework.zip' } | ||
s.source = { :http => 'https://github.com/Unity-Technologies/unity-ads-ios/releases/download/3.6.2/UnityAds.framework.zip' } | ||
s.ios.deployment_target = '9.0' | ||
s.ios.vendored_frameworks = 'UnityAds.framework' | ||
s.ios.xcconfig = { 'OTHER_LDFLAGS' => '-framework UnityAds' } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
|
||
#import <Foundation/Foundation.h> | ||
#import "USRVDeviceLog.h" | ||
#import "UADSTools.h" | ||
|
||
#endif /* PrefixHeader_pch */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#import <XCTest/XCTest.h> | ||
#import "NSDate + NSNumber.h" | ||
|
||
@interface NSDate_NSNumberTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation NSDate_NSNumberTests | ||
|
||
-(void)test_returns_timestamp_as_ns_number { | ||
XCTAssertTrue([[NSDate new].uads_timeIntervalSince1970 isKindOfClass:[NSNumber class]]); | ||
} | ||
|
||
-(void)test_returns_correct_double_value { | ||
NSDate *date = [NSDate dateWithTimeIntervalSince1970: 100.100]; | ||
NSNumber *timestamp = date.uads_timeIntervalSince1970; | ||
XCTAssertEqual(date.timeIntervalSince1970, timestamp.doubleValue); | ||
} | ||
|
||
@end |
28 changes: 28 additions & 0 deletions
28
...Categories/NSMutableDictionary + SafeOperations/NSMutableDictionary_SafeOperationsTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#import <XCTest/XCTest.h> | ||
#import "NSMutableDictionary + SafeOperations.h" | ||
|
||
@interface NSMutableDictionary_SafeOperationsTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation NSMutableDictionary_SafeOperationsTests | ||
|
||
|
||
-(void)test_dictionary_doesnt_set_nil_object_nor_set_the_key { | ||
NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; | ||
NSString *testKey = @"Test"; | ||
[dictionary uads_setValueIfNotNil: nil forKey: testKey]; | ||
XCTAssertEqual(dictionary.allKeys.count, 0); | ||
} | ||
|
||
-(void)test_dictionary_set_nonnul_object { | ||
NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; | ||
NSString *testKey = @"Test"; | ||
NSNumber *testValue = @3; | ||
[dictionary uads_setValueIfNotNil: testValue forKey: testKey]; | ||
XCTAssertEqual(dictionary.allKeys.count, 1); | ||
XCTAssertEqualObjects(dictionary[testKey], testValue); | ||
} | ||
|
||
|
||
@end |
37 changes: 37 additions & 0 deletions
37
UnityAdsTests/UADSTools/Categories/NSInvocation/Mocks/NSInvocationTargetMock.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#define NSINVOCATION_MOCK_RETURNED_VALUE @10 | ||
typedef NS_ENUM(NSInteger, NSInvocationTarget) { | ||
NSInvocationTargetArgument1, | ||
NSInvocationTargetArgument2 | ||
}; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSInvocationTargetMock : NSObject | ||
|
||
|
||
@property (nonatomic) NSNumber * getNumberArgument; | ||
@property (nonatomic) NSNumber * mockFunctionArgument; | ||
@property (nonatomic) NSInvocationTarget enumArgument; | ||
@property (nonatomic) double doubleValue; | ||
@property (class,nonatomic,readonly) NSNumber * getNumberArgument; | ||
@property (class,nonatomic,readonly) NSNumber * mockFunctionArgument; | ||
|
||
|
||
-(NSNumber *)getNumberWithArg: (NSNumber *) number; | ||
+(NSNumber *)getNumberWithArg: (NSNumber *) number; | ||
|
||
-(void)mockFunctionWithArg: (NSNumber *) number; | ||
+(void)mockFunctionWithArg: (NSNumber *) number; | ||
|
||
-(void)mockFunctionWithEnumArg: (NSInvocationTarget) type; | ||
|
||
|
||
-(void)callWithDouble: (double) value; | ||
|
||
+(void)reset; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
51 changes: 51 additions & 0 deletions
51
UnityAdsTests/UADSTools/Categories/NSInvocation/Mocks/NSInvocationTargetMock.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#import "NSInvocationTargetMock.h" | ||
|
||
@implementation NSInvocationTargetMock | ||
@synthesize doubleValue; | ||
@synthesize getNumberArgument; | ||
@synthesize mockFunctionArgument; | ||
@synthesize enumArgument; | ||
static NSNumber * getNumberArgument; | ||
static NSNumber * mockFunctionArgument; | ||
|
||
+(NSNumber *)getNumberWithArg: (NSNumber *)number { | ||
getNumberArgument = number; | ||
return NSINVOCATION_MOCK_RETURNED_VALUE; | ||
} | ||
+(NSNumber *)getNumberArgument { | ||
return getNumberArgument; | ||
} | ||
|
||
+(NSNumber *)mockFunctionArgument { | ||
return mockFunctionArgument; | ||
} | ||
|
||
+ (void)reset { | ||
getNumberArgument = 0; | ||
mockFunctionArgument = 0; | ||
} | ||
|
||
+(void)mockFunctionWithArg: (NSNumber *)number { | ||
mockFunctionArgument = number; | ||
} | ||
|
||
-(void)mockFunctionWithArg: (NSNumber *)number { | ||
self.mockFunctionArgument = number; | ||
} | ||
|
||
-(NSNumber *)getNumberWithArg: (NSNumber *)number { | ||
self.getNumberArgument = number; | ||
return NSINVOCATION_MOCK_RETURNED_VALUE; | ||
} | ||
|
||
|
||
- (void)mockFunctionWithEnumArg:(NSInvocationTarget)type { | ||
self.enumArgument = type; | ||
} | ||
|
||
- (void)callWithDouble:(double)value { | ||
self.doubleValue = value; | ||
} | ||
|
||
|
||
@end |
114 changes: 114 additions & 0 deletions
114
UnityAdsTests/UADSTools/Categories/NSInvocation/NSInvocationTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#import "NSInvocationTargetMock.h" | ||
#import "NSInvocation+Convenience.h" | ||
#import <XCTest/XCTest.h> | ||
#import "NSPrimitivesBox.h" | ||
#define TEST_PASSED_VALUE @5 | ||
@interface NSInvocationTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation NSInvocationTests | ||
|
||
- (void)setUp { | ||
[NSInvocationTargetMock reset]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)test_executes_instance_function_with_an_argument { | ||
NSInvocationTargetMock *mock = [NSInvocationTargetMock new]; | ||
[NSInvocation uads_invokeUsingMethod: @"mockFunctionWithArg:" | ||
classType: [NSInvocationTargetMock class] | ||
target: mock | ||
args: @[TEST_PASSED_VALUE]]; | ||
XCTAssertEqualObjects(mock.mockFunctionArgument, TEST_PASSED_VALUE); | ||
} | ||
|
||
- (void)test_executes_class_function_with_an_argument { | ||
[NSInvocation uads_invokeUsingMethod: @"mockFunctionWithArg:" | ||
classType: [NSInvocationTargetMock class] | ||
target: nil | ||
args: @[TEST_PASSED_VALUE]]; | ||
XCTAssertEqualObjects(NSInvocationTargetMock.mockFunctionArgument, TEST_PASSED_VALUE); | ||
} | ||
|
||
|
||
- (void)test_executes_instance_function_with_returned_value_with_an_argument { | ||
NSInvocationTargetMock *mock = [NSInvocationTargetMock new]; | ||
NSNumber *returnedValue = [NSInvocation uads_invokeWithReturnedUsingMethod: @"getNumberWithArg:" | ||
classType: [NSInvocationTargetMock class] | ||
target: mock | ||
args: @[TEST_PASSED_VALUE]]; | ||
XCTAssertEqualObjects(returnedValue, NSINVOCATION_MOCK_RETURNED_VALUE); | ||
} | ||
|
||
- (void)test_executes_class_function_with_returned_value_and_argument { | ||
NSNumber *returnedValue = [NSInvocation uads_invokeWithReturnedUsingMethod: @"getNumberWithArg:" | ||
classType: [NSInvocationTargetMock class] | ||
target: nil | ||
args: @[TEST_PASSED_VALUE]]; | ||
XCTAssertEqualObjects(returnedValue, NSINVOCATION_MOCK_RETURNED_VALUE); | ||
} | ||
|
||
- (void)test_passes_enum_to_the_invocation { | ||
NSInvocationTargetMock *mock = [NSInvocationTargetMock new]; | ||
NSInvocationTarget arg = NSInvocationTargetArgument1; | ||
NSPrimitivesBox *box = [NSPrimitivesBox newWithBytes:&arg objCType:@encode(NSInvocationTarget)]; | ||
[NSInvocation uads_invokeUsingMethod: @"mockFunctionWithArg:" | ||
classType: [NSInvocationTargetMock class] | ||
target: mock | ||
args: @[box]]; | ||
XCTAssertEqual(mock.enumArgument, arg); | ||
} | ||
|
||
|
||
- (void)test_invocation_can_call_using_double { | ||
NSInvocationTargetMock *mock = [NSInvocationTargetMock new]; | ||
double arg = 10.5; | ||
NSPrimitivesBox *box = [NSPrimitivesBox newWithBytes: &arg objCType: @encode(double)]; | ||
[NSInvocation uads_invokeUsingMethod: @"callWithDouble:" | ||
classType: [NSInvocationTargetMock class] | ||
target: mock | ||
args: @[box]]; | ||
XCTAssertEqual(mock.doubleValue, arg); | ||
} | ||
|
||
|
||
- (void)test_calls_non_existed_selector_on_instance_should_resist_to_crash { | ||
NSInvocationTargetMock *mock = [NSInvocationTargetMock new]; | ||
[NSInvocation uads_invokeUsingMethod: @"selectorThatDoesntExist:" | ||
classType: [NSInvocationTargetMock class] | ||
target: mock | ||
args: @[]]; | ||
} | ||
|
||
|
||
- (void)test_calls_non_existed_selector_on_class_should_resist_to_crash { | ||
[NSInvocation uads_invokeUsingMethod: @"selectorThatDoesntExist:" | ||
classType: [NSInvocationTargetMock class] | ||
target: nil | ||
args: @[]]; | ||
} | ||
|
||
|
||
|
||
- (void)test_calls_non_existed_selector_on_instance_should_return_nil { | ||
NSInvocationTargetMock *mock = [NSInvocationTargetMock new]; | ||
id val = [NSInvocation uads_invokeWithReturnedUsingMethod: @"selectorThatDoesntExist:" | ||
classType: [NSInvocationTargetMock class] | ||
target: mock | ||
args: @[]]; | ||
XCTAssertNil(val); | ||
} | ||
|
||
|
||
- (void)test_calls_non_existed_selector_on_class_should_return_nil { | ||
id val = [NSInvocation uads_invokeWithReturnedUsingMethod: @"selectorThatDoesntExist:" | ||
classType: [NSInvocationTargetMock class] | ||
target: nil | ||
args: @[]]; | ||
XCTAssertNil(val); | ||
} | ||
|
||
|
||
|
||
@end |
16 changes: 16 additions & 0 deletions
16
UnityAdsTests/UADSTools/UADSProxyReflection/Mocks/UADSBridgeMock.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "UADSProxyReflection.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface UADSBridgeMock: UADSProxyReflection | ||
@property (nonatomic, readonly) NSString *testValue; | ||
+ (instancetype)createDefault; | ||
- (NSString *)nonExistingKVO; | ||
+ (void)setMockSelectors: (NSArray<NSString *> *)names; | ||
+ (void)setMockKeys: (NSArray<NSString *> *)names; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
|
64 changes: 64 additions & 0 deletions
64
UnityAdsTests/UADSTools/UADSProxyReflection/Mocks/UADSBridgeMock.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#import "UADSBridgeMock.h" | ||
|
||
NSArray<NSString *> *mockedSelectors; | ||
NSArray<NSString *> *mockKeysForKVO; | ||
|
||
@interface ClosedClassMock: NSObject | ||
@end | ||
|
||
@implementation ClosedClassMock | ||
@end | ||
|
||
@interface UADSBridgeMock() | ||
@end | ||
|
||
|
||
@implementation UADSBridgeMock | ||
|
||
- (NSString *)testValue { | ||
return @"TEST_VALUE"; | ||
} | ||
|
||
+(NSString *)className { | ||
return @"UADSBridgeMock"; | ||
} | ||
|
||
+ (instancetype)createDefault { | ||
return [UADSBridgeMock getProxyWithObject: [ClosedClassMock new]]; | ||
} | ||
|
||
- (NSString *)nonExistingKVO { | ||
return [self valueForKey: @"NonExisted"]; | ||
} | ||
|
||
+ (NSArray<NSString *> *)requiredSelectors { | ||
return mockedSelectors; | ||
} | ||
|
||
+ (NSArray<NSString *> *)requiredKeysForKVO { | ||
return mockKeysForKVO; | ||
} | ||
|
||
+ (void)setMockKeys:(NSArray<NSString *> *)names { | ||
mockKeysForKVO = names; | ||
} | ||
|
||
+ (void)setMockSelectors:(NSArray<NSString *> *)names { | ||
mockedSelectors = names; | ||
} | ||
|
||
- (void)fakeSelectorToTest { | ||
// do nothing, just allow test to see this selector | ||
} | ||
|
||
|
||
|
||
@end | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
9 changes: 9 additions & 0 deletions
9
UnityAdsTests/UADSTools/UADSProxyReflection/Mocks/UADSProxyReflectionMock.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import <UIKit/UIKit.h> | ||
#import "UADSProxyReflection.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface UADSProxyReflectionMock: UADSProxyReflection | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
8 changes: 8 additions & 0 deletions
8
UnityAdsTests/UADSTools/UADSProxyReflection/Mocks/UADSProxyReflectionMock.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
#import "UADSProxyReflectionMock.h" | ||
|
||
@implementation UADSProxyReflectionMock | ||
+ (NSString *)className { | ||
return @"NSMutableArray"; | ||
} | ||
@end |
Oops, something went wrong.