Skip to content

Commit 47a34f0

Browse files
committed
[webview_flutter_lwe] Add integration test based on upstream v4.13.1
Port the 'can receive url changes' NavigationDelegate test from upstream webview_flutter v4.13.1, now runnable thanks to the onUrlChange implementation. Other upstream tests not present in this suite remain omitted because the lightweight web engine does not support the required features (custom request headers, HTTP error status callback, HTTP basic auth, web storage clearing, window.open, and media playback policy).
1 parent 1df5c3d commit 47a34f0

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

packages/webview_flutter_lwe/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.4.2
22

33
* Implement `onUrlChange` for the navigation delegate.
4+
* Add 1 integration test case.
45

56
## 0.4.1
67

packages/webview_flutter_lwe/example/integration_test/webview_flutter_test.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,36 @@ Future<void> main() async {
447447
final String? currentUrl = await controller.currentUrl();
448448
expect(currentUrl, secondaryUrl);
449449
});
450+
451+
testWidgets('can receive url changes', (WidgetTester tester) async {
452+
final Completer<void> pageLoaded = Completer<void>();
453+
454+
final WebViewController controller = WebViewController();
455+
unawaited(controller.setJavaScriptMode(JavaScriptMode.unrestricted));
456+
unawaited(
457+
controller.setNavigationDelegate(
458+
NavigationDelegate(onPageFinished: (_) => pageLoaded.complete()),
459+
),
460+
);
461+
unawaited(controller.loadRequest(Uri.parse(blankPageEncoded)));
462+
463+
await tester.pumpWidget(WebViewWidget(controller: controller));
464+
465+
await pageLoaded.future;
466+
467+
final Completer<String> urlChangeCompleter = Completer<String>();
468+
await controller.setNavigationDelegate(
469+
NavigationDelegate(
470+
onUrlChange: (UrlChange change) {
471+
urlChangeCompleter.complete(change.url);
472+
},
473+
),
474+
);
475+
476+
await controller.runJavaScript('location.href = "$primaryUrl"');
477+
478+
await expectLater(urlChangeCompleter.future, completion(primaryUrl));
479+
});
450480
});
451481
}
452482

0 commit comments

Comments
 (0)