diff --git a/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj b/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj index 9b7ee2550..cd90313ab 100644 --- a/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj +++ b/InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj @@ -31,6 +31,10 @@ 3CC4A3EA2C11F96800B97128 /* CustomRendererBannerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC4A3E82C11F96800B97128 /* CustomRendererBannerController.swift */; }; 457FD34BA45C3840CC31A8F5 /* Pods_InternalTestApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C11D97034E668BBFDD0DDCA /* Pods_InternalTestApp.framework */; }; 530E722C292FACB20025B44D /* UIImageView+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 530E722B292FACB20025B44D /* UIImageView+Extensions.swift */; }; + 535ADDFB2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535ADDFA2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift */; }; + 535ADDFC2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535ADDFA2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift */; }; + 535ADDFE2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535ADDFD2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift */; }; + 535ADDFF2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535ADDFD2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift */; }; 5397BD142936185400ABDA22 /* PrebidOriginalAPIDisplayBannerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5397BD132936185400ABDA22 /* PrebidOriginalAPIDisplayBannerController.swift */; }; 5397BD26293760F500ABDA22 /* PrebidOriginalAPIDisplayInterstitialController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5397BD25293760F500ABDA22 /* PrebidOriginalAPIDisplayInterstitialController.swift */; }; 5397BD2A29376C9700ABDA22 /* PrebidOriginalAPIVideoRewardedController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5397BD2929376C9700ABDA22 /* PrebidOriginalAPIVideoRewardedController.swift */; }; @@ -381,6 +385,8 @@ 3C28C9D72C35713B00D0A7DB /* CustomRendererInterstitialController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRendererInterstitialController.swift; sourceTree = ""; }; 3CC4A3E82C11F96800B97128 /* CustomRendererBannerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRendererBannerController.swift; sourceTree = ""; }; 530E722B292FACB20025B44D /* UIImageView+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageView+Extensions.swift"; sourceTree = ""; }; + 535ADDFA2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidUniversalCreativeTestingGAMController.swift; sourceTree = ""; }; + 535ADDFD2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidUniversalCreativeTestingWebViewController.swift; sourceTree = ""; }; 5397BD132936185400ABDA22 /* PrebidOriginalAPIDisplayBannerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidOriginalAPIDisplayBannerController.swift; sourceTree = ""; }; 5397BD25293760F500ABDA22 /* PrebidOriginalAPIDisplayInterstitialController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidOriginalAPIDisplayInterstitialController.swift; sourceTree = ""; }; 5397BD2929376C9700ABDA22 /* PrebidOriginalAPIVideoRewardedController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidOriginalAPIVideoRewardedController.swift; sourceTree = ""; }; @@ -722,6 +728,8 @@ 5397BD312937895700ABDA22 /* PrebidOriginalAPIVideoInstreamViewController.swift */, 539F961329DEF2670061E7A5 /* PrebidOriginalAPIVideoInterstitialController.swift */, 5397BD2929376C9700ABDA22 /* PrebidOriginalAPIVideoRewardedController.swift */, + 535ADDFA2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift */, + 535ADDFD2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift */, ); path = OriginalAPI; sourceTree = ""; @@ -1587,6 +1595,7 @@ 53ED2FF629798104007D13EE /* BaseConfigurationController.swift in Sources */, 53ED2FF729798104007D13EE /* NativeAsset+Extensions.swift in Sources */, 53ED2FF829798104007D13EE /* PrebidGAMNativeAdController.swift in Sources */, + 535ADDFE2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift in Sources */, 53ED2FF929798104007D13EE /* PrebidOriginalAPIVideoInstreamViewController.swift in Sources */, 53ED2FFA29798104007D13EE /* PrebidAdMobBannerViewController.swift in Sources */, 53ED2FFB29798104007D13EE /* ConfigurableViewController.swift in Sources */, @@ -1610,6 +1619,7 @@ 53ED300B29798104007D13EE /* PrebidMAXInterstitialController.swift in Sources */, 53ED300C29798104007D13EE /* DummyTableViewCell.swift in Sources */, 53ED300D29798104007D13EE /* AboutViewController.swift in Sources */, + 535ADDFC2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift in Sources */, 53ED300E29798104007D13EE /* NativeAdViewBoxProtocol.swift in Sources */, 53ED300F29798104007D13EE /* FormViewController+RowBuildHelpers.swift in Sources */, 53ED301029798104007D13EE /* PrebidGAMBannerController.swift in Sources */, @@ -1683,6 +1693,7 @@ 5B209B4A21075E0A00C0F5CE /* BaseConfigurationController.swift in Sources */, 92C4E60B27A2F5D900738370 /* NativeAsset+Extensions.swift in Sources */, 92102C6127B0F2FE003F12B2 /* PrebidGAMNativeAdController.swift in Sources */, + 535ADDFF2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift in Sources */, 5397BD322937895700ABDA22 /* PrebidOriginalAPIVideoInstreamViewController.swift in Sources */, 92E92502276B299F002B57F3 /* PrebidAdMobBannerViewController.swift in Sources */, 5BCCA3D62136D2E800DA3B5A /* ConfigurableViewController.swift in Sources */, @@ -1706,6 +1717,7 @@ 92221CE12804AF5B005DF671 /* PrebidMAXInterstitialController.swift in Sources */, 5B8EB5EF22676914003CC15C /* DummyTableViewCell.swift in Sources */, 5B3EEDCB2101D1AF00BAA0C4 /* AboutViewController.swift in Sources */, + 535ADDFB2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift in Sources */, 92F9A5D127A15BD1007B0B17 /* NativeAdViewBoxProtocol.swift in Sources */, 341CC3142562C9D000186F29 /* FormViewController+RowBuildHelpers.swift in Sources */, 3493021C2473F408004A6086 /* PrebidGAMBannerController.swift in Sources */, diff --git a/InternalTestApp/PrebidMobileDemoRendering/AppDelegate.swift b/InternalTestApp/PrebidMobileDemoRendering/AppDelegate.swift index c4c076b6a..1b46f832e 100644 --- a/InternalTestApp/PrebidMobileDemoRendering/AppDelegate.swift +++ b/InternalTestApp/PrebidMobileDemoRendering/AppDelegate.swift @@ -183,4 +183,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } + + } diff --git a/InternalTestApp/PrebidMobileDemoRendering/Model/TestCasesManager.swift b/InternalTestApp/PrebidMobileDemoRendering/Model/TestCasesManager.swift index f05b106ae..ab72c496a 100644 --- a/InternalTestApp/PrebidMobileDemoRendering/Model/TestCasesManager.swift +++ b/InternalTestApp/PrebidMobileDemoRendering/Model/TestCasesManager.swift @@ -467,6 +467,30 @@ struct TestCaseManager { setupCustomParams(for: interstitialController.prebidConfigId) }), + + // MARK: ---- Prebid Universal Creative Tests + + TestCase(title: "Prebid Universal Creative (GAM)", + tags: [.banner, .originalAPI, .server], + exampleVCStoryboardID: "AdapterViewController", + configurationClosure: { vc in + guard let adapterVC = vc as? AdapterViewController else { + return + } + + let bannerController = PrebidUniversalCreativeTestingGAMController(rootController: adapterVC) + bannerController.adSize = CGSize(width: 300, height: 250) + bannerController.gamAdUnitID = "/21808260008/prebid_puc_testing" + + adapterVC.setup(adapter: bannerController) + setupCustomParams(for: bannerController.prebidConfigId) + }), + + TestCase(title: "Prebid Universal Creative (WebView)", + tags: [.banner, .originalAPI, .server], + exampleVCStoryboardID: "PrebidUniversalCreativeTestingWebViewController", + configurationClosure: { vc in }), + // MARK: ---- Native (Original API) TestCase(title: "Native Banner (GAM Original) [OK, PUC]", diff --git a/InternalTestApp/PrebidMobileDemoRendering/Resources/Base.lproj/Main.storyboard b/InternalTestApp/PrebidMobileDemoRendering/Resources/Base.lproj/Main.storyboard index 571f4d114..94081ba36 100644 --- a/InternalTestApp/PrebidMobileDemoRendering/Resources/Base.lproj/Main.storyboard +++ b/InternalTestApp/PrebidMobileDemoRendering/Resources/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -376,6 +376,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InternalTestApp/PrebidMobileDemoRendering/Resources/Info.plist b/InternalTestApp/PrebidMobileDemoRendering/Resources/Info.plist index 7e4d40308..8869d27d5 100644 --- a/InternalTestApp/PrebidMobileDemoRendering/Resources/Info.plist +++ b/InternalTestApp/PrebidMobileDemoRendering/Resources/Info.plist @@ -35,8 +35,21 @@ NSAppTransportSecurity + NSAllowsArbitraryLoadsInWebContent + NSAllowsArbitraryLoads + NSAppTransportSecurity + + NSExceptionDomains + + 192.168.0.102 + + NSExceptionAllowsInsecureHTTPLoads + + + + NSLocationAlwaysUsageDescription Access to GPS is needed for testing purposes. diff --git a/InternalTestApp/PrebidMobileDemoRendering/ViewControllers/Adapters/Prebid/OriginalAPI/PrebidUniversalCreativeTestingGAMController.swift b/InternalTestApp/PrebidMobileDemoRendering/ViewControllers/Adapters/Prebid/OriginalAPI/PrebidUniversalCreativeTestingGAMController.swift new file mode 100644 index 000000000..678ddcb7f --- /dev/null +++ b/InternalTestApp/PrebidMobileDemoRendering/ViewControllers/Adapters/Prebid/OriginalAPI/PrebidUniversalCreativeTestingGAMController.swift @@ -0,0 +1,86 @@ +/*   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 GoogleMobileAds + +final class PrebidUniversalCreativeTestingGAMController: + NSObject, + AdaptedController, + PrebidConfigurableBannerController, + GADBannerViewDelegate, WKNavigationDelegate { + + var refreshInterval: TimeInterval = 0 + var prebidConfigId: String = "" + var gamAdUnitID: String = "" + var adSize = CGSize.zero + + let rootController: AdapterViewController + + private var gamBanner: GAMBannerView! + + private let configIdLabel = UILabel() + private let reloadButton = ThreadCheckingButton() + + init(rootController: AdapterViewController) { + self.rootController = rootController + super.init() + + setupAdapterController() + } + + func configurationController() -> BaseConfigurationController? { + return PrebidBannerConfigurationController(controller: self) + } + + private func setupAdapterController() { + rootController.showButton.isHidden = true + + configIdLabel.isHidden = true + rootController.actionsView.addArrangedSubview(configIdLabel) + + reloadButton.addTarget(self, action: #selector(reload), for: .touchUpInside) + } + + func loadAd() { + configIdLabel.isHidden = false + configIdLabel.text = "GAM AdUnit ID: \(gamAdUnitID)" + + gamBanner = GAMBannerView(adSize: GADAdSizeFromCGSize(adSize)) + gamBanner.adUnitID = gamAdUnitID + gamBanner.rootViewController = rootController + gamBanner.delegate = self + + rootController.bannerView?.addSubview(gamBanner) + + let gamRequest = GAMRequest() + gamBanner.load(gamRequest) + } + + @objc private func reload() { + reloadButton.isEnabled = false + let gamRequest = GAMRequest() + gamBanner.load(gamRequest) + } + + func bannerViewDidReceiveAd(_ bannerView: GADBannerView) { + rootController.bannerView.backgroundColor = .clear + reloadButton.isEnabled = true + rootController.bannerView.constraints.first { $0.firstAttribute == .width }?.constant = 300 + rootController.bannerView.constraints.first { $0.firstAttribute == .height }?.constant = 500 + +// let targetWebView = bannerView.allSubViewsOf(type: WKWebView.self).first +// targetWebView?.load(URLRequest(url: URL(string: "http://192.168.0.102:9876")!)) + } +} diff --git a/InternalTestApp/PrebidMobileDemoRendering/ViewControllers/Adapters/Prebid/OriginalAPI/PrebidUniversalCreativeTestingWebViewController.swift b/InternalTestApp/PrebidMobileDemoRendering/ViewControllers/Adapters/Prebid/OriginalAPI/PrebidUniversalCreativeTestingWebViewController.swift new file mode 100644 index 000000000..417bdf9ea --- /dev/null +++ b/InternalTestApp/PrebidMobileDemoRendering/ViewControllers/Adapters/Prebid/OriginalAPI/PrebidUniversalCreativeTestingWebViewController.swift @@ -0,0 +1,32 @@ +/*   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 UIKit +import WebKit + +final class PrebidUniversalCreativeTestingWebViewController: UIViewController { + + @IBOutlet weak var webView: WKWebView! + @IBOutlet weak var textField: UITextField! + + @IBAction func onOpenURLPressed(_ sender: Any) { + guard let urlString = textField.text, let url = URL(string: "http://\(urlString)") else { + return + } + + let request = URLRequest(url: url) + webView.load(request) + } +}