-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webview_flutter_wkwebview] Updates the internal wrapper to use `@Pro…
…xyApi` from pigeon (#8311) Also fixes flutter/flutter#152352
- Loading branch information
1 parent
040f805
commit d6705de
Showing
187 changed files
with
24,976 additions
and
27,676 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/webview_flutter/webview_flutter_wkwebview/CONTRIBUTING.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Contributing to `webview_flutter_wkwebview` | ||
|
||
Please start by taking a look at the general guide to contributing to the `flutter/packages` repo: | ||
https://github.com/flutter/packages/blob/main/CONTRIBUTING.md | ||
|
||
## Package Structure | ||
|
||
This plugin serves as a platform implementation plugin as outlined in [federated plugins](https://docs.flutter.dev/packages-and-plugins/developing-packages#federated-plugins). | ||
The sections below will provide an overview of how this plugin implements this portion with iOS and | ||
macOS. | ||
|
||
For making changes to this package, please take a look at [changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins). | ||
|
||
### Quick Overview | ||
|
||
This plugin implements the platform interface provided by `webview_flutter_platform_interface` using | ||
the native WebKit APIs for WKWebView APIs. | ||
|
||
#### SDK Wrappers | ||
|
||
To access native APIS, this plugins uses Dart wrappers of the native library. The native library is | ||
wrapped using using the `ProxyApi` feature from the `pigeon` package. | ||
|
||
The wrappers for the native library can be updated and modified by changing `pigeons/web_kit.dart`. | ||
|
||
The generated files are located: | ||
* `lib/src/common/web_kit.g.dart` | ||
* `darwin/webview_flutter_wkwebview/Sources/webview_flutter_wkwebview/WebKitLibrary.g.swift` | ||
|
||
To update the wrapper, follow the steps below: | ||
|
||
##### 1. Make changes to the respective pigeon file that matches the native SDK | ||
|
||
* WebKit Dependency: https://developer.apple.com/documentation/webkit | ||
* Pigeon file to update: `pigeons/web_kit.dart` | ||
|
||
##### 2. Run the code generator from the terminal | ||
|
||
Run: `dart run pigeon --input pigeons/web_kit.dart` | ||
|
||
##### 3. Update the generated APIs in native code | ||
|
||
Running the `flutter build` command from step 1 again should provide build errors and indicate what | ||
needs to be done. Alternatively, it can be easier to update native code with the platform's specific | ||
IDE: | ||
|
||
Open `example/ios/` or `example/macos/` in Xcode. | ||
|
||
##### 4. Write API tests | ||
|
||
Assuming a non-static method or constructor was added to the native wrapper, a native test will need | ||
to be added. | ||
|
||
Tests location: `darwin/Tests` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...webview_flutter_wkwebview/darwin/Tests/AuthenticationChallengeResponseProxyAPITests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import XCTest | ||
|
||
@testable import webview_flutter_wkwebview | ||
|
||
class AuthenticationChallengeResponseProxyAPITests: XCTestCase { | ||
func testPigeonDefaultConstructor() { | ||
let registrar = TestProxyApiRegistrar() | ||
let api = registrar.apiDelegate.pigeonApiAuthenticationChallengeResponse(registrar) | ||
|
||
let instance = try? api.pigeonDelegate.pigeonDefaultConstructor( | ||
pigeonApi: api, disposition: UrlSessionAuthChallengeDisposition.useCredential, | ||
credential: URLCredential()) | ||
XCTAssertNotNil(instance) | ||
} | ||
|
||
func testDisposition() { | ||
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) | ||
} | ||
|
||
func testCredential() { | ||
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) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/ErrorProxyAPITests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import XCTest | ||
|
||
@testable import webview_flutter_wkwebview | ||
|
||
class ErrorProxyAPITests: XCTestCase { | ||
func testCode() { | ||
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)) | ||
} | ||
|
||
func testDomain() { | ||
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) | ||
} | ||
|
||
func testUserInfo() { | ||
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) | ||
} | ||
} |
209 changes: 0 additions & 209 deletions
209
packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/FWFDataConvertersTests.m
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/webview_flutter/webview_flutter_wkwebview/darwin/Tests/FWFErrorTests.m
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.