Skip to content

Commit

Permalink
Release 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguyhampton committed Dec 5, 2019
1 parent 5eed9d1 commit 9046dd4
Show file tree
Hide file tree
Showing 72 changed files with 589 additions and 1,064 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ verify-release-build:
echo 'UnityAds.framework.zip does not exist'; \
exit 1; \
fi;

setup:
./scripts/setup.sh

project:
./generate-project.rb
bundle exec fastlane provision_example_app
6 changes: 3 additions & 3 deletions UnityAds.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Pod::Spec.new do |s|
s.name = 'UnityAds'
s.version = '3.3.0'
s.version = '3.4.0'
s.license = { :type => 'Apache License, Version 2.0', :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.3.0/UnityAds.framework.zip' }
s.ios.deployment_target = '7.0'
s.source = { :http => 'https://github.com/Unity-Technologies/unity-ads-ios/releases/download/3.4.0/UnityAds.framework.zip' }
s.ios.deployment_target = '9.0'
s.ios.vendored_frameworks = 'UnityAds.framework'
s.ios.xcconfig = { 'OTHER_LDFLAGS' => '-framework UnityAds' }

Expand Down
28 changes: 28 additions & 0 deletions UnityAdsBannerIntegrationTests/BannerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import <UnityAds/UnityAds.h>
#import "BannerTestDelegate.h"
#import "UnityBannerTestDelegate.h"
#import "UADSBannerRefreshInfo.h"

@implementation NSURLRequest (ATS)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host {
Expand Down Expand Up @@ -74,4 +75,31 @@ - (void)testLegacyBannerLoadLifeCycleFromBackground {
[UnityAdsBanner destroy];
}

- (void)testLegacyBannerLoadwithRefresh {
UnityBannerTestDelegate *unityBannerTestDelegate = [[UnityBannerTestDelegate alloc] init];
[UnityAdsBanner setDelegate:unityBannerTestDelegate];
[[UADSBannerRefreshInfo sharedInstance] setRefreshRateForPlacementId:@"bannerads" refreshRate:[NSNumber numberWithInt:15]];

XCTestExpectation *loadExpectation = [self expectationWithDescription:@"didLoadBlockExpectation"];
unityBannerTestDelegate.didLoadBlock = ^(NSString *placementId, UIView *view) {
XCTAssertEqual(placementId, @"bannerads");
XCTAssertNotNil(view);
[loadExpectation fulfill];
};
[UnityAdsBanner loadBanner:@"bannerads"];
[self waitForExpectationsWithTimeout:100 handler:^(NSError *_Nullable error) {
}];

loadExpectation = [self expectationWithDescription:@"didLoadBlockExpectation"];
unityBannerTestDelegate.didLoadBlock = ^(NSString *placementId, UIView *view) {
XCTAssertEqual(placementId, @"bannerads");
XCTAssertNotNil(view);
[loadExpectation fulfill];
};
[self waitForExpectationsWithTimeout:100 handler:^(NSError *_Nullable error) {
}];

[UnityAdsBanner destroy];
}

@end
3 changes: 2 additions & 1 deletion UnityAdsExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ - (IBAction)initializeButtonTapped:(id)sender {

[UnityAds setDebugMode:true];

[UnityAds initialize:gameId delegate:self testMode:self.testMode];
[UnityAds addDelegate:self];
[UnityAds initialize:gameId testMode:self.testMode];
}

- (void)unityAdsReady:(NSString *)placementId {
Expand Down
5 changes: 5 additions & 0 deletions UnityAdsHybridTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
119 changes: 118 additions & 1 deletion UnityAdsTests/Ads/Properties/UADSPropertiesTests.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import <XCTest/XCTest.h>
#import "UADSProperties.h"
#import "UnityAds.h"
#import "UnityAdsDelegateMock.h"

@interface UADSPropertiesTests: XCTestCase
Expand All @@ -25,30 +26,146 @@ - (void)tearDown {
[UADSProperties setShowTimeout:UADSPROPERTIES_DEFAULT_SHOW_TIMEOUT];
}

- (void)testSetDelegate {
UnityAdsDelegateMock *delegate = [[UnityAdsDelegateMock alloc] init];

[UADSProperties setDelegate:delegate];

// test get
XCTAssertEqual(delegate, [UADSProperties getDelegate]);
// test getDelegates includes setDelegate
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate]);
XCTAssertEqual(1, [[UADSProperties getDelegates] count]);
}

- (void)testGetDelegate {
XCTAssertNil([UADSProperties getDelegate]);
}

- (void)testAddDelegate {
UnityAdsDelegateMock *delegate = [[UnityAdsDelegateMock alloc] init];

XCTAssertEqual(0, [[UADSProperties getDelegates] count]);

[UADSProperties addDelegate:delegate];

XCTAssertEqual(1, [[UADSProperties getDelegates] count]);
XCTAssertEqual(delegate, [[UADSProperties getDelegates] firstObject]);

[UADSProperties removeDelegate:delegate];

XCTAssertEqual(0, [[UADSProperties getDelegates] count]);
}

- (void)testRemoveDelegate {
UnityAdsDelegateMock *delegate = [[UnityAdsDelegateMock alloc] init];

XCTAssertEqual(0, [[UADSProperties getDelegates] count]);

[UADSProperties addDelegate:delegate];

XCTAssertEqual(1, [[UADSProperties getDelegates] count]);
XCTAssertEqual(delegate, [[UADSProperties getDelegates] firstObject]);

[UADSProperties removeDelegate:delegate];

XCTAssertEqual(0, [[UADSProperties getDelegates] count]);
}

- (void)testRemoveDuringIteration {
UnityAdsDelegateMock *delegate1 = [[UnityAdsDelegateMock alloc] init];
UnityAdsDelegateMock *delegate2 = [[UnityAdsDelegateMock alloc] init];

[UADSProperties addDelegate:delegate1];
[UADSProperties addDelegate:delegate2];

NSOrderedSet *orderedSet = [UADSProperties getDelegates];
@try {
for (id <UnityAdsDelegate>delegate in orderedSet) {
[UADSProperties removeDelegate:delegate];
}
XCTAssertTrue(true);
} @catch (NSException *exception) {
XCTFail(@"Exception was thrown");
}

}

- (void)testAddMultipleDelegates {
UnityAdsDelegateMock *delegate1 = [[UnityAdsDelegateMock alloc] init];
UnityAdsDelegateMock *delegate2 = [[UnityAdsDelegateMock alloc] init];
XCTAssertEqual(0, [[UADSProperties getDelegates] count]);

[UADSProperties addDelegate:delegate1];
[UADSProperties addDelegate:delegate2];

XCTAssertEqual(2, [[UADSProperties getDelegates] count]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate1]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate2]);

