Revert "Assert that runApp is called in the same zone as binding.ensureInitialized (#117113)" (#122830)

Revert "Assert that runApp is called in the same zone as binding.ensureInitialized"
This commit is contained in:
yaakovschectman
2023-03-16 20:29:13 +00:00
committed by GitHub
parent 62171dfe38
commit 5bea4d9023
14 changed files with 11 additions and 266 deletions

View File

@@ -369,13 +369,6 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
// doesn't get generated for tests.
}
@override
bool debugCheckZone(String entryPoint) {
// We skip all the zone checks in tests because the test framework makes heavy use
// of zones and so the zones never quite match the way the framework expects.
return true;
}
/// Whether there is currently a test executing.
bool get inTest;
@@ -822,9 +815,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
};
FlutterError.demangleStackTrace = (StackTrace stack) {
// package:stack_trace uses ZoneSpecification.errorCallback to add useful
// information to stack traces, meaning Trace and Chain classes can be
// present. Because these StackTrace implementations do not follow the
// format the framework expects, we convert them to a vm trace here.
// information to stack traces, in this case the Trace and Chain classes
// can be present. Because these StackTrace implementations do not follow
// the format the framework expects, we covert them to a vm trace here.
if (stack is stack_trace.Trace) {
return stack.vmTrace;
}

View File

@@ -2,38 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
// This test is very fragile and bypasses some zone-related checks.
// It is written this way to verify some invariants that would otherwise
// be difficult to check.
// Do not use this test as a guide for writing good Flutter code.
class TestBinding extends WidgetsFlutterBinding {
@override
void initInstances() {
super.initInstances();
_instance = this;
}
@override
bool debugCheckZone(String entryPoint) { return true; }
static TestBinding get instance => BindingBase.checkInstance(_instance);
static TestBinding? _instance;
static TestBinding ensureInitialized() {
if (TestBinding._instance == null) {
TestBinding();
}
return TestBinding.instance;
}
}
class CountButton extends StatefulWidget {
const CountButton({super.key});
@@ -92,8 +65,6 @@ class _AnimateSampleState extends State<AnimateSample>
}
void main() {
TestBinding.ensureInitialized();
test('Test pump on LiveWidgetController', () async {
runApp(const MaterialApp(home: Center(child: CountButton())));
@@ -138,7 +109,7 @@ void main() {
final List<PointerEventRecord> records = <PointerEventRecord>[
PointerEventRecord(Duration.zero, <PointerEvent>[
// Typically PointerAddedEvent is not used in testers, but for records
// captured on a device it is usually what starts a gesture.
// captured on a device it is usually what start a gesture.
PointerAddedEvent(
position: location,
),