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

Fix tests & support GMA SDK 11.6.0 #1020

Merged
merged 5 commits into from
Jul 3, 2024
Merged
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: 8 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ version: 2.1
jobs:
build:
macos:
xcode: 14.1.0
xcode: 15.4.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- run:
Expand All @@ -12,7 +13,8 @@ jobs:

unit-test:
macos:
xcode: 14.1.0
xcode: 15.4.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- run:
Expand All @@ -21,7 +23,8 @@ jobs:

run-swift-demo-integration-tests:
macos:
xcode: 14.1.0
xcode: 15.4.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- run:
Expand All @@ -30,7 +33,8 @@ jobs:

run-swift-demo-ui-tests:
macos:
xcode: 14.1.0
xcode: 15.4.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- run:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class PrebidAdMobMediationBaseAdapter: NSObject, GADMediationAdapter {

// Added for tests
static func latestTestedGMAVersion() -> GADVersionNumber {
return GADVersionNumber(majorVersion: 11, minorVersion: 5, patchVersion: 0)
return GADVersionNumber(majorVersion: 11, minorVersion: 6, patchVersion: 0)
}

required public override init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class GAMUtils: NSObject {

// Added for tests
static func latestTestedGMAVersion() -> GADVersionNumber {
return GADVersionNumber(majorVersion: 11, minorVersion: 5, patchVersion: 0)
return GADVersionNumber(majorVersion: 11, minorVersion: 6, patchVersion: 0)
}

// MARK: Private Methods
Expand Down
12 changes: 6 additions & 6 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PODS:
- Alamofire (4.9.1)
- AppLovinSDK (12.5.0)
- Eureka (5.4.0)
- Google-Mobile-Ads-SDK (11.5.0):
- Eureka (5.5.0)
- Google-Mobile-Ads-SDK (11.6.0):
- GoogleUserMessagingPlatform (>= 1.1)
- GoogleAds-IMA-iOS-SDK (3.22.1)
- GoogleAds-IMA-iOS-SDK (3.23.0)
- GoogleUserMessagingPlatform (2.4.0)
- RxSwift (6.7.1)
- SVProgressHUD (2.3.1):
Expand Down Expand Up @@ -34,9 +34,9 @@ SPEC REPOS:
SPEC CHECKSUMS:
Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
AppLovinSDK: 626d2aea57ae1bf9280d2012e8e20c521c58ce28
Eureka: fadaa9fa3d6e402d3c60f78f24edf3d7bafc9c29
Google-Mobile-Ads-SDK: 7db2098033ad3bfcd72a11e7503b49700a93029e
GoogleAds-IMA-iOS-SDK: 160c3616b8371b58016e30aaf441e71d6d9e8f7d
Eureka: 1c18c7fcd8f772cc2ca42d6be36292dffa77eecb
Google-Mobile-Ads-SDK: 28339250757645a9bab066ebbe667fa48d2c9bd7
GoogleAds-IMA-iOS-SDK: ee2a68ed7a1a17c7bb81bdb1b81590b35a3fc8f3
GoogleUserMessagingPlatform: f131fa7978d2ba88d7426702b057c2cc318e6595
RxSwift: b9a93a26031785159e11abd40d1a55bcb8057e52
SVProgressHUD: 4837c74bdfe2e51e8821c397825996a8d7de6e22
Expand Down
12 changes: 12 additions & 0 deletions PrebidMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
53CE09012AD673020018CB75 /* sample_ortb_native_with_win_event.json in Resources */ = {isa = PBXBuildFile; fileRef = 53CE09002AD673020018CB75 /* sample_ortb_native_with_win_event.json */; };
53CE09032AD67ECE0018CB75 /* MockPBMBidRequester.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CE09022AD67ECE0018CB75 /* MockPBMBidRequester.swift */; };
53CF5B3729DC690600613E84 /* VideoAdUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CF5B3629DC690600613E84 /* VideoAdUnit.swift */; };
53D3C3882C2BEE1E0074D99B /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D3C3872C2BEE1E0074D99B /* URL+Extensions.swift */; };
53D3C38D2C2BEF9B0074D99B /* NSURL+PBMExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D3C38C2C2BEF9B0074D99B /* NSURL+PBMExtensions.m */; };
53D3C38E2C2BEF9B0074D99B /* NSURL+PBMExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D3C38B2C2BEF9B0074D99B /* NSURL+PBMExtensions.h */; };
53D934FF282CE62E0092E243 /* AgeUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D934FE282CE62E0092E243 /* AgeUtils.swift */; };
53D93505282CEA900092E243 /* DateFormatService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D93504282CEA900092E243 /* DateFormatService.swift */; };
53E3910E27FCD60800DBA2F7 /* VideoParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E3910D27FCD60800DBA2F7 /* VideoParameters.swift */; };
Expand Down Expand Up @@ -963,6 +966,9 @@
53CE09002AD673020018CB75 /* sample_ortb_native_with_win_event.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = sample_ortb_native_with_win_event.json; sourceTree = "<group>"; };
53CE09022AD67ECE0018CB75 /* MockPBMBidRequester.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockPBMBidRequester.swift; sourceTree = "<group>"; };
53CF5B3629DC690600613E84 /* VideoAdUnit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoAdUnit.swift; sourceTree = "<group>"; };
53D3C3872C2BEE1E0074D99B /* URL+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Extensions.swift"; sourceTree = "<group>"; };
53D3C38B2C2BEF9B0074D99B /* NSURL+PBMExtensions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSURL+PBMExtensions.h"; sourceTree = "<group>"; };
53D3C38C2C2BEF9B0074D99B /* NSURL+PBMExtensions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSURL+PBMExtensions.m"; sourceTree = "<group>"; };
53D934FE282CE62E0092E243 /* AgeUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgeUtils.swift; sourceTree = "<group>"; };
53D93504282CEA900092E243 /* DateFormatService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateFormatService.swift; sourceTree = "<group>"; };
53E3910D27FCD60800DBA2F7 /* VideoParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoParameters.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1861,6 +1867,7 @@
34C9CD5E2850CE6300FB5451 /* OMSDKVersionProvider.m */,
53F35F6E292BAE9B001C1183 /* UserDefaults+Extensions.swift */,
53842BBB29E565030069A4B7 /* NSString+Extensions.swift */,
53D3C3872C2BEE1E0074D99B /* URL+Extensions.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -1955,6 +1962,8 @@
5BC3765E271F1CFD00444D5E /* UIWindow+PBMExtensions.h */,
5BC3766F271F1CFD00444D5E /* UIWindow+PBMExtensions.m */,
53C925012990FB30009E6F94 /* String+Extensions.swift */,
53D3C38B2C2BEF9B0074D99B /* NSURL+PBMExtensions.h */,
53D3C38C2C2BEF9B0074D99B /* NSURL+PBMExtensions.m */,
);
path = ExtensionsAndWrappers;
sourceTree = "<group>";
Expand Down Expand Up @@ -3360,6 +3369,7 @@
5BC37A66271F1D0000444D5E /* PBMORTBBidExtSkadn.h in Headers */,
5BC37AD7271F1D0100444D5E /* PBMUserConsentParameterBuilder.h in Headers */,
5BC37964271F1D0000444D5E /* PBMVastResponse.h in Headers */,
53D3C38E2C2BEF9B0074D99B /* NSURL+PBMExtensions.h in Headers */,
5BC379CC271F1D0000444D5E /* PBMAdLoadManagerVAST.h in Headers */,
5BC37985271F1D0000444D5E /* PBMMRAIDController.h in Headers */,
5BC3790F271F1CFF00444D5E /* PBMDeviceAccessManager.h in Headers */,
Expand Down Expand Up @@ -3963,6 +3973,7 @@
9236A650272FEC5A00ABBEF4 /* ImpressionTask.swift in Sources */,
5BC37A97271F1D0000444D5E /* InterstitialEventHandlerProtocol.swift in Sources */,
5BC379F3271F1D0000444D5E /* PBMExternalLinkHandler.m in Sources */,
53D3C38D2C2BEF9B0074D99B /* NSURL+PBMExtensions.m in Sources */,
5BC379AD271F1D0000444D5E /* PBMTransaction.m in Sources */,
53269D55282E6D0F0098550D /* ServerEvent.swift in Sources */,
5BC37A5E271F1D0000444D5E /* PBMORTBBidResponseExt.m in Sources */,
Expand Down Expand Up @@ -4190,6 +4201,7 @@
5BC37961271F1D0000444D5E /* PBMVastAdsBuilder.m in Sources */,
5BC37A91271F1D0000444D5E /* InterstitialEventLoadingDelegate.swift in Sources */,
530382F2283197E100B2B111 /* PrebidServerResponse.swift in Sources */,
53D3C3882C2BEE1E0074D99B /* URL+Extensions.swift in Sources */,
5BC3792F271F1D0000444D5E /* PBMDeviceAccessManager.m in Sources */,
5BC37A6E271F1D0000444D5E /* PBMORTBBidResponse.m in Sources */,
5BC37ACE271F1D0100444D5E /* PBMGeoLocationParameterBuilder.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
class PrebidGAMVersionChecker {

var latestTestedGMAVersion: (Int, Int, Int) {
(11, 5, 0)
(11, 6, 0)
}

var currentGMAVersion: (Int, Int, Int)?
Expand Down
2 changes: 1 addition & 1 deletion PrebidMobile/Host.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Host: NSObject {
*/

