iosWebViewFix/example/integration_test/chrome_safari_browser/custom_action_button.dart

45 lines
1.7 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 and update icon', () 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');
var actionButtonIcon2 =
await rootBundle.load('test_assets/images/flutter-logo.jpg');
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);
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>()));
2022-04-29 00:07:01 +00:00
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
await chromeSafariBrowser.updateActionButton(
icon: actionButtonIcon2.buffer.asUint8List(),
description: 'New Action Button description');
2022-04-28 21:23:38 +00:00
await chromeSafariBrowser.close();
await chromeSafariBrowser.closed.future;
2022-04-28 21:23:38 +00:00
expect(chromeSafariBrowser.isOpened(), false);
}, skip: shouldSkip);
}