diff --git a/engine/src/flutter/testing/dart/assets_test.dart b/engine/src/flutter/testing/dart/assets_test.dart index 198f952f98..21e0c7635a 100644 --- a/engine/src/flutter/testing/dart/assets_test.dart +++ b/engine/src/flutter/testing/dart/assets_test.dart @@ -70,7 +70,7 @@ void main() { /// Manually load font asset through dart. final Uint8List encoded = utf8.encoder.convert(Uri(path: Uri.encodeFull('Roboto-Medium.ttf')).path); final Completer result = Completer(); - window.sendPlatformMessage('flutter/assets', encoded.buffer.asByteData(), (ByteData? data) { + PlatformDispatcher.instance.sendPlatformMessage('flutter/assets', encoded.buffer.asByteData(), (ByteData? data) { result.complete(data!.buffer.asUint8List()); }); diff --git a/engine/src/flutter/testing/dart/color_test.dart b/engine/src/flutter/testing/dart/color_test.dart index 8876fa8da4..5d8f680cb8 100644 --- a/engine/src/flutter/testing/dart/color_test.dart +++ b/engine/src/flutter/testing/dart/color_test.dart @@ -7,7 +7,7 @@ import 'dart:ui'; import 'package:litetest/litetest.dart'; class NotAColor extends Color { - const NotAColor(int value) : super(value); + const NotAColor(super.value); } void main() { diff --git a/engine/src/flutter/testing/dart/observatory/skp_test.dart b/engine/src/flutter/testing/dart/observatory/skp_test.dart index 00c7235b2f..239e3b529f 100644 --- a/engine/src/flutter/testing/dart/observatory/skp_test.dart +++ b/engine/src/flutter/testing/dart/observatory/skp_test.dart @@ -25,7 +25,7 @@ void main() { ); final Completer completer = Completer(); - window.onBeginFrame = (Duration timeStamp) { + PlatformDispatcher.instance.onBeginFrame = (Duration timeStamp) { final PictureRecorder recorder = PictureRecorder(); final Canvas canvas = Canvas(recorder); canvas.drawRect(const Rect.fromLTRB(10, 10, 20, 20), Paint()); @@ -35,14 +35,11 @@ void main() { builder.addPicture(Offset.zero, picture); final Scene scene = builder.build(); - window.render(scene); + PlatformDispatcher.instance.implicitView!.render(scene); scene.dispose(); - // window.onBeginFrame = (Duration timeStamp) { - completer.complete(); - // }; - // window.scheduleFrame(); + completer.complete(); }; - window.scheduleFrame(); + PlatformDispatcher.instance.scheduleFrame(); await completer.future; final vms.Response response = await vmService.callServiceExtension('_flutter.screenshotSkp'); diff --git a/engine/src/flutter/testing/dart/observatory/tracing_test.dart b/engine/src/flutter/testing/dart/observatory/tracing_test.dart index 6f709bf640..9c9f961f42 100644 --- a/engine/src/flutter/testing/dart/observatory/tracing_test.dart +++ b/engine/src/flutter/testing/dart/observatory/tracing_test.dart @@ -23,7 +23,7 @@ void main() { ); final Completer completer = Completer(); - window.onBeginFrame = (Duration timeStamp) async { + PlatformDispatcher.instance.onBeginFrame = (Duration timeStamp) async { final PictureRecorder recorder = PictureRecorder(); final Canvas canvas = Canvas(recorder); canvas.drawColor(const Color(0xff0000ff), BlendMode.srcOut); @@ -45,7 +45,7 @@ void main() { scene.dispose(); completer.complete(); }; - window.scheduleFrame(); + PlatformDispatcher.instance.scheduleFrame(); await completer.future; final vms.Timeline timeline = await vmService.getVMTimeline(); diff --git a/engine/src/flutter/testing/dart/observatory/vmservice_methods_test.dart b/engine/src/flutter/testing/dart/observatory/vmservice_methods_test.dart index e74caac65b..7ba1565d0a 100644 --- a/engine/src/flutter/testing/dart/observatory/vmservice_methods_test.dart +++ b/engine/src/flutter/testing/dart/observatory/vmservice_methods_test.dart @@ -75,7 +75,7 @@ void main() { } final Completer completer = Completer(); - ui.window.onPlatformMessage = (String name, ByteData? data, ui.PlatformMessageResponseCallback? callback) { + ui.PlatformDispatcher.instance.onPlatformMessage = (String name, ByteData? data, ui.PlatformMessageResponseCallback? callback) { final ByteBuffer buffer = data!.buffer; final Uint8List list = buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); completer.complete(PlatformResponse(name: name, contents: utf8.decode(list))); diff --git a/engine/src/flutter/testing/dart/platform_view_test.dart b/engine/src/flutter/testing/dart/platform_view_test.dart index c234e63bb0..146c865899 100644 --- a/engine/src/flutter/testing/dart/platform_view_test.dart +++ b/engine/src/flutter/testing/dart/platform_view_test.dart @@ -12,7 +12,7 @@ void main() { builder.addPlatformView(1); final Scene scene = builder.build(); - window.render(scene); + PlatformDispatcher.instance.implicitView!.render(scene); scene.dispose(); // Test harness asserts that this does not emit an error from the shell logs. }); diff --git a/engine/src/flutter/testing/dart/pubspec.yaml b/engine/src/flutter/testing/dart/pubspec.yaml index 971314f032..cebfd58910 100644 --- a/engine/src/flutter/testing/dart/pubspec.yaml +++ b/engine/src/flutter/testing/dart/pubspec.yaml @@ -14,7 +14,7 @@ publish_to: none # relative to this directory into //third_party/dart environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: litetest: any diff --git a/engine/src/flutter/testing/dart/text_test.dart b/engine/src/flutter/testing/dart/text_test.dart index e0f9c825ec..db23069ce0 100644 --- a/engine/src/flutter/testing/dart/text_test.dart +++ b/engine/src/flutter/testing/dart/text_test.dart @@ -195,10 +195,10 @@ void testTextRange() { void testLoadFontFromList() { test('loadFontFromList will send platform message after font is loaded', () async { - final PlatformMessageCallback? oldHandler = window.onPlatformMessage; + final PlatformMessageCallback? oldHandler = PlatformDispatcher.instance.onPlatformMessage; late String actualName; late String message; - window.onPlatformMessage = (String name, ByteData? data, PlatformMessageResponseCallback? callback) { + PlatformDispatcher.instance.onPlatformMessage = (String name, ByteData? data, PlatformMessageResponseCallback? callback) { assert(data != null); actualName = name; final Uint8List list = data!.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); @@ -206,7 +206,7 @@ void testLoadFontFromList() { }; final Uint8List fontData = Uint8List(0); await loadFontFromList(fontData, fontFamily: 'fake'); - window.onPlatformMessage = oldHandler; + PlatformDispatcher.instance.onPlatformMessage = oldHandler; expect(actualName, 'flutter/system'); expect(message, '{"type":"fontsChange"}'); }); diff --git a/engine/src/flutter/testing/dart/window_test.dart b/engine/src/flutter/testing/dart/window_test.dart index 66bcefa130..018c72a575 100644 --- a/engine/src/flutter/testing/dart/window_test.dart +++ b/engine/src/flutter/testing/dart/window_test.dart @@ -12,7 +12,7 @@ void main() { test('window.sendPlatformMessage preserves callback zone', () { runZoned(() { final Zone innerZone = Zone.current; - window.sendPlatformMessage('test', ByteData.view(Uint8List(0).buffer), expectAsync1((ByteData? data) { + PlatformDispatcher.instance.sendPlatformMessage('test', ByteData.view(Uint8List(0).buffer), expectAsync1((ByteData? data) { final Zone runZone = Zone.current; expect(runZone, isNotNull); expect(runZone, same(innerZone)); @@ -76,7 +76,7 @@ void main() { const Locale.fromSubtags(languageCode: 'en'), ]; // The default implementation returns null due to lack of a real platform. - final Locale? result = window.computePlatformResolvedLocale(supportedLocales); + final Locale? result = PlatformDispatcher.instance.computePlatformResolvedLocale(supportedLocales); expect(result, null); }); }