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

Temporarily silence concurrency warnings #25

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Source/Bridge/Bridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public final class Bridge: Bridgable {
}
}

extension Bridge: ScriptMessageHandlerDelegate {
extension Bridge: @preconcurrency ScriptMessageHandlerDelegate {
@MainActor
func scriptMessageHandlerDidReceiveMessage(_ scriptMessage: WKScriptMessage) {
if let event = scriptMessage.body as? String, event == "ready" {
Expand Down
2 changes: 1 addition & 1 deletion Source/Turbo/Navigator/WKUIController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import WebKit
@preconcurrency import WebKit

public protocol WKUIControllerDelegate: AnyObject {
func present(_ alert: UIAlertController, animated: Bool)
Expand Down
2 changes: 1 addition & 1 deletion Source/Turbo/Session/Session.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import WebKit
@preconcurrency import WebKit

/// A Session represents the main interface for managing
/// a Hotwire app in a web view. Each Session manages a single web view
Expand Down
2 changes: 1 addition & 1 deletion Source/Turbo/Visit/ColdBootVisit.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import WebKit
@preconcurrency import WebKit

/// A "Cold Boot" visit is the initial visit to load the page, including all resources.
/// Subsequent visits go through Turbo and use `JavaScriptVisit`.
Expand Down
6 changes: 5 additions & 1 deletion Tests/Turbo/SessionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class SessionTests: XCTestCase {

override func tearDown() {
session.webView.configuration.userContentController.removeScriptMessageHandler(forName: "turbo")

sessionDelegate.reset()

server.stopAndWait()
eventLoop.stop()
}
Expand All @@ -52,6 +53,7 @@ class SessionTests: XCTestCase {
XCTAssertTrue(sessionDelegate.sessionDidStartRequestCalled)
}

@MainActor
func test_coldBootVisit_whenVisitSucceeds_callsSessionDidLoadWebViewDelegateMethod() async {
await visit("/")

Expand Down Expand Up @@ -106,6 +108,7 @@ class SessionTests: XCTestCase {
XCTAssertEqual(error as? TurboError, TurboError.pageLoadFailure)
}

@MainActor
func test_coldBootVisit_Turbolinks5Compatibility_loadsThePageAndSetsTheAdapter() async throws {
await visit("/turbolinks")

Expand All @@ -115,6 +118,7 @@ class SessionTests: XCTestCase {
XCTAssertTrue(try XCTUnwrap(result as? Bool))
}

@MainActor
func test_coldBootVisit_Turbolinks5_3Compatibility_loadsThePageAndSetsTheAdapter() async throws {
await visit("/turbolinks-5.3")

Expand Down
15 changes: 13 additions & 2 deletions Tests/Turbo/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,27 @@ class TestVisitable: UIViewController, Visitable {
}

class TestSessionDelegate: NSObject, SessionDelegate {
var sessionDidLoadWebViewCalled = false { didSet { didChange?() }}
var sessionDidLoadWebViewCalled = false
var sessionDidStartRequestCalled = false
var sessionDidFinishRequestCalled = false
var failedRequestError: Error? = nil
var sessionDidFailRequestCalled = false { didSet { didChange?() }}
var sessionDidFailRequestCalled = false
var sessionDidProposeVisitCalled = false

var didChange: (() -> Void)?

func reset() {
sessionDidLoadWebViewCalled = false
sessionDidStartRequestCalled = false
sessionDidFinishRequestCalled = false
failedRequestError = nil
sessionDidFailRequestCalled = false
sessionDidProposeVisitCalled = false
}

func sessionDidLoadWebView(_ session: Session) {
sessionDidLoadWebViewCalled = true
didChange?()
}

func sessionDidStartRequest(_ session: Session) {
Expand All @@ -69,6 +79,7 @@ class TestSessionDelegate: NSObject, SessionDelegate {

func session(_ session: Session, didFailRequestForVisitable visitable: Visitable, error: Error) {
sessionDidFailRequestCalled = true
didChange?()
failedRequestError = error
}

Expand Down
Loading