Unverified Commit 07c548c6 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Apply BindingBase.checkInstance to TestDefaultBinaryMessengerBinding (#116937)

parent 865422da
...@@ -13,7 +13,7 @@ void main() { ...@@ -13,7 +13,7 @@ void main() {
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
setUp(() async { setUp(() async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
mockClipboard.handleMethodCall, mockClipboard.handleMethodCall,
); );
...@@ -23,7 +23,7 @@ void main() { ...@@ -23,7 +23,7 @@ void main() {
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
null, null,
); );
......
...@@ -159,7 +159,7 @@ class PathPointsMatcher extends Matcher { ...@@ -159,7 +159,7 @@ class PathPointsMatcher extends Matcher {
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
// Returns the first RenderEditable. // Returns the first RenderEditable.
RenderEditable findRenderEditable(WidgetTester tester) { RenderEditable findRenderEditable(WidgetTester tester) {
......
...@@ -82,7 +82,7 @@ void main() { ...@@ -82,7 +82,7 @@ void main() {
} }
setUp(() async { setUp(() async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
mockClipboard.handleMethodCall, mockClipboard.handleMethodCall,
); );
...@@ -92,7 +92,7 @@ void main() { ...@@ -92,7 +92,7 @@ void main() {
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
null, null,
); );
......
...@@ -546,7 +546,7 @@ void main() { ...@@ -546,7 +546,7 @@ void main() {
bool completed; bool completed;
completed = false; completed = false;
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData? message) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData? message) async {
expect(utf8.decode(message!.buffer.asUint8List()), 'test'); expect(utf8.decode(message!.buffer.asUint8List()), 'test');
completed = true; completed = true;
return ByteData(5); // 0x0000000000 return ByteData(5); // 0x0000000000
...@@ -573,7 +573,7 @@ void main() { ...@@ -573,7 +573,7 @@ void main() {
}); });
expect(data, isFalse); expect(data, isFalse);
expect(completed, isTrue); expect(completed, isTrue);
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', null);
}); });
test('Service extensions - exit', () async { test('Service extensions - exit', () async {
......
...@@ -16,7 +16,7 @@ void main() { ...@@ -16,7 +16,7 @@ void main() {
setUp(() async { setUp(() async {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
mockClipboard.handleMethodCall, mockClipboard.handleMethodCall,
); );
......
...@@ -27,14 +27,14 @@ void main () { ...@@ -27,14 +27,14 @@ void main () {
setUp(() { setUp(() {
semanticEvents = <Map<String, Object>>[]; semanticEvents = <Map<String, Object>>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async {
final Map<dynamic, dynamic> typedMessage = message as Map<dynamic, dynamic>; final Map<dynamic, dynamic> typedMessage = message as Map<dynamic, dynamic>;
semanticEvents.add(typedMessage.cast<String, Object>()); semanticEvents.add(typedMessage.cast<String, Object>());
}); });
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, null);
}); });
testWidgets('forTap', (WidgetTester tester) async { testWidgets('forTap', (WidgetTester tester) async {
......
...@@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
/// cannot be used in combination with other classes that do the same. /// cannot be used in combination with other classes that do the same.
class FeedbackTester { class FeedbackTester {
FeedbackTester() { FeedbackTester() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, _handler); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, _handler);
} }
/// Number of times haptic feedback was requested (vibration). /// Number of times haptic feedback was requested (vibration).
...@@ -34,7 +34,7 @@ class FeedbackTester { ...@@ -34,7 +34,7 @@ class FeedbackTester {
/// Stops tracking. /// Stops tracking.
void dispose() { void dispose() {
assert(TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.checkMockMessageHandler(SystemChannels.platform.name, _handler)); assert(TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.checkMockMessageHandler(SystemChannels.platform.name, _handler));
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
} }
} }
...@@ -17,12 +17,12 @@ void main() { ...@@ -17,12 +17,12 @@ void main() {
setUp(() async { setUp(() async {
// Fill the clipboard so that the Paste option is available in the text // Fill the clipboard so that the Paste option is available in the text
// selection menu. // selection menu.
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
await Clipboard.setData(const ClipboardData(text: 'Clipboard data')); await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
}); });
testWidgets('Changing query moves cursor to the end of query', (WidgetTester tester) async { testWidgets('Changing query moves cursor to the end of query', (WidgetTester tester) async {
......
...@@ -176,7 +176,7 @@ void main() { ...@@ -176,7 +176,7 @@ void main() {
setUp(() async { setUp(() async {
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
mockClipboard.handleMethodCall, mockClipboard.handleMethodCall,
); );
...@@ -186,7 +186,7 @@ void main() { ...@@ -186,7 +186,7 @@ void main() {
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
null, null,
); );
......
...@@ -17,7 +17,7 @@ import '../widgets/editable_text_utils.dart'; ...@@ -17,7 +17,7 @@ import '../widgets/editable_text_utils.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
setUp(() async { setUp(() async {
// Fill the clipboard so that the Paste option is available in the text // Fill the clipboard so that the Paste option is available in the text
......
...@@ -20,7 +20,7 @@ void main() { ...@@ -20,7 +20,7 @@ void main() {
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
setUp(() async { setUp(() async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler( .setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
mockClipboard.handleMethodCall, mockClipboard.handleMethodCall,
...@@ -31,7 +31,7 @@ void main() { ...@@ -31,7 +31,7 @@ void main() {
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
null, null,
); );
......
...@@ -17,7 +17,7 @@ void main() { ...@@ -17,7 +17,7 @@ void main() {
log.add(message); log.add(message);
} }
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, handleMessage); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, handleMessage);
await SemanticsService.announce('announcement 1', TextDirection.ltr); await SemanticsService.announce('announcement 1', TextDirection.ltr);
await SemanticsService.announce('announcement 2', TextDirection.rtl, assertiveness: Assertiveness.assertive); await SemanticsService.announce('announcement 2', TextDirection.rtl, assertiveness: Assertiveness.assertive);
......
...@@ -41,15 +41,15 @@ void main() { ...@@ -41,15 +41,15 @@ void main() {
group('disableContextMenu', () { group('disableContextMenu', () {
// Make sure the context menu is enabled (default) after the test. // Make sure the context menu is enabled (default) after the test.
tearDown(() async { tearDown(() async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, (MethodCall methodCall) { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, (MethodCall methodCall) {
return null; return null;
}); });
await BrowserContextMenu.enableContextMenu(); await BrowserContextMenu.enableContextMenu();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, null);
}); });
test('disableContextMenu calls its platform channel method', () async { test('disableContextMenu calls its platform channel method', () async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -58,13 +58,13 @@ void main() { ...@@ -58,13 +58,13 @@ void main() {
isMethodCall('disableContextMenu', arguments: null), isMethodCall('disableContextMenu', arguments: null),
]); ]);
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, null);
}); });
}); });
group('enableContextMenu', () { group('enableContextMenu', () {
test('enableContextMenu calls its platform channel method', () async { test('enableContextMenu calls its platform channel method', () async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -73,7 +73,7 @@ void main() { ...@@ -73,7 +73,7 @@ void main() {
isMethodCall('enableContextMenu', arguments: null), isMethodCall('enableContextMenu', arguments: null),
]); ]);
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.contextMenu, null);
}); });
}); });
}, },
......
...@@ -53,7 +53,7 @@ void main() { ...@@ -53,7 +53,7 @@ void main() {
test('can check the mock handler', () { test('can check the mock handler', () {
Future<ByteData?> handler(ByteData? call) => Future<ByteData?>.value(); Future<ByteData?> handler(ByteData? call) => Future<ByteData?>.value();
final TestDefaultBinaryMessenger messenger = TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger; final TestDefaultBinaryMessenger messenger = TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
expect(messenger.checkMockMessageHandler('test_channel', null), true); expect(messenger.checkMockMessageHandler('test_channel', null), true);
expect(messenger.checkMockMessageHandler('test_channel', handler), false); expect(messenger.checkMockMessageHandler('test_channel', handler), false);
......
...@@ -11,7 +11,7 @@ void main() { ...@@ -11,7 +11,7 @@ void main() {
test('installDeferredComponent test', () async { test('installDeferredComponent test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.deferredComponent, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.deferredComponent, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -28,7 +28,7 @@ void main() { ...@@ -28,7 +28,7 @@ void main() {
test('uninstallDeferredComponent test', () async { test('uninstallDeferredComponent test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.deferredComponent, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.deferredComponent, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
......
...@@ -151,7 +151,7 @@ class FakeAndroidViewController implements AndroidViewController { ...@@ -151,7 +151,7 @@ class FakeAndroidViewController implements AndroidViewController {
class FakeAndroidPlatformViewsController { class FakeAndroidPlatformViewsController {
FakeAndroidPlatformViewsController() { FakeAndroidPlatformViewsController() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform_views, _onMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform_views, _onMethodCall);
} }
Iterable<FakeAndroidPlatformView> get views => _views.values; Iterable<FakeAndroidPlatformView> get views => _views.values;
...@@ -370,7 +370,7 @@ class FakeAndroidPlatformViewsController { ...@@ -370,7 +370,7 @@ class FakeAndroidPlatformViewsController {
class FakeIosPlatformViewsController { class FakeIosPlatformViewsController {
FakeIosPlatformViewsController() { FakeIosPlatformViewsController() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform_views, _onMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform_views, _onMethodCall);
} }
Iterable<FakeUiKitView> get views => _views.values; Iterable<FakeUiKitView> get views => _views.values;
...@@ -473,7 +473,7 @@ class FakeIosPlatformViewsController { ...@@ -473,7 +473,7 @@ class FakeIosPlatformViewsController {
class FakeHtmlPlatformViewsController { class FakeHtmlPlatformViewsController {
FakeHtmlPlatformViewsController() { FakeHtmlPlatformViewsController() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform_views, _onMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform_views, _onMethodCall);
} }
Iterable<FakeHtmlPlatformView> get views => _views.values; Iterable<FakeHtmlPlatformView> get views => _views.values;
......
...@@ -11,7 +11,7 @@ void main() { ...@@ -11,7 +11,7 @@ void main() {
test('Haptic feedback control test', () async { test('Haptic feedback control test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -26,7 +26,7 @@ void main() { ...@@ -26,7 +26,7 @@ void main() {
Future<void> callAndVerifyHapticFunction(Future<void> Function() hapticFunction, String platformMethodArgument) async { Future<void> callAndVerifyHapticFunction(Future<void> Function() hapticFunction, String platformMethodArgument) async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
......
...@@ -14,18 +14,18 @@ void main() { ...@@ -14,18 +14,18 @@ void main() {
test('Mock binary message handler control test', () async { test('Mock binary message handler control test', () async {
final List<ByteData?> log = <ByteData>[]; final List<ByteData?> log = <ByteData>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('test1', (ByteData? message) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMessageHandler('test1', (ByteData? message) async {
log.add(message); log.add(message);
return null; return null;
}); });
final ByteData message = ByteData(2)..setUint16(0, 0xABCD); final ByteData message = ByteData(2)..setUint16(0, 0xABCD);
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.send('test1', message); await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.send('test1', message);
expect(log, equals(<ByteData>[message])); expect(log, equals(<ByteData>[message]));
log.clear(); log.clear();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('test1', null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMessageHandler('test1', null);
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.send('test1', message); await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.send('test1', message);
expect(log, isEmpty); expect(log, isEmpty);
}); });
} }
...@@ -12,7 +12,7 @@ void main() { ...@@ -12,7 +12,7 @@ void main() {
testWidgets('SystemChrome overlay style test', (WidgetTester tester) async { testWidgets('SystemChrome overlay style test', (WidgetTester tester) async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -70,7 +70,7 @@ void main() { ...@@ -70,7 +70,7 @@ void main() {
test('setPreferredOrientations control test', () async { test('setPreferredOrientations control test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -89,7 +89,7 @@ void main() { ...@@ -89,7 +89,7 @@ void main() {
test('setApplicationSwitcherDescription control test', () async { test('setApplicationSwitcherDescription control test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -108,7 +108,7 @@ void main() { ...@@ -108,7 +108,7 @@ void main() {
test('setApplicationSwitcherDescription missing plugin', () async { test('setApplicationSwitcherDescription missing plugin', () async {
final List<ByteData?> log = <ByteData>[]; final List<ByteData?> log = <ByteData>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/platform', (ByteData? message) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/platform', (ByteData? message) async {
log.add(message); log.add(message);
return null; return null;
}); });
...@@ -120,10 +120,11 @@ void main() { ...@@ -120,10 +120,11 @@ void main() {
expect(log, isNotEmpty); expect(log, isNotEmpty);
}); });
test('setEnabledSystemUIMode control test', () async { test('setEnabledSystemUIMode control test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -152,7 +153,7 @@ void main() { ...@@ -152,7 +153,7 @@ void main() {
test('setEnabledSystemUIMode passes correct overlays for manual configuration', () async { test('setEnabledSystemUIMode passes correct overlays for manual configuration', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -169,7 +170,7 @@ void main() { ...@@ -169,7 +170,7 @@ void main() {
test('setSystemUIChangeCallback control test', () async { test('setSystemUIChangeCallback control test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
......
...@@ -18,7 +18,7 @@ void main() { ...@@ -18,7 +18,7 @@ void main() {
} }
test('System navigator control test - platform messages', () async { test('System navigator control test - platform messages', () async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -27,11 +27,11 @@ void main() { ...@@ -27,11 +27,11 @@ void main() {
isMethodCall('SystemNavigator.pop', arguments: null), isMethodCall('SystemNavigator.pop', arguments: null),
]); ]);
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
}); });
test('System navigator control test - navigation messages', () async { test('System navigator control test - navigation messages', () async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
...@@ -56,6 +56,6 @@ void main() { ...@@ -56,6 +56,6 @@ void main() {
isMethodCall('routeInformationUpdated', arguments: <String, dynamic>{ 'location': 'a', 'state': true, 'replace': true }), isMethodCall('routeInformationUpdated', arguments: <String, dynamic>{ 'location': 'a', 'state': true, 'replace': true }),
]); ]);
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.navigation, null);
}); });
} }
...@@ -12,7 +12,7 @@ void main() { ...@@ -12,7 +12,7 @@ void main() {
test('System sound control test', () async { test('System sound control test', () async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
log.add(methodCall); log.add(methodCall);
return null; return null;
}); });
......
...@@ -26,12 +26,12 @@ void main() { ...@@ -26,12 +26,12 @@ void main() {
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
setUp(() async { setUp(() async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
await Clipboard.setData(const ClipboardData(text: 'empty')); await Clipboard.setData(const ClipboardData(text: 'empty'));
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
}); });
const String testText = const String testText =
......
...@@ -823,8 +823,7 @@ testWidgets('ChildBackButtonDispatcher take priority recursively', (WidgetTester ...@@ -823,8 +823,7 @@ testWidgets('ChildBackButtonDispatcher take priority recursively', (WidgetTester
testWidgets('PlatformRouteInformationProvider updates route information', (WidgetTester tester) async { testWidgets('PlatformRouteInformationProvider updates route information', (WidgetTester tester) async {
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
TestDefaultBinaryMessengerBinding TestDefaultBinaryMessengerBinding
.instance! .instance.defaultBinaryMessenger
.defaultBinaryMessenger
.setMockMethodCallHandler( .setMockMethodCallHandler(
SystemChannels.navigation, SystemChannels.navigation,
(MethodCall methodCall) async { (MethodCall methodCall) async {
......
...@@ -27,12 +27,12 @@ void main() { ...@@ -27,12 +27,12 @@ void main() {
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
setUp(() async { setUp(() async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
await Clipboard.setData(const ClipboardData(text: 'empty')); await Clipboard.setData(const ClipboardData(text: 'empty'));
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
}); });
testWidgets('mouse can select multiple widgets', (WidgetTester tester) async { testWidgets('mouse can select multiple widgets', (WidgetTester tester) async {
......
...@@ -28,12 +28,12 @@ void main() { ...@@ -28,12 +28,12 @@ void main() {
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
setUp(() async { setUp(() async {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
await Clipboard.setData(const ClipboardData(text: 'empty')); await Clipboard.setData(const ClipboardData(text: 'empty'));
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
}); });
group('SelectableRegion', () { group('SelectableRegion', () {
......
...@@ -146,7 +146,7 @@ void main() { ...@@ -146,7 +146,7 @@ void main() {
setUp(() async { setUp(() async {
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
mockClipboard.handleMethodCall, mockClipboard.handleMethodCall,
); );
...@@ -156,7 +156,7 @@ void main() { ...@@ -156,7 +156,7 @@ void main() {
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform, SystemChannels.platform,
null, null,
); );
......
...@@ -1374,11 +1374,11 @@ void main() { ...@@ -1374,11 +1374,11 @@ void main() {
group('when Clipboard fails', () { group('when Clipboard fails', () {
setUp(() { setUp(() {
final MockClipboard mockClipboard = MockClipboard(hasStringsThrows: true); final MockClipboard mockClipboard = MockClipboard(hasStringsThrows: true);
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
}); });
test('Clipboard API failure is gracefully recovered from', () async { test('Clipboard API failure is gracefully recovered from', () async {
...@@ -1394,11 +1394,11 @@ void main() { ...@@ -1394,11 +1394,11 @@ void main() {
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
setUp(() { setUp(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall);
}); });
tearDown(() { tearDown(() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);
}); });
test('update sets value based on clipboard contents', () async { test('update sets value based on clipboard contents', () async {
......
...@@ -99,7 +99,7 @@ mixin TestDefaultBinaryMessengerBinding on BindingBase, ServicesBinding { ...@@ -99,7 +99,7 @@ mixin TestDefaultBinaryMessengerBinding on BindingBase, ServicesBinding {
} }
/// The current [TestDefaultBinaryMessengerBinding], if one has been created. /// The current [TestDefaultBinaryMessengerBinding], if one has been created.
static TestDefaultBinaryMessengerBinding? get instance => _instance; static TestDefaultBinaryMessengerBinding get instance => BindingBase.checkInstance(_instance);
static TestDefaultBinaryMessengerBinding? _instance; static TestDefaultBinaryMessengerBinding? _instance;
@override @override
...@@ -775,10 +775,10 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -775,10 +775,10 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
assert(inTest); assert(inTest);
// Set the handler only if there is currently none. // Set the handler only if there is currently none.
if (TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger if (TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.checkMockMessageHandler(SystemChannels.accessibility.name, null)) { .checkMockMessageHandler(SystemChannels.accessibility.name, null)) {
_announcementHandler = _handleAnnouncementMessage; _announcementHandler = _handleAnnouncementMessage;
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockDecodedMessageHandler<dynamic>( .setMockDecodedMessageHandler<dynamic>(
SystemChannels.accessibility, _announcementHandler); SystemChannels.accessibility, _announcementHandler);
} }
...@@ -1067,10 +1067,10 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -1067,10 +1067,10 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
_parentZone = null; _parentZone = null;
buildOwner!.focusManager.dispose(); buildOwner!.focusManager.dispose();
if (TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger if (TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.checkMockMessageHandler( .checkMockMessageHandler(
SystemChannels.accessibility.name, _announcementHandler)) { SystemChannels.accessibility.name, _announcementHandler)) {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockDecodedMessageHandler(SystemChannels.accessibility, null); .setMockDecodedMessageHandler(SystemChannels.accessibility, null);
_announcementHandler = null; _announcementHandler = null;
} }
......
...@@ -27,7 +27,7 @@ extension TestBinaryMessengerExtension on BinaryMessenger { ...@@ -27,7 +27,7 @@ extension TestBinaryMessengerExtension on BinaryMessenger {
// 'This feature was deprecated after v2.1.0-10.0.pre.' // 'This feature was deprecated after v2.1.0-10.0.pre.'
// ) // )
void setMockMessageHandler(String channel, MessageHandler? handler) { void setMockMessageHandler(String channel, MessageHandler? handler) {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMessageHandler(channel, handler); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMessageHandler(channel, handler);
} }
/// Shim for `TestDefaultBinaryMessenger.checkMockMessageHandler`. /// Shim for `TestDefaultBinaryMessenger.checkMockMessageHandler`.
...@@ -38,7 +38,7 @@ extension TestBinaryMessengerExtension on BinaryMessenger { ...@@ -38,7 +38,7 @@ extension TestBinaryMessengerExtension on BinaryMessenger {
// 'This feature was deprecated after v2.1.0-10.0.pre.' // 'This feature was deprecated after v2.1.0-10.0.pre.'
// ) // )
bool checkMockMessageHandler(String channel, Object? handler) { bool checkMockMessageHandler(String channel, Object? handler) {
return TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.checkMockMessageHandler(channel, handler); return TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.checkMockMessageHandler(channel, handler);
} }
} }
...@@ -59,7 +59,7 @@ extension TestBasicMessageChannelExtension<T> on BasicMessageChannel<T> { ...@@ -59,7 +59,7 @@ extension TestBasicMessageChannelExtension<T> on BasicMessageChannel<T> {
// 'This feature was deprecated after v2.1.0-10.0.pre.' // 'This feature was deprecated after v2.1.0-10.0.pre.'
// ) // )
void setMockMessageHandler(Future<T> Function(T? message)? handler) { void setMockMessageHandler(Future<T> Function(T? message)? handler) {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockDecodedMessageHandler<T>(this, handler); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockDecodedMessageHandler<T>(this, handler);
} }
/// Shim for `TestDefaultBinaryMessenger.checkMockMessageHandler`. /// Shim for `TestDefaultBinaryMessenger.checkMockMessageHandler`.
...@@ -71,7 +71,7 @@ extension TestBasicMessageChannelExtension<T> on BasicMessageChannel<T> { ...@@ -71,7 +71,7 @@ extension TestBasicMessageChannelExtension<T> on BasicMessageChannel<T> {
// 'This feature was deprecated after v2.1.0-10.0.pre.' // 'This feature was deprecated after v2.1.0-10.0.pre.'
// ) // )
bool checkMockMessageHandler(Object? handler) { bool checkMockMessageHandler(Object? handler) {
return TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.checkMockMessageHandler(name, handler); return TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.checkMockMessageHandler(name, handler);
} }
} }
...@@ -92,7 +92,7 @@ extension TestMethodChannelExtension on MethodChannel { ...@@ -92,7 +92,7 @@ extension TestMethodChannelExtension on MethodChannel {
// 'This feature was deprecated after v2.1.0-10.0.pre.' // 'This feature was deprecated after v2.1.0-10.0.pre.'
// ) // )
void setMockMethodCallHandler(Future<dynamic>? Function(MethodCall call)? handler) { void setMockMethodCallHandler(Future<dynamic>? Function(MethodCall call)? handler) {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockMethodCallHandler(this, handler); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(this, handler);
} }
/// Shim for `TestDefaultBinaryMessenger.checkMockMessageHandler`. /// Shim for `TestDefaultBinaryMessenger.checkMockMessageHandler`.
...@@ -104,6 +104,6 @@ extension TestMethodChannelExtension on MethodChannel { ...@@ -104,6 +104,6 @@ extension TestMethodChannelExtension on MethodChannel {
// 'This feature was deprecated after v2.1.0-10.0.pre.' // 'This feature was deprecated after v2.1.0-10.0.pre.'
// ) // )
bool checkMockMethodCallHandler(Object? handler) { bool checkMockMethodCallHandler(Object? handler) {
return TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.checkMockMessageHandler(name, handler); return TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.checkMockMessageHandler(name, handler);
} }
} }
...@@ -680,7 +680,7 @@ class KeyEventSimulator { ...@@ -680,7 +680,7 @@ class KeyEventSimulator {
static Future<bool> _simulateKeyEventByRawEvent(ValueGetter<Map<String, dynamic>> buildKeyData) async { static Future<bool> _simulateKeyEventByRawEvent(ValueGetter<Map<String, dynamic>> buildKeyData) async {
return TestAsyncUtils.guard<bool>(() async { return TestAsyncUtils.guard<bool>(() async {
final Completer<bool> result = Completer<bool>(); final Completer<bool> result = Completer<bool>();
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.keyEvent.name, SystemChannels.keyEvent.name,
SystemChannels.keyEvent.codec.encodeMessage(buildKeyData()), SystemChannels.keyEvent.codec.encodeMessage(buildKeyData()),
(ByteData? data) { (ByteData? data) {
......
...@@ -205,7 +205,7 @@ class TestTextInput { ...@@ -205,7 +205,7 @@ class TestTextInput {
/// * [enterText], which is similar but takes only a String and resets the /// * [enterText], which is similar but takes only a String and resets the
/// selection. /// selection.
void updateEditingValue(TextEditingValue value) { void updateEditingValue(TextEditingValue value) {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
...@@ -229,7 +229,7 @@ class TestTextInput { ...@@ -229,7 +229,7 @@ class TestTextInput {
Future<void> receiveAction(TextInputAction action) async { Future<void> receiveAction(TextInputAction action) async {
return TestAsyncUtils.guard(() { return TestAsyncUtils.guard(() {
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
...@@ -269,7 +269,7 @@ class TestTextInput { ...@@ -269,7 +269,7 @@ class TestTextInput {
/// example when using the [integration_test] library, there is a risk that /// example when using the [integration_test] library, there is a risk that
/// the real IME will become confused as to the current state of input. /// the real IME will become confused as to the current state of input.
void closeConnection() { void closeConnection() {
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
...@@ -284,7 +284,7 @@ class TestTextInput { ...@@ -284,7 +284,7 @@ class TestTextInput {
/// Simulates a scribble interaction starting. /// Simulates a scribble interaction starting.
Future<void> startScribbleInteraction() async { Future<void> startScribbleInteraction() async {
assert(isRegistered); assert(isRegistered);
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
...@@ -299,7 +299,7 @@ class TestTextInput { ...@@ -299,7 +299,7 @@ class TestTextInput {
/// Simulates a Scribble focus. /// Simulates a Scribble focus.
Future<void> scribbleFocusElement(String elementIdentifier, Offset offset) async { Future<void> scribbleFocusElement(String elementIdentifier, Offset offset) async {
assert(isRegistered); assert(isRegistered);
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
...@@ -315,7 +315,7 @@ class TestTextInput { ...@@ -315,7 +315,7 @@ class TestTextInput {
Future<List<List<dynamic>>> scribbleRequestElementsInRect(Rect rect) async { Future<List<List<dynamic>>> scribbleRequestElementsInRect(Rect rect) async {
assert(isRegistered); assert(isRegistered);
List<List<dynamic>> response = <List<dynamic>>[]; List<List<dynamic>> response = <List<dynamic>>[];
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
...@@ -334,7 +334,7 @@ class TestTextInput { ...@@ -334,7 +334,7 @@ class TestTextInput {
/// Simulates iOS inserting a UITextPlaceholder during a long press with the pencil. /// Simulates iOS inserting a UITextPlaceholder during a long press with the pencil.
Future<void> scribbleInsertPlaceholder() async { Future<void> scribbleInsertPlaceholder() async {
assert(isRegistered); assert(isRegistered);
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
...@@ -349,7 +349,7 @@ class TestTextInput { ...@@ -349,7 +349,7 @@ class TestTextInput {
/// Simulates iOS removing a UITextPlaceholder after a long press with the pencil is released. /// Simulates iOS removing a UITextPlaceholder after a long press with the pencil is released.
Future<void> scribbleRemovePlaceholder() async { Future<void> scribbleRemovePlaceholder() async {
assert(isRegistered); assert(isRegistered);
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
MethodCall( MethodCall(
......
...@@ -26,7 +26,7 @@ class MacOSTestTextInputKeyHandler extends TestTextInputKeyHandler { ...@@ -26,7 +26,7 @@ class MacOSTestTextInputKeyHandler extends TestTextInputKeyHandler {
final int client; final int client;
Future<void> _sendSelectors(List<String> selectors) async { Future<void> _sendSelectors(List<String> selectors) async {
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.handlePlatformMessage( .handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
......
...@@ -827,7 +827,7 @@ void main() { ...@@ -827,7 +827,7 @@ void main() {
testWidgets('Returns the list of announcements', (WidgetTester tester) async { testWidgets('Returns the list of announcements', (WidgetTester tester) async {
// Make sure the handler is properly set // Make sure the handler is properly set
expect(TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger expect(TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.checkMockMessageHandler(SystemChannels.accessibility.name, null), isFalse); .checkMockMessageHandler(SystemChannels.accessibility.name, null), isFalse);
await SemanticsService.announce('announcement 1', TextDirection.ltr); await SemanticsService.announce('announcement 1', TextDirection.ltr);
...@@ -863,7 +863,7 @@ void main() { ...@@ -863,7 +863,7 @@ void main() {
log.add(message); log.add(message);
} }
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockDecodedMessageHandler<dynamic>( .setMockDecodedMessageHandler<dynamic>(
SystemChannels.accessibility, handleMessage); SystemChannels.accessibility, handleMessage);
...@@ -883,14 +883,14 @@ void main() { ...@@ -883,14 +883,14 @@ void main() {
])); ]));
// Remove the handler // Remove the handler
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockDecodedMessageHandler<dynamic>( .setMockDecodedMessageHandler<dynamic>(
SystemChannels.accessibility, null); SystemChannels.accessibility, null);
}); });
tearDown(() { tearDown(() {
// Make sure that the handler is removed in [TestWidgetsFlutterBinding.postTest] // Make sure that the handler is removed in [TestWidgetsFlutterBinding.postTest]
expect(TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger expect(TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.checkMockMessageHandler(SystemChannels.accessibility.name, null), isTrue); .checkMockMessageHandler(SystemChannels.accessibility.name, null), isTrue);
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment