Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce test cases for PUC #1077

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -381,6 +385,8 @@
3C28C9D72C35713B00D0A7DB /* CustomRendererInterstitialController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRendererInterstitialController.swift; sourceTree = "<group>"; };
3CC4A3E82C11F96800B97128 /* CustomRendererBannerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRendererBannerController.swift; sourceTree = "<group>"; };
530E722B292FACB20025B44D /* UIImageView+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImageView+Extensions.swift"; sourceTree = "<group>"; };
535ADDFA2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidUniversalCreativeTestingGAMController.swift; sourceTree = "<group>"; };
535ADDFD2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidUniversalCreativeTestingWebViewController.swift; sourceTree = "<group>"; };
5397BD132936185400ABDA22 /* PrebidOriginalAPIDisplayBannerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidOriginalAPIDisplayBannerController.swift; sourceTree = "<group>"; };
5397BD25293760F500ABDA22 /* PrebidOriginalAPIDisplayInterstitialController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidOriginalAPIDisplayInterstitialController.swift; sourceTree = "<group>"; };
5397BD2929376C9700ABDA22 /* PrebidOriginalAPIVideoRewardedController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrebidOriginalAPIVideoRewardedController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -722,6 +728,8 @@
5397BD312937895700ABDA22 /* PrebidOriginalAPIVideoInstreamViewController.swift */,
539F961329DEF2670061E7A5 /* PrebidOriginalAPIVideoInterstitialController.swift */,
5397BD2929376C9700ABDA22 /* PrebidOriginalAPIVideoRewardedController.swift */,
535ADDFA2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift */,
535ADDFD2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift */,
);
path = OriginalAPI;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand Down
2 changes: 2 additions & 0 deletions InternalTestApp/PrebidMobileDemoRendering/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:.
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6M7-3O-9SJ">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="6M7-3O-9SJ">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -376,6 +376,68 @@
</objects>
<point key="canvasLocation" x="-180" y="1926"/>
</scene>
<!--Prebid Universal Creative Testing Web View Controller-->
<scene sceneID="1bh-3o-3hr">
<objects>
<viewController storyboardIdentifier="PrebidUniversalCreativeTestingWebViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="6C0-Uv-o8K" customClass="PrebidUniversalCreativeTestingWebViewController" customModule="InternalTestApp" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="f5y-Bu-uF0">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="gEx-oc-f1D">
<rect key="frame" x="94" y="63" width="187.5" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WuP-WD-y5P">
<rect key="frame" x="136.5" y="107" width="102" height="35"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Open URL"/>
<connections>
<action selector="onOpenURLPressed:" destination="6C0-Uv-o8K" eventType="touchUpInside" id="APu-tj-xWt"/>
</connections>
</button>
<wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="M13-Dr-swd">
<rect key="frame" x="37.5" y="152" width="300" height="250"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="Yx3-0i-S0n"/>
<constraint firstAttribute="height" constant="250" id="jn4-oq-cg6"/>
</constraints>
<wkWebViewConfiguration key="configuration">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences"/>
</wkWebViewConfiguration>
</wkWebView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="IP address(f.e. 192.168.0.108:9876)" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zgi-DY-0kd">
<rect key="frame" x="62.5" y="35" width="250.5" height="18"/>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="6xz-81-es3"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="WuP-WD-y5P" firstAttribute="centerX" secondItem="f5y-Bu-uF0" secondAttribute="centerX" id="3MP-so-oYh"/>
<constraint firstItem="Zgi-DY-0kd" firstAttribute="centerX" secondItem="f5y-Bu-uF0" secondAttribute="centerX" id="3yK-uW-tei"/>
<constraint firstItem="Zgi-DY-0kd" firstAttribute="top" secondItem="6xz-81-es3" secondAttribute="top" constant="15" id="MiX-3g-VhY"/>
<constraint firstItem="gEx-oc-f1D" firstAttribute="centerX" secondItem="f5y-Bu-uF0" secondAttribute="centerX" id="R0m-Oy-yjw"/>
<constraint firstItem="M13-Dr-swd" firstAttribute="top" secondItem="WuP-WD-y5P" secondAttribute="bottom" constant="10" id="U8i-28-Imo"/>
<constraint firstItem="gEx-oc-f1D" firstAttribute="top" secondItem="Zgi-DY-0kd" secondAttribute="bottom" constant="10" id="ZUA-zC-sqp"/>
<constraint firstItem="M13-Dr-swd" firstAttribute="centerX" secondItem="f5y-Bu-uF0" secondAttribute="centerX" id="c5e-jc-sxK"/>
<constraint firstItem="gEx-oc-f1D" firstAttribute="width" secondItem="f5y-Bu-uF0" secondAttribute="width" multiplier="0.5" id="cwk-oO-d6t"/>
<constraint firstItem="WuP-WD-y5P" firstAttribute="top" secondItem="gEx-oc-f1D" secondAttribute="bottom" constant="10" id="eo7-c4-dHB"/>
</constraints>
</view>
<connections>
<outlet property="textField" destination="gEx-oc-f1D" id="DEy-7S-P3k"/>
<outlet property="webView" destination="M13-Dr-swd" id="bbx-Nr-eXo"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="bHa-QV-5Dm" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-186" y="2603"/>
</scene>
<!--Prebid Presentation View Controller-->
<scene sceneID="tdw-Us-BGz">
<objects>
Expand Down
13 changes: 13 additions & 0 deletions InternalTestApp/PrebidMobileDemoRendering/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,21 @@
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>192.168.0.102</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
<key>NSLocationAlwaysUsageDescription</key>
<string>Access to GPS is needed for testing purposes.</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -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")!))
}
}
Loading