Skip to content

Commit

Permalink
Pull request #919: 5732707 Portrait/Landscape/Square sizes should not…
Browse files Browse the repository at this point in the history
… be applied for HTML Banner Ads

Merge in MOBILE-SDK/app_mobile-sdk-ios from 5732707_VideoSize_BannerFix to develop

Squashed commit of the following:

commit 995354461498d5d01f7e8c473204f5b70f33f66a
Author: ksubramanian <[email protected]>
Date:   Wed Oct 11 18:36:22 2023 -0400

    Portrait/Landscape/Square sizes should not be applied for HTML Banner Ads
  • Loading branch information
Kowshickkarthick Subramanian committed Oct 17, 2023
1 parent 861b303 commit 0c80698
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sdk/sourcefiles/internal/MRAID/ANMRAIDContainerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ - (void)setAdViewDelegate:(id<ANAdViewInternalDelegate>)adViewDelegate
}


if ([_adViewDelegate conformsToProtocol:@protocol(ANBannerAdViewInternalDelegate)])
if (self.isBannerVideo && [_adViewDelegate conformsToProtocol:@protocol(ANBannerAdViewInternalDelegate)])
{
id<ANBannerAdViewInternalDelegate> bannerDelegate = (id<ANBannerAdViewInternalDelegate>)_adViewDelegate;

Expand Down
52 changes: 46 additions & 6 deletions tests/UnitTestApp/FunctionalTests/ANBannerAdViewVideoTestCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#import "ANRTBVideoAd.h"
#import "ANCSMVideoAd.h"
#import "ANMediatedAd.h"
#import "XandrAd.h"

@interface ANBannerAdViewVideoTestCase : XCTestCase<ANBannerAdViewDelegate>
@property (nonatomic, readwrite, strong) ANBannerAdView *banner;
Expand All @@ -34,6 +35,8 @@ @implementation ANBannerAdViewVideoTestCase
- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
// Init here if not the tests will crash
[[XandrAd sharedInstance] initWithMemberID:1 preCacheRequestObjects:true completionHandler:nil];
}

- (void)tearDown {
Expand Down Expand Up @@ -62,13 +65,16 @@ -(void) setupBannerVideoAd{
[[ANHTTPStubbingManager sharedStubbingManager] enable];
[ANHTTPStubbingManager sharedStubbingManager].ignoreUnstubbedRequests = YES;

self.banner = [[ANBannerAdView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)
self.banner = [[ANBannerAdView alloc] initWithFrame:CGRectMake(0, 0, 300, 250)
placementId:@"9887537"
adSize:CGSizeMake(320, 480)];
adSize:CGSizeMake(300, 250)];
self.banner.accessibilityLabel = @"AdView";
self.banner.autoRefreshInterval = 0;
self.banner.delegate = self;
self.banner.shouldAllowVideoDemand = YES;
self.banner.portraitBannerVideoPlayerSize = CGSizeMake(320, 400);
self.banner.landscapeBannerVideoPlayerSize = CGSizeMake(330, 250);
self.banner.squareBannerVideoPlayerSize = CGSizeMake(200, 200);
self.banner.rootViewController = [ANGlobal getKeyWindow].rootViewController;
[[ANGlobal getKeyWindow].rootViewController.view addSubview:self.banner];
}
Expand All @@ -79,13 +85,16 @@ -(void) setupBannerNativeAd{
[[ANHTTPStubbingManager sharedStubbingManager] enable];
[ANHTTPStubbingManager sharedStubbingManager].ignoreUnstubbedRequests = YES;

self.banner = [[ANBannerAdView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)
self.banner = [[ANBannerAdView alloc] initWithFrame:CGRectMake(0, 0, 300, 250)
placementId:@"9887537"
adSize:CGSizeMake(320, 480)];
adSize:CGSizeMake(300, 250)];
self.banner.accessibilityLabel = @"AdView";
self.banner.autoRefreshInterval = 0;
self.banner.delegate = self;
self.banner.shouldAllowNativeDemand = YES;
self.banner.portraitBannerVideoPlayerSize = CGSizeMake(320, 400);
self.banner.landscapeBannerVideoPlayerSize = CGSizeMake(330, 250);
self.banner.squareBannerVideoPlayerSize = CGSizeMake(200, 200);
self.banner.rootViewController = [ANGlobal getKeyWindow].rootViewController;
[[ANGlobal getKeyWindow].rootViewController.view addSubview:self.banner];
}
Expand All @@ -96,12 +105,15 @@ -(void) setupBannerAd{
[[ANHTTPStubbingManager sharedStubbingManager] enable];
[ANHTTPStubbingManager sharedStubbingManager].ignoreUnstubbedRequests = YES;

self.banner = [[ANBannerAdView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)
self.banner = [[ANBannerAdView alloc] initWithFrame:CGRectMake(0, 0, 300, 250)
placementId:@"9887537"
adSize:CGSizeMake(320, 480)];
adSize:CGSizeMake(300, 250)];
self.banner.accessibilityLabel = @"AdView";
self.banner.autoRefreshInterval = 0;
self.banner.delegate = self;
self.banner.portraitBannerVideoPlayerSize = CGSizeMake(320, 400);
self.banner.landscapeBannerVideoPlayerSize = CGSizeMake(330, 250);
self.banner.squareBannerVideoPlayerSize = CGSizeMake(200, 200);
self.banner.rootViewController = [ANGlobal getKeyWindow].rootViewController;
[[ANGlobal getKeyWindow].rootViewController.view addSubview:self.banner];
}
Expand Down Expand Up @@ -161,6 +173,14 @@ - (void)testRTBHTMLBanner {

XCTAssertNotNil(self.banner.adFetcher.adView);
XCTAssert([self.banner.adFetcher.adView isKindOfClass:[ANMRAIDContainerView class]]);

// Make sure AdView frame widh and heigh are proper. Portrait/Landscape/Square sizes should not be used for Banner
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.width,300);
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.height,250);
// Make sure LoadAdSize widh and heigh are proper. Portrait/Landscape/Square sizes should not be used for Banner
XCTAssertEqual(self.banner.loadedAdSize.width, 300);
XCTAssertEqual(self.banner.loadedAdSize.height, 250);

