import 'dart:async'; import 'dart:collection'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_test/flutter_test.dart'; /// Returns a matcher that matches the isNullOrEmpty property. const Matcher isNullOrEmpty = _NullOrEmpty(); class _NullOrEmpty extends Matcher { const _NullOrEmpty(); @override bool matches(Object? item, Map matchState) => item == null || (item as dynamic).isEmpty; @override Description describe(Description description) => description.add('null or empty'); } class Foo { String? bar; String? baz; Foo({this.bar, this.baz}); Map toJson() { return {'bar': this.bar, 'baz': this.baz}; } } class MyInAppBrowser extends InAppBrowser { final Completer browserCreated = Completer(); final Completer firstPageLoaded = Completer(); MyInAppBrowser( {int? windowId, UnmodifiableListView? initialUserScripts}) : super(windowId: windowId, initialUserScripts: initialUserScripts); @override Future onBrowserCreated() async { browserCreated.complete(); } @override void onLoadStop(WebUri? url) { super.onLoadStop(url); if (!firstPageLoaded.isCompleted) { firstPageLoaded.complete(); } } } class MyChromeSafariBrowser extends ChromeSafariBrowser { final Completer serviceConnected = Completer(); final Completer opened = Completer(); final Completer firstPageLoaded = Completer(); final Completer closed = Completer(); final Completer navigationEvent = Completer(); final Completer relationshipValidationResult = Completer(); @override void onServiceConnected() { serviceConnected.complete(); } @override void onOpened() { opened.complete(); } @override void onCompletedInitialLoad(didLoadSuccessfully) { firstPageLoaded.complete(didLoadSuccessfully); } @override void onNavigationEvent(CustomTabsNavigationEventType? type) { if (!navigationEvent.isCompleted) { navigationEvent.complete(type); } } @override void onRelationshipValidationResult( CustomTabsRelationType? relation, Uri? requestedOrigin, bool result) { relationshipValidationResult.complete(result); } @override void onClosed() { closed.complete(); } }