-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[webview_flutter] Update Widget Unit Tests to be platform agnostic #4489
Conversation
| expect(await controller!.currentUrl(), equals('https://flutter.io')); | ||
| }); | ||
|
|
||
| testWidgets("Can't go back before loading a page", |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
| when(mockWebViewPlatform.clearCookies()) | ||
| .thenAnswer((_) => Future<bool>.value(true)); | ||
|
|
||
| testWidgets('Second cookie clear does not have cookies', |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
As discussed in #4455 (comment), many of the unit tests for
webview_flutteruseAndroidViewandMethodChannelWebViewPlatformas default platform implementations. Sincewebview_flutteris moving away from using a defaultMethodChannelimplementation, many of the tests break when Android uses its own implementation.This PR replaces
WebView.platformwith aMockWebViewPlatformand uses aMockWebViewPlatformController.Pre-launch Checklist
dart format.)[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.