2023-06-10 23:55:42 +00:00
|
|
|
part of 'main.dart';
|
2022-04-28 21:23:38 +00:00
|
|
|
|
|
|
|
void trustedWebActivity() {
|
2022-04-29 00:07:01 +00:00
|
|
|
final shouldSkip = kIsWeb
|
|
|
|
? true
|
|
|
|
: ![
|
|
|
|
TargetPlatform.android,
|
|
|
|
].contains(defaultTargetPlatform);
|
2022-04-28 21:23:38 +00:00
|
|
|
|
2023-06-10 23:55:42 +00:00
|
|
|
skippableGroup('Trusted Web Activity', () {
|
|
|
|
skippableTest('basic', () 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(
|
2023-11-12 17:56:11 +00:00
|
|
|
url: TEST_TWA_URL,
|
2022-04-28 21:23:38 +00:00
|
|
|
settings: ChromeSafariBrowserSettings(isTrustedWebActivity: true));
|
2022-10-25 09:18:53 +00:00
|
|
|
await chromeSafariBrowser.opened.future;
|
2022-04-28 21:23:38 +00:00
|
|
|
expect(chromeSafariBrowser.isOpened(), true);
|
|
|
|
expect(() async {
|
2023-11-12 17:56:11 +00:00
|
|
|
await chromeSafariBrowser.open(url: TEST_TWA_URL);
|
2023-06-10 23:55:42 +00:00
|
|
|
}, throwsAssertionError);
|
2022-04-28 21:23:38 +00:00
|
|
|
|
|
|
|
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
|
|
|
|
await chromeSafariBrowser.close();
|
2022-10-25 09:18:53 +00:00
|
|
|
await chromeSafariBrowser.closed.future;
|
2022-04-28 21:23:38 +00:00
|
|
|
expect(chromeSafariBrowser.isOpened(), false);
|
|
|
|
});
|
|
|
|
|
2023-06-10 23:55:42 +00:00
|
|
|
skippableTest('single instance', () 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(
|
2023-11-12 17:56:11 +00:00
|
|
|
url: TEST_TWA_URL,
|
2022-04-28 21:23:38 +00:00
|
|
|
settings: ChromeSafariBrowserSettings(
|
|
|
|
isTrustedWebActivity: true, isSingleInstance: true));
|
2022-10-25 09:18:53 +00:00
|
|
|
await chromeSafariBrowser.opened.future;
|
2022-04-28 21:23:38 +00:00
|
|
|
expect(chromeSafariBrowser.isOpened(), true);
|
|
|
|
expect(() async {
|
2023-11-12 17:56:11 +00:00
|
|
|
await chromeSafariBrowser.open(url: TEST_TWA_URL);
|
2023-06-10 23:55:42 +00:00
|
|
|
}, throwsAssertionError);
|
2022-04-28 21:23:38 +00:00
|
|
|
|
|
|
|
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
|
|
|
|
await chromeSafariBrowser.close();
|
2022-10-25 09:18:53 +00:00
|
|
|
await chromeSafariBrowser.closed.future;
|
|
|
|
expect(chromeSafariBrowser.isOpened(), false);
|
|
|
|
});
|
|
|
|
|
2023-06-10 23:55:42 +00:00
|
|
|
skippableTest('validate relationship', () async {
|
2022-10-25 09:18:53 +00:00
|
|
|
var chromeSafariBrowser = MyChromeSafariBrowser();
|
|
|
|
expect(chromeSafariBrowser.isOpened(), false);
|
|
|
|
|
|
|
|
await chromeSafariBrowser.open(
|
|
|
|
settings: ChromeSafariBrowserSettings(isTrustedWebActivity: true));
|
|
|
|
await chromeSafariBrowser.serviceConnected.future;
|
2022-10-26 15:52:35 +00:00
|
|
|
expect(
|
|
|
|
await chromeSafariBrowser.validateRelationship(
|
|
|
|
relation: CustomTabsRelationType.USE_AS_ORIGIN,
|
2023-11-12 17:56:11 +00:00
|
|
|
origin: TEST_TWA_URL),
|
2022-10-26 15:52:35 +00:00
|
|
|
true);
|
|
|
|
expect(
|
|
|
|
await chromeSafariBrowser.relationshipValidationResult.future, true);
|
2023-11-12 17:56:11 +00:00
|
|
|
await chromeSafariBrowser.launchUrl(url: TEST_TWA_URL);
|
2022-10-25 09:18:53 +00:00
|
|
|
await chromeSafariBrowser.opened.future;
|
|
|
|
expect(chromeSafariBrowser.isOpened(), true);
|
|
|
|
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);
|
|
|
|
}
|