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

Xcode 16 Support #316

Merged
merged 1 commit into from
Sep 13, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -332,10 +332,9 @@ public final class AuthorizationCodeAuthProvider: AuthProviding {
}

DispatchQueue.main.async {
self.applicationLauncher.open(
self.applicationLauncher.launch(
url,
options: [:],
completionHandler: { opened in
completion: { opened in
completion?(opened)
}
)
11 changes: 9 additions & 2 deletions Sources/UberCore/ApplicationLauncher.swift
Original file line number Diff line number Diff line change
@@ -29,7 +29,14 @@ import UIKit
/// @mockable
public protocol ApplicationLaunching {

func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler: ((Bool) -> Void)?)
func launch(_ url: URL, completion: ((Bool) -> ())?)
}

extension UIApplication: ApplicationLaunching {}
extension UIApplication: ApplicationLaunching {

public func launch(_ url: URL, completion: ((Bool) -> ())?) {
open(url, options: [:]) {
completion?($0)
}
}
}
12 changes: 6 additions & 6 deletions examples/UberSDK/UberSDKTests/Mocks/Mocks.swift
Original file line number Diff line number Diff line change
@@ -125,12 +125,12 @@ public class ApplicationLaunchingMock: ApplicationLaunching {
public init() { }


public private(set) var openCallCount = 0
public var openHandler: ((URL, [UIApplication.OpenExternalURLOptionsKey: Any], ((Bool) -> Void)?) -> ())?
public func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler: ((Bool) -> Void)?) {
openCallCount += 1
if let openHandler = openHandler {
openHandler(url, options, completionHandler)
public private(set) var launchCallCount = 0
public var launchHandler: ((URL, ((Bool) -> ())?) -> ())?
public func launch(_ url: URL, completion: ((Bool) -> ())?) {
launchCallCount += 1
if let launchHandler = launchHandler {
launchHandler(url, completion)
}

}
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
}

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, completion in
applicationLauncher.launchHandler = { _, completion in
completion?(true)
}

@@ -114,7 +114,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
}

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, completion in
applicationLauncher.launchHandler = { _, completion in
completion?(true)
}

@@ -156,7 +156,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
let promptString = prompt.stringValue.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { url, _, completion in
applicationLauncher.launchHandler = { url, completion in
XCTAssertTrue(url.query()!.contains("prompt=\(promptString)"))
expectation.fulfill()
completion?(true)
@@ -190,7 +190,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
let promptString = prompt.stringValue.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { url, _, completion in
applicationLauncher.launchHandler = { url, completion in
XCTAssertTrue(url.query()!.contains("prompt=\(promptString)"))
expectation.fulfill()
completion?(true)
@@ -334,7 +334,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
let expectation = XCTestExpectation()

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, completion in
applicationLauncher.launchHandler = { _, completion in
expectation.fulfill()
completion?(true)
}
@@ -360,7 +360,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
func test_executeNativeLogin_noDestinations_triggersInAppLogin() {

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, _ in }
applicationLauncher.launchHandler = { _, _ in }

configurationProvider.isInstalledHandler = { _, _ in
false
@@ -385,7 +385,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
func test_executeNativeLogin_noOpens_triggersInAppLogin() {

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, completion in
applicationLauncher.launchHandler = { _, completion in
completion?(false)
}

@@ -423,7 +423,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
func test_executeNativeLogin_noTokenExchange_doesNotIncludeCodeChallenge() {

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { url, _, completion in
applicationLauncher.launchHandler = { url, completion in
XCTAssertFalse(url.absoluteString.contains("code_challenge"))
XCTAssertFalse(url.absoluteString.contains("code_challenge_method"))
completion?(false)
@@ -448,7 +448,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
applicationLauncher: applicationLauncher
)

XCTAssertEqual(applicationLauncher.openCallCount, 0)
XCTAssertEqual(applicationLauncher.launchCallCount, 0)

provider.execute(
authDestination: .native(appPriority: [.eats]),
@@ -458,7 +458,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {

wait(for: [expectation], timeout: 0.2)

XCTAssertEqual(applicationLauncher.openCallCount, 1)
XCTAssertEqual(applicationLauncher.launchCallCount, 1)
}

func test_handleResponse_true_callsResponseParser() {
@@ -588,7 +588,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
}

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, completion in
applicationLauncher.launchHandler = { _, completion in
completion?(true)
}

@@ -626,7 +626,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
}

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, completion in
applicationLauncher.launchHandler = { _, completion in
completion?(true)
}

@@ -671,7 +671,7 @@ final class AuthorizationCodeAuthProviderTests: XCTestCase {
}

let applicationLauncher = ApplicationLaunchingMock()
applicationLauncher.openHandler = { _, _, completion in
applicationLauncher.launchHandler = { _, completion in
completion?(true)
}

Loading