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

@@ -5,9 +5,7 @@
import 'dart:developer' as developer;
import 'dart:isolate' as isolate;
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';
@@ -54,29 +52,3 @@ Future<void> runFrame(VoidCallback callback) {
callback();
return result;
}
// This binding skips the zones tests. These tests were written before we
// verified zones properly, and they have been legacied-in to avoid having
// to refactor them.
//
// When creating new tests, avoid relying on this class.
class ZoneIgnoringTestBinding extends WidgetsFlutterBinding {
@override
void initInstances() {
super.initInstances();
_instance = this;
}
@override
bool debugCheckZone(String entryPoint) { return true; }
static ZoneIgnoringTestBinding get instance => BindingBase.checkInstance(_instance);
static ZoneIgnoringTestBinding? _instance;
static ZoneIgnoringTestBinding ensureInitialized() {
if (ZoneIgnoringTestBinding._instance == null) {
ZoneIgnoringTestBinding();
}
return ZoneIgnoringTestBinding.instance;
}
}

View File

@@ -13,8 +13,6 @@ import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';
void main() {
LiveTestWidgetsFlutterBinding.ensureInitialized();
late VmService vmService;
late LiveTestWidgetsFlutterBinding binding;
setUpAll(() async {
@@ -29,7 +27,7 @@ void main() {
await vmService.streamListen(EventStreams.kExtension);
// Initialize bindings
binding = LiveTestWidgetsFlutterBinding.instance;
binding = LiveTestWidgetsFlutterBinding();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
binding.attachRootWidget(const SizedBox.expand());
expect(binding.framesEnabled, true);

View File

@@ -16,7 +16,7 @@ final Set<String> interestingLabels = <String>{
};
void main() {
ZoneIgnoringTestBinding.ensureInitialized();
WidgetsFlutterBinding.ensureInitialized();
initTimelineTests();
test('Children of MultiChildRenderObjectElement show up in tracing', () async {
// We don't have expectations around the first frame because there's a race around

View File

@@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'common.dart';
void main() {
ZoneIgnoringTestBinding.ensureInitialized();
WidgetsFlutterBinding.ensureInitialized();
initTimelineTests();
test('Widgets with updated keys produce well formed timelines', () async {
await runFrame(() { runApp(const TestRoot()); });

View File

@@ -58,7 +58,7 @@ class TestRootState extends State<TestRoot> {
}
void main() {
ZoneIgnoringTestBinding.ensureInitialized();
WidgetsFlutterBinding.ensureInitialized();
initTimelineTests();
test('Timeline', () async {
// We don't have expectations around the first frame because there's a race around