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

Conversation

bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Nov 9, 2021

As discussed in #4455 (comment), many of the unit tests for webview_flutter use AndroidView and MethodChannelWebViewPlatform as default platform implementations. Since webview_flutter is moving away from using a default MethodChannel implementation, many of the tests break when Android uses its own implementation.

This PR replaces WebView.platform with a MockWebViewPlatform and uses a MockWebViewPlatformController.

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.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@google-cla google-cla bot added the cla: yes label Nov 9, 2021
@github-actions github-actions bot added the p: webview_flutter Edits files for a webview_flutter plugin label Nov 9, 2021
@bparrishMines bparrishMines changed the title Webview tests [webview_flutter] Update Unit Widget Tests to be platform agnostic Nov 9, 2021
@bparrishMines bparrishMines changed the title [webview_flutter] Update Unit Widget Tests to be platform agnostic [webview_flutter] Update Widget Unit Tests to be platform agnostic Nov 9, 2021

testWidgets("Can't go back before loading a page",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was removed since it only tests the behavior of a fake Platform WebView and not the behavior of the WebView widget.

expect(fakePlatformViewsController.lastCreatedView!.hasCache, false);
});

testWidgets("Can't go back with no history", (WidgetTester tester) async {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this test for the same reason as the one above.

expect(canGoBackSecondPageLoaded, true);
});

testWidgets("Can't go forward before loading a page",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this test for the same reason as the one above.


testWidgets('Second cookie clear does not have cookies',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this test for the same reason as the one above.

@stuartmorgan-g stuartmorgan-g self-requested a review November 11, 2021 21:10
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM!

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants