This reverts commit 92ef2b9ce1.
This requires either runApp() or
WidgetsFlutterBinding.ensureInitialized() to have been called before
using any MethodChannels. Plugins broadly rely on MethodChannels and
right now there's no general requirements that they be constructed
within the runApp call, so the ecosystem breakages from this are broader
than originally thought. Reverting for now.
This commit is contained in:
committed by
GitHub
parent
77e15103da
commit
821602aef3
@@ -207,10 +207,10 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
|
||||
@override
|
||||
void initInstances() {
|
||||
super.initInstances();
|
||||
timeDilation = 1.0; // just in case the developer has artificially changed it for development
|
||||
HttpOverrides.global = _MockHttpOverrides();
|
||||
_testTextInput = TestTextInput(onCleared: _resetFocusedEditable)..register();
|
||||
super.initInstances();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -808,7 +808,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
final String assetFolderPath = Platform.environment['UNIT_TEST_ASSETS'];
|
||||
final String prefix = 'packages/${Platform.environment['APP_NAME']}/';
|
||||
|
||||
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData message) {
|
||||
defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData message) {
|
||||
String key = utf8.decode(message.buffer.asUint8List());
|
||||
File asset = File(path.join(assetFolderPath, key));
|
||||
|
||||
|
||||
@@ -36,9 +36,6 @@ class TestTextInput {
|
||||
/// first be requested, e.g. using [WidgetTester.showKeyboard].
|
||||
final VoidCallback onCleared;
|
||||
|
||||
/// The messenger which sends the bytes for this channel, not null.
|
||||
BinaryMessenger get _binaryMessenger => ServicesBinding.instance.defaultBinaryMessenger;
|
||||
|
||||
/// Installs this object as a mock handler for [SystemChannels.textInput].
|
||||
void register() {
|
||||
SystemChannels.textInput.setMockMethodCallHandler(_handleTextInputCall);
|
||||
@@ -111,7 +108,7 @@ class TestTextInput {
|
||||
// test this code does not run in a package:test test zone.
|
||||
if (_client == 0)
|
||||
throw TestFailure('Tried to use TestTextInput with no keyboard attached. You must use WidgetTester.showKeyboard() first.');
|
||||
_binaryMessenger.handlePlatformMessage(
|
||||
defaultBinaryMessenger.handlePlatformMessage(
|
||||
SystemChannels.textInput.name,
|
||||
SystemChannels.textInput.codec.encodeMethodCall(
|
||||
MethodCall(
|
||||
@@ -143,7 +140,7 @@ class TestTextInput {
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
|
||||
_binaryMessenger.handlePlatformMessage(
|
||||
defaultBinaryMessenger.handlePlatformMessage(
|
||||
SystemChannels.textInput.name,
|
||||
SystemChannels.textInput.codec.encodeMethodCall(
|
||||
MethodCall(
|
||||
|
||||
Reference in New Issue
Block a user