[UADSProperties removeDelegate:delegate1];
[UADSProperties removeDelegate:delegate2];

XCTAssertEqual(0, [[UADSProperties getDelegates] count]);
}

- (void)testInitializeMultipleListeners {
UnityAdsDelegateMock *delegate1 = [[UnityAdsDelegateMock alloc] init];
UnityAdsDelegateMock *delegate2 = [[UnityAdsDelegateMock alloc] init];

[UnityAds initialize:@"14850" delegate:delegate1];
[UnityAds initialize:@"14850" delegate:delegate2];

XCTAssertEqual(2, [[UADSProperties getDelegates] count]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate1]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate2]);
XCTAssertEqual(delegate1, [UADSProperties getDelegate]);
}

- (void)testWrappingFirstListener {
UnityAdsDelegateMock *delegate1 = [[UnityAdsDelegateMock alloc] init];
UnityAdsDelegateMock *delegate2 = [[UnityAdsDelegateMock alloc] init];
UnityAdsDelegateMock *delegate3 = [[UnityAdsDelegateMock alloc] init];

// Initialize with first listener
[UnityAds initialize:@"14851" delegate:delegate1];

XCTAssertEqual(1, [[UADSProperties getDelegates] count]);
XCTAssertEqual(delegate1, [UADSProperties getDelegate]);

// Replace listener from initialize
[UnityAds setDelegate:delegate2];

XCTAssertEqual(1, [[UADSProperties getDelegates] count]);
XCTAssertEqual(delegate2, [UADSProperties getDelegate]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate2]);
XCTAssertFalse([[UADSProperties getDelegates] containsObject:delegate1]);

// Add another listener that should only be added
[UnityAds addDelegate:delegate3];

XCTAssertEqual(delegate2, [UADSProperties getDelegate]);
XCTAssertEqual(2, [[UADSProperties getDelegates] count]);
XCTAssertFalse([[UADSProperties getDelegates] containsObject:delegate1]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate2]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate3]);
}

- (void)testSetOverwriteInit {
UnityAdsDelegateMock *delegate1 = [[UnityAdsDelegateMock alloc] init];
UnityAdsDelegateMock *delegate2 = [[UnityAdsDelegateMock alloc] init];
UnityAdsDelegateMock *delegate3 = [[UnityAdsDelegateMock alloc] init];

[UnityAds initialize:@"14851" delegate:delegate1];
[UnityAds setDelegate:delegate2];
[UnityAds initialize:@"14851" delegate:delegate3];

XCTAssertEqual(2, [[UADSProperties getDelegates] count]);
XCTAssertEqual(delegate2, [UADSProperties getDelegate]);
XCTAssertFalse([[UADSProperties getDelegates] containsObject:delegate1]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate2]);
XCTAssertTrue([[UADSProperties getDelegates] containsObject:delegate3]);
}

