From 0c806989ecaf1ef6047f311592ea0eba810e33a1 Mon Sep 17 00:00:00 2001 From: Kowshickkarthick Subramanian Date: Tue, 17 Oct 2023 13:06:40 +0000 Subject: [PATCH] Pull request #919: 5732707 Portrait/Landscape/Square sizes should not 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 Date: Wed Oct 11 18:36:22 2023 -0400 Portrait/Landscape/Square sizes should not be applied for HTML Banner Ads --- .../internal/MRAID/ANMRAIDContainerView.m | 2 +- .../ANBannerAdViewVideoTestCase.m | 52 ++++++++++++++++--- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/sdk/sourcefiles/internal/MRAID/ANMRAIDContainerView.m b/sdk/sourcefiles/internal/MRAID/ANMRAIDContainerView.m index b32cc476..41196433 100644 --- a/sdk/sourcefiles/internal/MRAID/ANMRAIDContainerView.m +++ b/sdk/sourcefiles/internal/MRAID/ANMRAIDContainerView.m @@ -217,7 +217,7 @@ - (void)setAdViewDelegate:(id)adViewDelegate } - if ([_adViewDelegate conformsToProtocol:@protocol(ANBannerAdViewInternalDelegate)]) + if (self.isBannerVideo && [_adViewDelegate conformsToProtocol:@protocol(ANBannerAdViewInternalDelegate)]) { id bannerDelegate = (id)_adViewDelegate; diff --git a/tests/UnitTestApp/FunctionalTests/ANBannerAdViewVideoTestCase.m b/tests/UnitTestApp/FunctionalTests/ANBannerAdViewVideoTestCase.m index 3e248687..fd07dc2a 100644 --- a/tests/UnitTestApp/FunctionalTests/ANBannerAdViewVideoTestCase.m +++ b/tests/UnitTestApp/FunctionalTests/ANBannerAdViewVideoTestCase.m @@ -23,6 +23,7 @@ #import "ANRTBVideoAd.h" #import "ANCSMVideoAd.h" #import "ANMediatedAd.h" +#import "XandrAd.h" @interface ANBannerAdViewVideoTestCase : XCTestCase @property (nonatomic, readwrite, strong) ANBannerAdView *banner; @@ -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 { @@ -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]; } @@ -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]; } @@ -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]; } @@ -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"); } @@ -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); } @@ -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); } @@ -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); }