Skip to content

Commit

Permalink
feat: add web view test case
Browse files Browse the repository at this point in the history
  • Loading branch information
OlenaPostindustria committed Jan 6, 2025
1 parent e47e054 commit 0ff1ad6
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 2 deletions.
6 changes: 6 additions & 0 deletions InternalTestApp/InternalTestApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
53514CEE2D08416B00A480C0 /* CustomRendererBannerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53514CDE2D08416B00A480C0 /* CustomRendererBannerController.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 @@ -396,6 +398,7 @@
53514CDE2D08416B00A480C0 /* CustomRendererBannerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRendererBannerController.swift; sourceTree = "<group>"; };
53514CDF2D08416B00A480C0 /* CustomRendererInterstitialController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomRendererInterstitialController.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 @@ -750,6 +753,7 @@
539F961329DEF2670061E7A5 /* PrebidOriginalAPIVideoInterstitialController.swift */,
5397BD2929376C9700ABDA22 /* PrebidOriginalAPIVideoRewardedController.swift */,
535ADDFA2D19731000DB888F /* PrebidUniversalCreativeTestingGAMController.swift */,
535ADDFD2D19A62C00DB888F /* PrebidUniversalCreativeTestingWebViewController.swift */,
);
path = OriginalAPI;
sourceTree = "<group>";
Expand Down Expand Up @@ -1614,6 +1618,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 Down Expand Up @@ -1715,6 +1720,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ struct TestCaseManager {
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
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 0ff1ad6

Please sign in to comment.