- (void)testSetShowTimeout {
XCTAssertEqual(UADSPROPERTIES_DEFAULT_SHOW_TIMEOUT, [UADSProperties getShowTimeout]);
[UADSProperties setShowTimeout:100];
Expand Down
2 changes: 1 addition & 1 deletion UnityAdsTests/Ads/UnityAdsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ -(void)testInitializeThenRemove {
UnityAdsDelegateMock *firstDelegate = [[UnityAdsDelegateMock alloc] init];
[UnityAds initialize:@"mediator1" delegate:firstDelegate];
XCTAssertEqual([UnityAds getDelegate], firstDelegate);
[UnityAds removeDelegate:firstDelegate];
[UnityAds setDelegate:nil];
XCTAssertNil([UnityAds getDelegate]);
}

Expand Down
45 changes: 45 additions & 0 deletions UnityAdsTests/Ads/WebPlayer/UADSWebPlayerViewTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#import <XCTest/XCTest.h>
#import "UADSWebPlayerView.h"

@interface ApplicationDelegate : NSObject <UIApplicationDelegate>

- (UIWindow *)window;

@end

@implementation ApplicationDelegate

- (UIWindow *)window {
return [[UIWindow alloc] init];
}

@end

@interface UADSWebPlayerViewTests: XCTestCase
@end

@implementation UADSWebPlayerViewTests

-(void)testSendFrameUpdateWithNilWindowDoesNotCrash {
@try {
UADSWebPlayerView *webPlayerView = [[UADSWebPlayerView alloc] initWithFrame:CGRectZero viewId:@"testViewId" webPlayerSettings:[[NSDictionary alloc] init]];
[webPlayerView layoutSubviews];
XCTAssertTrue(YES); // successfully did not throw
} @catch(NSException *e) {
XCTFail("Should not throw");
}
}

- (void)testSendFrameUpdateWithWindowDoesNotCrash {
@try {
UADSWebPlayerView *webPlayerView = [[UADSWebPlayerView alloc] initWithFrame:CGRectZero viewId:@"testViewId" webPlayerSettings:[[NSDictionary alloc] init]];
[UIApplication.sharedApplication.delegate.window addSubview:webPlayerView];
[webPlayerView layoutSubviews];
XCTAssertTrue(YES); // successfully did not throw
[webPlayerView removeFromSuperview];
} @catch(NSException *e) {
XCTFail(@"Should not throw");
}
}

@end
2 changes: 1 addition & 1 deletion UnityAdsTests/ClientPropertiesTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (void)testGetSupportedOrientations {
}

- (void)testGetAppName {
XCTAssertEqualObjects([USRVClientProperties getAppName], @"com.unity3d.ads.example", "App name should be eqaul to 'com.unity3d.ads.example");
XCTAssertEqualObjects([USRVClientProperties getAppName], @"com.unity3d.ads.exampleapp", "App name should be eqaul to 'com.unity3d.ads.exampleapp");
}

- (void)testGetAppVersion {
Expand Down
2 changes: 1 addition & 1 deletion UnityAdsTests/InitializeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (void)testInitializeStateLoadCache {
- (void)testInitializeStateCreate {
NSString *url = @"https://www.example.com/handlecallback.html";
NSString *data = @"<script>var nativebridge = new Object(); nativebridge.handleCallback = new function() { webviewbridge.handleInvocation(\"[['com.unity3d.ads.api.Sdk','initComplete', [], 'CALLBACK_01']]\"); }</script>";
NSString *hash = [data sha256];
NSString *hash = [data unityads_sha256];

USRVConfiguration *config = [[USRVConfiguration alloc] init];
[config setWebViewUrl:url];
Expand Down
2 changes: 1 addition & 1 deletion UnityAdsTests/NSDictionaryMergeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)testMergeDictionary {
[objectTwoSub setValue:@"secondary" forKey:@"override"];
[objectTwo setValue:objectTwoSub forKey:@"test"];

NSDictionary *merged = [NSDictionary dictionaryByMerging:objectOne secondary:objectTwo];
NSDictionary *merged = [NSDictionary unityads_dictionaryByMerging:objectOne secondary:objectTwo];

NSLog(@"%@", merged);

Expand Down
12 changes: 9 additions & 3 deletions UnityAdsTests/NSStringHashTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ @interface NSStringHashTests : XCTestCase
@implementation NSStringHashTests

- (void)testSha256 {
XCTAssertEqualObjects([@"hello" sha256], @"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824", "SHA256 not what was expected");
XCTAssertEqualObjects([@"" sha256], @"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "SHA256 not what was expected");
XCTAssertEqualObjects([@"hello" unityads_sha256], @"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824", "SHA256 not what was expected");
XCTAssertEqualObjects([@"" unityads_sha256], @"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "SHA256 not what was expected");
}

@end
- (void)testSha256ForBrokenString {
unichar c = 0xd800;
NSString *s = [[NSString alloc] initWithCharacters:&c length:1];
XCTAssertEqualObjects([s unityads_sha256], @"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "SHA256 not what was expected");
}

@end
Loading

0 comments on commit 9046dd4

Please sign in to comment.