Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter] Add platform interface method loadRequest. #4450

Merged

Conversation

BeMacized
Copy link
Member

@BeMacized BeMacized commented Oct 25, 2021

This PR is a partial resubmission of my colleague's PR: #4169.

It adds the loadRequest method to the webview plugin's platform interface, in order to support executing more specific requests when loading web pages.

Related issue:

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter]. (Note that unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the [CLA].
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy].
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

BeMacized and others added 2 commits October 25, 2021 15:11
Co-authored-by: Yusuf Dağ <yusuf@baseflow.com>
@google-cla
Copy link

google-cla bot commented Oct 25, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Oct 25, 2021
@github-actions github-actions bot added the p: webview_flutter Edits files for a webview_flutter plugin label Oct 25, 2021
@ydag
Copy link
Contributor

ydag commented Oct 25, 2021

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Oct 25, 2021
Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit

),
],
);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a second test that sets the optional parameters and ensures they come through as expected as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stuartmorgan Would that not just be testing WebViewRequest's toJson method? We can of course add a second test, but as that toJson is already being tested here, including the optional parameters, I feel like we would be testing for the same thing twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you know that loadRequest calls WebViewRequest's toJson method? Or to be more precise: how do you know that it will continue to do so?

I guarantee you that I could write a PR that breaks the test I am asking you to write without changing WebViewRequest.toJson.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is indeed a fair point, I now see it wouldn't. I've added the test for the optional parameters.

Just for my own curiosity: Would it not be possible to avoid testing toJson by instead mocking the WebViewRequest and checking if the return value of toJson gets passed to invokeMethod?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests should assert the behavior you want to guarantee. Which is a better description of the thing you want to guarantee is true:

  1. "The method channel is sent the following specific keys with the expected values", or
  2. "The call to the method channel is implemented by calling toJson on invokeMethod"?

(As an example of why only one of these is a good description: if someone later decides that the JSON keys aren't very descriptive, and sends a PR that updates toJson and its test to use different keys, what do you want to happen?)

@BeMacized BeMacized added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Nov 2, 2021
@fluttergithubbot fluttergithubbot merged commit 2c16458 into flutter:master Nov 2, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 3, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 3, 2021
NickalasB added a commit to NickalasB/plugins that referenced this pull request Nov 4, 2021
* master:
  [webview_flutter] Deprecate evaluateJavascript in favour of runJavaScript and runJavaScriptForResult. (flutter#4403)
  [webview_flutter] Add interface methods to load local files and HTML strings. (flutter#4446)
  [ci] add pedantic dep to new in_app_purchase pkgs (flutter#4471)
  [ci] Remove unused dep from file_selector. (flutter#4468)
  [ci] update build_runner dep in android_intent and file_selector example (flutter#4467)
  [webview_flutter] Add platform interface method `loadRequest`. (flutter#4450)
  Remove -Werror from deprecated plugin Android builds (flutter#4466)
  [webview_flutter] Update webview packages for Android and iOS to implement `runJavascript` and `runJavascriptReturningResult`. (flutter#4402)
  [camera] Fix CamcorderProfile Usages (flutter#4423)
  [google_sign_in] Use a transparent image as a placeholder for the `GoogleUserCircleAvatar` (flutter#4391)
  [in_app_purchase]IAP/platform interface add cancel status (flutter#4093)
  [image_picker] doc:readme image picker misprints (flutter#4421)
  Support Hybrid Composition through the GoogleMaps Widget (flutter#4082)
  [path_provider] started supporting background platform channels (flutter#4443)
  [device_info] started using Background Platform Channels (flutter#4456)

# Conflicts:
#	packages/webview_flutter/webview_flutter/CHANGELOG.md
#	packages/webview_flutter/webview_flutter/pubspec.yaml
stuartmorgan pushed a commit that referenced this pull request Dec 7, 2021
Implements the `loadRequest` method added in #4450 for the Android package.

Related issue:
- flutter/flutter#27730
amantoux pushed a commit to amantoux/plugins that referenced this pull request Dec 11, 2021
amantoux pushed a commit to amantoux/plugins that referenced this pull request Dec 11, 2021
…4563)

Implements the `loadRequest` method added in flutter#4450 for the Android package.

Related issue:
- flutter/flutter#27730
KyleFin pushed a commit to KyleFin/plugins that referenced this pull request Dec 21, 2021
KyleFin pushed a commit to KyleFin/plugins that referenced this pull request Dec 21, 2021
…4563)

Implements the `loadRequest` method added in flutter#4450 for the Android package.

Related issue:
- flutter/flutter#27730
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes p: webview_flutter Edits files for a webview_flutter plugin waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
4 participants