iosWebViewFix/example/integration_test/chrome_safari_browser/open_and_close.dart

58 lines
2.1 KiB
Dart
Raw Normal View History

2022-04-28 21:23:38 +00:00
import 'package:flutter/foundation.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
import '../util.dart';
void openAndClose() {
2022-04-29 00:07:01 +00:00
final shouldSkip = kIsWeb
? true
2022-10-19 14:54:54 +00:00
: ![TargetPlatform.android, TargetPlatform.iOS]
.contains(defaultTargetPlatform);
2022-04-28 21:23:38 +00:00
test('open and close', () async {
2022-10-08 17:07:50 +00:00
var chromeSafariBrowser = MyChromeSafariBrowser();
2022-04-28 21:23:38 +00:00
expect(chromeSafariBrowser.isOpened(), false);
await chromeSafariBrowser.open(
url: TEST_URL_1,
settings: ChromeSafariBrowserSettings(
shareState: CustomTabsShareState.SHARE_STATE_OFF,
startAnimations: [
AndroidResource(
name: "slide_in_left",
defType: "anim",
defPackage: "android"),
AndroidResource(
name: "slide_out_right",
defType: "anim",
defPackage: "android")
],
exitAnimations: [
AndroidResource(
name: "abc_slide_in_top",
defType: "anim",
defPackage:
"com.pichillilorenzo.flutter_inappwebviewexample"),
AndroidResource(
name: "abc_slide_out_top",
defType: "anim",
defPackage: "com.pichillilorenzo.flutter_inappwebviewexample")
],
keepAliveEnabled: true,
dismissButtonStyle: DismissButtonStyle.CLOSE,
presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN));
await chromeSafariBrowser.opened.future;
2022-04-28 21:23:38 +00:00
expect(chromeSafariBrowser.isOpened(), true);
expect(() async {
await chromeSafariBrowser.open(url: TEST_CROSS_PLATFORM_URL_1);
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
await chromeSafariBrowser.close();
await chromeSafariBrowser.closed.future;
2022-04-28 21:23:38 +00:00
expect(chromeSafariBrowser.isOpened(), false);
}, skip: shouldSkip);
}