iosWebViewFix/example/integration_test/chrome_safari_browser/custom_action_button.dart

40 lines
1.4 KiB
Dart
Raw Normal View History

2022-04-28 21:23:38 +00:00
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
import '../util.dart';
void customActionButton() {
2022-04-29 00:07:01 +00:00
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
].contains(defaultTargetPlatform);
2022-04-28 21:23:38 +00:00
test('add custom action button', () async {
2022-10-08 17:07:50 +00:00
var chromeSafariBrowser = MyChromeSafariBrowser();
2022-04-28 21:23:38 +00:00
var actionButtonIcon =
2022-04-29 00:07:01 +00:00
await rootBundle.load('test_assets/images/flutter-logo.png');
2022-04-28 21:23:38 +00:00
chromeSafariBrowser.setActionButton(ChromeSafariBrowserActionButton(
id: 1,
description: 'Action Button description',
icon: actionButtonIcon.buffer.asUint8List(),
2022-10-11 14:19:36 +00:00
action: (url, title) {}));
2022-04-28 21:23:38 +00:00
expect(chromeSafariBrowser.isOpened(), false);
2022-04-29 00:07:01 +00:00
await chromeSafariBrowser.open(url: TEST_URL_1);
2022-04-28 21:23:38 +00:00
await chromeSafariBrowser.browserCreated.future;
expect(chromeSafariBrowser.isOpened(), true);
expect(() async {
await chromeSafariBrowser.open(url: TEST_CROSS_PLATFORM_URL_1);
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
2022-04-29 00:07:01 +00:00
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
2022-04-28 21:23:38 +00:00
await chromeSafariBrowser.close();
await chromeSafariBrowser.browserClosed.future;
expect(chromeSafariBrowser.isOpened(), false);
}, skip: shouldSkip);
}