Skip to content

Commit

Permalink
feat: add adPosition to InterstitialRenderingAdUnit and RewardedAdUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
OlenaPostindustria committed Dec 5, 2024
1 parent 5597f24 commit 70250a2
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 21 deletions.
10 changes: 9 additions & 1 deletion PrebidMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@
534C61462CB562E40026119A /* CloseActionManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 534C61452CB562E40026119A /* CloseActionManagerTests.swift */; };
535145E02CCB758800D40B19 /* NSObject+PBMExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 535145DF2CCB758800D40B19 /* NSObject+PBMExtensions.m */; };
535145E12CCB758800D40B19 /* NSObject+PBMExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 535145DE2CCB758800D40B19 /* NSObject+PBMExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
53514CC62D01B5B900A480C0 /* InterstitialRenderingAdUnitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514CC52D01B5AF00A480C0 /* InterstitialRenderingAdUnitTest.swift */; };
53514CC82D01B5F900A480C0 /* RewardedAdUnitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514CC72D01B5F200A480C0 /* RewardedAdUnitTest.swift */; };
5355ACA929C454070014F16E /* VAST_with_empty_companion.xml in Resources */ = {isa = PBXBuildFile; fileRef = 5355ACA829C454070014F16E /* VAST_with_empty_companion.xml */; };
5355ACAB29C454770014F16E /* CreativeModelCollectionMakerVASTTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5355ACAA29C454770014F16E /* CreativeModelCollectionMakerVASTTests.swift */; };
536A39262A84C50F00B1CCEA /* StringExtensionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536A39252A84C50F00B1CCEA /* StringExtensionsTest.swift */; };
Expand Down Expand Up @@ -985,6 +987,8 @@
534C61452CB562E40026119A /* CloseActionManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloseActionManagerTests.swift; sourceTree = "<group>"; };
535145DE2CCB758800D40B19 /* NSObject+PBMExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSObject+PBMExtensions.h"; sourceTree = "<group>"; };
535145DF2CCB758800D40B19 /* NSObject+PBMExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSObject+PBMExtensions.m"; sourceTree = "<group>"; };
53514CC52D01B5AF00A480C0 /* InterstitialRenderingAdUnitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InterstitialRenderingAdUnitTest.swift; sourceTree = "<group>"; };
53514CC72D01B5F200A480C0 /* RewardedAdUnitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RewardedAdUnitTest.swift; sourceTree = "<group>"; };
5355ACA829C454070014F16E /* VAST_with_empty_companion.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = VAST_with_empty_companion.xml; sourceTree = "<group>"; };
5355ACAA29C454770014F16E /* CreativeModelCollectionMakerVASTTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreativeModelCollectionMakerVASTTests.swift; sourceTree = "<group>"; };
536A39252A84C50F00B1CCEA /* StringExtensionsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensionsTest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3051,16 +3055,18 @@
isa = PBXGroup;
children = (
925D5DA92737C4E800A8A2B5 /* AdLoadFlow */,
927ADB2528058170006EB8D5 /* MediationAPI */,
925D5E082737DF5F00A8A2B5 /* PBMBannerViewTest.swift */,
925D5E112737E04B00A8A2B5 /* PBMBidRequesterTest.swift */,
925D5E132737E74C00A8A2B5 /* PBMBidResponseTransformerTest.swift */,
925D5E152737E77200A8A2B5 /* DemandResponseInfoTest.swift */,
925D5E172737E7D200A8A2B5 /* PBMErrorTest.swift */,
925D5E1B2737E89400A8A2B5 /* PBMORTBTest.swift */,
925D5E1D2737E8BF00A8A2B5 /* PBMBaseInterstitialAdUnit_DelegationTest.swift */,
927ADB2528058170006EB8D5 /* MediationAPI */,
925D5E2C2737ECEA00A8A2B5 /* PBMWinNotifierTest.swift */,
92F6720727F252E500EA3B8D /* BaseInterstitialAdUnitTest.swift */,
53514CC52D01B5AF00A480C0 /* InterstitialRenderingAdUnitTest.swift */,
53514CC72D01B5F200A480C0 /* RewardedAdUnitTest.swift */,
533135C5282A869800AA1E4D /* BidTest.swift */,
);
path = Prebid;
Expand Down Expand Up @@ -3868,6 +3874,7 @@
FAC837D82321583500565051 /* CollectionExtensionTest.swift in Sources */,
922AFCE82736FAAE00732C53 /* LogToFileLock.swift in Sources */,
600CF0702208963500C95176 /* UtilsTests.swift in Sources */,
53514CC62D01B5B900A480C0 /* InterstitialRenderingAdUnitTest.swift in Sources */,
922AFD392737286D00732C53 /* PBMHTMLCreativeTest_ModalManagerDelegate.swift in Sources */,
6013E3F82215C82900FEE2B1 /* CLLocationManager+Swizzle.swift in Sources */,
925D5D722737B79D00A8A2B5 /* PBMTrackingRecordTest.swift in Sources */,
Expand Down Expand Up @@ -3997,6 +4004,7 @@
925D5D872737BAB300A8A2B5 /* PBMOpenMeasurementWrapperTest.swift in Sources */,
536A39262A84C50F00B1CCEA /* StringExtensionsTest.swift in Sources */,
925D5E782737F60100A8A2B5 /* VastEventTrackingTest.swift in Sources */,
53514CC82D01B5F900A480C0 /* RewardedAdUnitTest.swift in Sources */,
533FDF852A12030C0066ED5A /* MockPrebidJSLibraryManager.swift in Sources */,
922AFD452737298200732C53 /* PBMHTMLCreativeTest_MRAIDPlayVideo.swift in Sources */,
47D9AD2385D2A68745D1AD77 /* MockLocationManager.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion PrebidMobile/AdUnits/MultiformatAdUnit/PrebidAdUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public class PrebidAdUnit: NSObject {
}

adUnit.adUnitConfig.adConfiguration.isInterstitialAd = request.isInterstitial
adUnit.adUnitConfig.adConfiguration.isOptIn = request.isRewarded
adUnit.adUnitConfig.adConfiguration.isRewarded = request.isRewarded
adUnit.adUnitConfig.adPosition = request.adPosition

if request.isInterstitial || request.isRewarded {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class InterstitialRenderingAdUnit: NSObject, BaseInterstitialAdUnitProtoc
set { adUnitConfig.adFormats = newValue }
}

/// The position of the ad on the screen.
public var adPosition: AdPosition {
get { adUnitConfig.adPosition }
set { adUnitConfig.adPosition = newValue }
}

/// The ORTB (OpenRTB) configuration string for the ad unit.
public var ortbConfig: String? {
get { adUnitConfig.ortbConfig }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class RewardedAdUnit: NSObject, BaseInterstitialAdUnitProtocol {
set { adUnitConfig.adFormats = newValue }
}

/// The position of the ad on the screen.
public var adPosition: AdPosition {
get { adUnitConfig.adPosition }
set { adUnitConfig.adPosition = newValue }
}

/// The ORTB (OpenRTB) configuration string for the ad unit.
public var ortbConfig: String? {
get { adUnitConfig.ortbConfig }
Expand Down Expand Up @@ -75,14 +81,17 @@ public class RewardedAdUnit: NSObject, BaseInterstitialAdUnitProtocol {
set { adUnitConfig.adConfiguration.videoControlsConfig.isSoundButtonVisible = newValue }
}

// MARK: Private properties

private let baseAdUnit: BaseRewardedAdUnit
// MARK: Internal Properties

private var adUnitConfig: AdUnitConfig {
// Note: exposed for tests
var adUnitConfig: AdUnitConfig {
baseAdUnit.adUnitConfig
}

// MARK: Private properties

private let baseAdUnit: BaseRewardedAdUnit

private var eventHandler: PBMPrimaryAdRequesterProtocol {
baseAdUnit.eventHandler
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,4 @@ class BaseInterstitialAdUnitTest: XCTestCase {
videoConfig.closeButtonPosition = .topLeft
XCTAssertEqual(videoConfig.closeButtonPosition, .topLeft)
}

func testSetAdPosition() {
let adUnit = BaseInterstitialAdUnit(configID: "test")
let adUnitConfig = adUnit.adUnitConfig

adUnit.adPosition = .header

XCTAssertEqual(adUnit.adPosition, adUnitConfig.adPosition)
XCTAssertEqual(adUnitConfig.adPosition, .header)

adUnit.adPosition = .footer

XCTAssertEqual(adUnit.adPosition, adUnitConfig.adPosition)
XCTAssertEqual(adUnitConfig.adPosition, .footer)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*   Copyright 2018-2024 Prebid.org, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

import XCTest
@testable import PrebidMobile

class InterstitialRenderingAdUnitTest: XCTestCase {

func testSetAdPosition() {
let adUnit = InterstitialRenderingAdUnit(configID: "test")

let adUnitConfig = adUnit.adUnitConfig

adUnit.adPosition = .header

XCTAssertEqual(adUnit.adPosition, adUnitConfig.adPosition)
XCTAssertEqual(adUnitConfig.adPosition, .header)

adUnit.adPosition = .footer

XCTAssertEqual(adUnit.adPosition, adUnitConfig.adPosition)
XCTAssertEqual(adUnitConfig.adPosition, .footer)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*   Copyright 2018-2024 Prebid.org, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

import XCTest
@testable import PrebidMobile

class RewardedAdUnitTest: XCTestCase {

func testSetAdPosition() {
let adUnit = RewardedAdUnit(configID: "test")

let adUnitConfig = adUnit.adUnitConfig

adUnit.adPosition = .header

XCTAssertEqual(adUnit.adPosition, adUnitConfig.adPosition)
XCTAssertEqual(adUnitConfig.adPosition, .header)

adUnit.adPosition = .footer

XCTAssertEqual(adUnit.adPosition, adUnitConfig.adPosition)
XCTAssertEqual(adUnitConfig.adPosition, .footer)
}
}

0 comments on commit 70250a2

Please sign in to comment.