iosWebViewFix/example/integration_test/chrome_safari_browser/open_and_close.dart

56 lines
2.2 KiB
Dart
Raw Normal View History

part of 'main.dart';
2022-04-28 21:23:38 +00:00
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
skippableTest('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: [
2022-10-26 15:52:35 +00:00
AndroidResource.anim(
name: "slide_in_left", defPackage: "android"),
AndroidResource.anim(
name: "slide_out_right", defPackage: "android")
],
exitAnimations: [
2022-10-26 15:52:35 +00:00
AndroidResource.anim(
name: "abc_slide_in_top",
defPackage:
"com.pichillilorenzo.flutter_inappwebviewexample"),
2022-10-26 15:52:35 +00:00
AndroidResource.anim(
name: "abc_slide_out_top",
defPackage: "com.pichillilorenzo.flutter_inappwebviewexample")
],
keepAliveEnabled: true,
dismissButtonStyle: DismissButtonStyle.CLOSE,
2022-10-26 15:52:35 +00:00
presentationStyle: ModalPresentationStyle.OVER_FULL_SCREEN,
eventAttribution: UIEventAttribution(
sourceIdentifier: 4,
destinationURL: WebUri("https://shop.example/test.html"),
2022-10-26 15:52:35 +00:00
sourceDescription: "Banner ad for Test.",
purchaser: "Shop Example, Inc."),
activityButton: ActivityButton(
templateImage: UIImage(systemName: "sun.max"),
extensionIdentifier:
"com.pichillilorenzo.flutter-inappwebview-example7.test")));
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);
}, throwsAssertionError);
2022-04-28 21:23:38 +00:00
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);
}