XCTAssertEqual(self.banner.adResponseInfo.adType, ANAdTypeBanner);
XCTAssertEqualObjects(self.banner.adResponseInfo.creativeId, @"6332753");
}
Expand Down Expand Up @@ -214,6 +234,13 @@ - (void) testBannerVideoVerticalOrientation
}];
XCTAssertEqual(self.banner.adResponseInfo.adType , ANAdTypeVideo);
XCTAssertEqual(self.banner.getVideoOrientation, ANPortrait);

// Make sure AdView frame widh and heigh are proper. portraitBannerVideoPlayerSize should be used for Vertical Videos
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.width,320);
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.height,400);
// Make sure LoadAdSize widh and heigh are proper. portraitBannerVideoPlayerSize should be used for Vertical Videos
XCTAssertEqual(self.banner.loadedAdSize.width, 320);
XCTAssertEqual(self.banner.loadedAdSize.height, 400);
}


Expand All @@ -229,6 +256,13 @@ - (void) testBannerVideoLandscapeOrientation
}];
XCTAssertEqual(self.banner.adResponseInfo.adType , ANAdTypeVideo);
XCTAssertEqual(self.banner.getVideoOrientation, ANLandscape);

// Make sure AdView frame widh and heigh are proper. landscapeBannerVideoPlayerSize should be used for Vertical Videos
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.width,330);
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.height,250);
// Make sure LoadAdSize widh and heigh are proper. landscapeBannerVideoPlayerSize should be used for Vertical Videos
XCTAssertEqual(self.banner.loadedAdSize.width, 330);
XCTAssertEqual(self.banner.loadedAdSize.height, 250);
}


Expand All @@ -244,6 +278,12 @@ - (void) testBannerVideoSquareOrientation
}];
XCTAssertEqual(self.banner.adResponseInfo.adType , ANAdTypeVideo);
XCTAssertEqual(self.banner.getVideoOrientation, ANSquare);
// Make sure AdView frame widh and heigh are proper. squareBannerVideoPlayerSize should be used for Vertical Videos
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.width,200);
XCTAssertEqual(self.banner.adFetcher.adView.frame.size.height,200);
// Make sure LoadAdSize widh and heigh are proper. squareBannerVideoPlayerSize should be used for Vertical Videos
XCTAssertEqual(self.banner.loadedAdSize.width, 200);
XCTAssertEqual(self.banner.loadedAdSize.height, 200);
}


Expand Down

0 comments on commit 0c80698

Please sign in to comment.