@objc public func setCustomHostURL(_ urlString: String?) throws {
guard let url = URL(string: urlString!) else {
guard let url = URL.urlWithoutEncoding(from: urlString) else {
throw ErrorCode.prebidServerURLInvalid(urlString ?? "")
}
customHostURL = url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "NSException+PBMExtensions.h"
#import "NSString+PBMExtensions.h"
#import "UIView+PBMExtensions.h"
#import "NSURL+PBMExtensions.h"

#import "PBMAbstractCreative.h"
#import "PBMCreativeModel.h"
Expand Down Expand Up @@ -277,7 +278,7 @@ - (void)handleMRAIDCommandOpen:(PBMMRAIDCommand *)command {
@throw [NSException pbmException:@"No arguments to MRAID.open()"];
}

NSURL *url = [NSURL URLWithString:strURL];
NSURL *url = [NSURL PBMURLWithoutEncodingFromString:strURL];
if (!url) {
@throw [NSException pbmException:[NSString stringWithFormat:@"Could not create URL from string: %@", strURL]];
}
Expand Down Expand Up @@ -323,7 +324,7 @@ - (void)handleMRAIDCommandExpand:(PBMMRAIDCommand *)command originURL:(NSURL *)u
NSString *strExpandURL = [[command.arguments firstObject] stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
if (strExpandURL && ![strExpandURL isEqualToString:@""]) {
//Epanding to a URL
NSURL *expandURL = [NSURL URLWithString:strExpandURL];
NSURL *expandURL = [NSURL PBMURLWithoutEncodingFromString:strExpandURL];
if (!expandURL) {
PBMLogError(@"Could not create expand url to: %@", strExpandURL);
return;
Expand Down Expand Up @@ -532,7 +533,7 @@ - (void)handleMRAIDCommandPlayVideo:(PBMMRAIDCommand *)command {
@throw [NSException pbmException:@"Insufficient arguments for MRAIDAction.playVideo"];
}

NSURL *url = [NSURL URLWithString:strURL];
NSURL *url = [NSURL PBMURLWithoutEncodingFromString:strURL];
if (!url) {
NSString *message = [NSString stringWithFormat:@"MRAID attempted to load an invalid URL: %@", strURL];
@throw [NSException pbmException:message];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*   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 <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSURL (PBMExtensions)

+ (NSURL *)PBMURLWithoutEncodingFromString:(NSString *)str;

@end

NS_ASSUME_NONNULL_END
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 "NSURL+PBMExtensions.h"

@implementation NSURL (PBMExtensions)

+ (NSURL *)PBMURLWithoutEncodingFromString:(NSString *)str {
if (!str) {
return nil;
}

if (@available(iOS 17.0, *)) {
return [NSURL URLWithString:str encodingInvalidCharacters:NO];
} else {
return [NSURL URLWithString:str];
}
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public class PrebidServerConnection: NSObject, PrebidServerConnectionProtocol, U
return nil
}

guard let url = URL(string: strUrl) else {
guard let url = URL.urlWithoutEncoding(from: strUrl) else {
Log.error("URL creation failed for string: \(strUrl)")
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
 */

#import "PBMDeepLinkPlus.h"
#import "NSURL+PBMExtensions.h"

@interface PBMDeepLinkPlus()

Expand Down Expand Up @@ -48,7 +49,7 @@ - (BOOL)parseURL:(NSURL * _Nonnull)url {

for (NSURLQueryItem *queryItem in queryItems) {
NSString *key = queryItem.name;
NSURL *valueURL = [NSURL URLWithString:queryItem.value];
NSURL *valueURL = [NSURL PBMURLWithoutEncodingFromString:queryItem.value];
if (valueURL != nil) {
if ([key isEqualToString:@"primaryUrl"]) {
if (self.primaryURL == nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ - (nullable NSString *)platformString {
}

- (nullable NSString *)userLangaugeCode {
return [self.locale objectForKey:NSLocaleLanguageCode];
NSString * languageCode = [self.locale objectForKey:NSLocaleLanguageCode];
if (languageCode.length == 0) {
return nil;
}
return languageCode;
}

#pragma mark - IDFA
Expand Down
31 changes: 31 additions & 0 deletions PrebidMobile/Utils/URL+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*   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 Foundation

extension URL {

static func urlWithoutEncoding(from str: String?) -> URL? {
guard let str = str else {
return nil
}

if #available(iOS 17.0, *) {
return URL(string: str, encodingInvalidCharacters: false)
}

return URL(string: str)
}
}
2 changes: 1 addition & 1 deletion scripts/testPrebidDemo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else
SCHEME="PrebidDemoTests"
TEST="Integration"
fi
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme $SCHEME -test-iterations 2 -retry-tests-on-failure -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=latest' | xcpretty -f `xcpretty-travis-formatter` --color --test
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme $SCHEME -test-iterations 2 -retry-tests-on-failure -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest' | xcpretty -f `xcpretty-travis-formatter` --color --test

if [[ ${PIPESTATUS[0]} == 0 ]]; then
echo "✅ ${TEST} Tests Passed"
Expand Down
9 changes: 5 additions & 4 deletions scripts/testPrebidMobile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ fi
echo -e "\n${GREEN}Running PrebidMobile unit tests${NC} \n"
xcodebuild test \
-workspace PrebidMobile.xcworkspace \
-retry-tests-on-failure \
-scheme "PrebidMobileTests" \
-destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=latest' | xcpretty --color --test
-destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest' | xcpretty --color --test

if [[ ${PIPESTATUS[0]} == 0 ]]; then
echo "✅ PrebidMobile Unit Tests Passed"
Expand All @@ -67,7 +68,7 @@ echo -e "\n${GREEN}Running PrebidMobileGAMEventHandlers unit tests${NC} \n"
xcodebuild test \
-workspace PrebidMobile.xcworkspace \
-scheme "PrebidMobileGAMEventHandlersTests" \
-destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=latest' | xcpretty --color --test
-destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest' | xcpretty --color --test

if [[ ${PIPESTATUS[0]} == 0 ]]; then
echo "✅ PrebidMobileGAMEventHandlers Unit Tests Passed"
Expand All @@ -77,7 +78,7 @@ else
fi

echo -e "\n${GREEN}Running PrebidMobileAdMobAdapters unit tests${NC} \n"
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidMobileAdMobAdaptersTests" -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=latest' | xcpretty -f `xcpretty-travis-formatter` --color --test
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidMobileAdMobAdaptersTests" -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest' | xcpretty -f `xcpretty-travis-formatter` --color --test

if [[ ${PIPESTATUS[0]} == 0 ]]; then
echo "✅ PrebidMobileAdMobAdapters Unit Tests Passed"
Expand All @@ -87,7 +88,7 @@ else
fi

echo -e "\n${GREEN}Running PrebidMobileMAXAdapters unit tests${NC} \n"
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidMobileMAXAdaptersTests" -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=latest' | xcpretty -f `xcpretty-travis-formatter` --color --test
xcodebuild test -workspace PrebidMobile.xcworkspace -scheme "PrebidMobileMAXAdaptersTests" -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=latest' | xcpretty -f `xcpretty-travis-formatter` --color --test

if [[ ${PIPESTATUS[0]} == 0 ]]; then
echo "✅ PrebidMobileMAXAdapters Unit Tests Passed"
Expand Down