Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -2,40 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest
import Foundation
import Testing

@testable import webview_flutter_wkwebview

class AuthenticationChallengeResponseProxyAPITests: XCTestCase {
func testPigeonDefaultConstructor() {
@Suite struct AuthenticationChallengeResponseProxyAPITests {
@Test func pigeonDefaultConstructor() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiAuthenticationChallengeResponse(registrar)

let instance = try? api.pigeonDelegate.pigeonDefaultConstructor(
pigeonApi: api, disposition: UrlSessionAuthChallengeDisposition.useCredential,
credential: URLCredential())
XCTAssertNotNil(instance)
#expect(instance != nil)
}

func testDisposition() {
@Test func disposition() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiAuthenticationChallengeResponse(registrar)

let instance = AuthenticationChallengeResponse(
disposition: .useCredential, credential: URLCredential())
let value = try? api.pigeonDelegate.disposition(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, UrlSessionAuthChallengeDisposition.useCredential)
#expect(value == UrlSessionAuthChallengeDisposition.useCredential)
}

func testCredential() {
@Test func credential() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiAuthenticationChallengeResponse(registrar)

let instance = AuthenticationChallengeResponse(
disposition: .useCredential, credential: URLCredential())
let value = try? api.pigeonDelegate.credential(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, instance.credential)
#expect(value == instance.credential)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest
import Foundation
import Testing

@testable import webview_flutter_wkwebview

#if os(iOS)
import UIKit
#endif

class ColorProxyAPITests: XCTestCase {
@Suite struct ColorProxyAPITests {
#if os(iOS)
func testPigeonDefaultConstructor() {
@Test func pigeonDefaultConstructor() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiUIColor(registrar)

let instance = try? api.pigeonDelegate.pigeonDefaultConstructor(
pigeonApi: api, red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
XCTAssertNotNil(instance)
#expect(instance != nil)
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest
import Foundation
import Testing

@testable import webview_flutter_wkwebview

class ErrorProxyAPITests: XCTestCase {
func testCode() {
@Suite struct ErrorProxyAPITests {
@Test func code() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiNSError(registrar)

let code = 0
let instance = NSError(domain: "", code: code)
let value = try? api.pigeonDelegate.code(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, Int64(code))
#expect(value == Int64(code))
}

func testDomain() {
@Test func domain() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiNSError(registrar)

let domain = "domain"
let instance = NSError(domain: domain, code: 0)
let value = try? api.pigeonDelegate.domain(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, domain)
#expect(value == domain)
}

func testUserInfo() {
@Test func userInfo() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiNSError(registrar)

let userInfo: [String: String?] = ["some": "info"]
let instance = NSError(domain: "", code: 0, userInfo: userInfo as [String: Any])
let value = try? api.pigeonDelegate.userInfo(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value as! [String: String?], userInfo)
#expect(value as! [String: String?] == userInfo)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import Foundation
import Testing
import WebKit
import XCTest

@testable import webview_flutter_wkwebview

Expand All @@ -15,8 +16,8 @@ import XCTest
#error("Unsupported platform.")
#endif

class FWFWebViewFlutterWKWebViewExternalAPITests: XCTestCase {
@MainActor func testWebViewForIdentifier() {
@Suite struct FWFWebViewFlutterWKWebViewExternalAPITests {
@MainActor @Test func webViewForIdentifier() throws {
let registry = TestRegistry()

#if os(iOS)
Expand All @@ -36,23 +37,23 @@ class FWFWebViewFlutterWKWebViewExternalAPITests: XCTestCase {

let result = FWFWebViewFlutterWKWebViewExternalAPI.webView(
forIdentifier: Int64(webViewIdentifier), withPluginRegistry: registry)
XCTAssertEqual(result, webView)
#expect(result == webView)
}

@MainActor func testWebViewForIdentifierHandlesIncorrectRegistry() {
@MainActor @Test func webViewForIdentifierHandlesIncorrectRegistry() throws {
let registry = TestRegistry()
// Ensure that passing an empty registry, such as the FlutterAppDelegate
// in an app that has adopted UIScene, gracefully returns nil.
let result = FWFWebViewFlutterWKWebViewExternalAPI.webView(
forIdentifier: 0, withPluginRegistry: registry)
XCTAssertEqual(result, nil)
#expect(result == nil)
}

// FlutterPluginRegistrar.valuePublished(byPlugin:) is not available on macOS. This
// can be removed once this method becomes available.
// See https://github.com/flutter/flutter/issues/186911.
#if os(iOS)
@MainActor func testWebViewForIdentifierFromRegistrar() {
@MainActor @Test func webViewForIdentifierFromRegistrar() throws {
let registry = TestRegistry()

#if os(iOS)
Expand All @@ -72,16 +73,16 @@ class FWFWebViewFlutterWKWebViewExternalAPITests: XCTestCase {

let result = FWFWebViewFlutterWKWebViewExternalAPI.webView(
forIdentifier: Int64(webViewIdentifier), withPluginRegistrar: registrar)
XCTAssertEqual(result, webView)
#expect(result == webView)
}

@MainActor func testWebViewForIdentifierHandlesIncorrectRegistrar() {
@MainActor @Test func webViewForIdentifierHandlesIncorrectRegistrar() throws {
let registrar = TestFlutterPluginRegistrar()
// Ensure that passing an empty registry, such as the FlutterAppDelegate
// in an app that has adopted UIScene, gracefully returns nil.
let result = FWFWebViewFlutterWKWebViewExternalAPI.webView(
forIdentifier: 0, withPluginRegistrar: registrar)
XCTAssertEqual(result, nil)
#expect(result == nil)
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import Foundation
import Testing
import WebKit
import XCTest

@testable import webview_flutter_wkwebview

@MainActor
class FrameInfoProxyAPITests: XCTestCase {
@MainActor func testIsMainFrame() {
@Suite struct FrameInfoProxyAPITests {
@MainActor @Test func isMainFrame() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiWKFrameInfo(registrar)

let instance = TestFrameInfo.instance
let value = try? api.pigeonDelegate.isMainFrame(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, instance.isMainFrame)
#expect(value == instance.isMainFrame)
}

@MainActor func testRequest() {
@MainActor @Test func request() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiWKFrameInfo(registrar)

let instance = TestFrameInfo.instance
let value = try? api.pigeonDelegate.request(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value?.value, instance.request)
#expect(value?.value == instance.request)
}

@MainActor func testNilRequest() {
@MainActor @Test func nilRequest() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiWKFrameInfo(registrar)

Expand All @@ -38,9 +39,9 @@ class FrameInfoProxyAPITests: XCTestCase {
// On macOS 15.5+, `WKFrameInfo.request` returns with an empty URLRequest.
// Previously it would return nil so accept either.
if value != nil {
XCTAssertEqual(value?.value.url?.absoluteString, "")
#expect(value?.value.url?.absoluteString == "")
} else {
XCTAssertNil(value)
#expect(value == nil)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest
import Foundation
import Testing

@testable import webview_flutter_wkwebview

class GetTrustResultResponseProxyAPITests: XCTestCase {
func testResult() {
@Suite struct GetTrustResultResponseProxyAPITests {
@Test func result() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiGetTrustResultResponse(registrar)

let instance = GetTrustResultResponse(result: SecTrustResultType.invalid, resultCode: -1)
let value = try? api.pigeonDelegate.result(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, DartSecTrustResultType.invalid)
#expect(value == DartSecTrustResultType.invalid)
}

func testResultCode() {
@Test func resultCode() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiGetTrustResultResponse(registrar)

let instance = GetTrustResultResponse(result: SecTrustResultType.invalid, resultCode: -1)
let value = try? api.pigeonDelegate.resultCode(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value, -1)
#expect(value == -1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import XCTest
import Foundation
import Testing

@testable import webview_flutter_wkwebview

class HTTPCookieProxyAPITests: XCTestCase {
func testPigeonDefaultConstructor() {
@Suite struct HTTPCookieProxyAPITests {
@Test func pigeonDefaultConstructor() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiHTTPCookie(registrar)

let instance = try? api.pigeonDelegate.pigeonDefaultConstructor(
pigeonApi: api,
properties: [.name: "foo", .value: "bar", .domain: "http://google.com", .path: "/anything"])
XCTAssertNotNil(instance)
#expect(instance != nil)
}

func testGetProperties() {
@Test func getProperties() throws {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiHTTPCookie(registrar)

Expand All @@ -26,9 +27,9 @@ class HTTPCookieProxyAPITests: XCTestCase {
])!
let value = try? api.pigeonDelegate.getProperties(pigeonApi: api, pigeonInstance: instance)

XCTAssertEqual(value?[.name] as? String, "foo")
XCTAssertEqual(value?[.value] as? String, "bar")
XCTAssertEqual(value?[.domain] as? String, "http://google.com")
XCTAssertEqual(value?[.path] as? String, "/anything")
#expect(value?[.name] as? String == "foo")
#expect(value?[.value] as? String == "bar")
#expect(value?[.domain] as? String == "http://google.com")
#expect(value?[.path] as? String == "/anything")
}
}
Loading
Loading