iosWebViewFix/example/integration_test/in_app_webview/on_progress_changed.dart

41 lines
1.2 KiB
Dart
Raw Normal View History

2022-04-28 17:29:01 +00:00
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
void onProgressChanged() {
2022-04-29 11:39:28 +00:00
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
2022-04-28 17:29:01 +00:00
testWidgets('onProgressChanged', (WidgetTester tester) async {
final Completer<void> onProgressChangedCompleter = Completer<void>();
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: InAppWebView(
key: GlobalKey(),
2022-04-29 11:39:28 +00:00
initialUrlRequest: URLRequest(url: TEST_URL_1),
2022-04-28 17:29:01 +00:00
initialSettings: InAppWebViewSettings(
clearCache: true,
),
onProgressChanged: (controller, progress) {
2022-10-06 13:13:31 +00:00
if (progress == 100 && !onProgressChangedCompleter.isCompleted) {
2022-04-28 17:29:01 +00:00
onProgressChangedCompleter.complete();
}
},
),
),
);
await expectLater(onProgressChangedCompleter.future, completes);
}, skip: shouldSkip);
}