Remove single window assumption from testing/dart (flutter/engine#40160)
This commit is contained in:
committed by
GitHub
parent
b212a6f27a
commit
51a00ac884
@@ -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<Uint8List> result = Completer<Uint8List>();
|
||||
window.sendPlatformMessage('flutter/assets', encoded.buffer.asByteData(), (ByteData? data) {
|
||||
PlatformDispatcher.instance.sendPlatformMessage('flutter/assets', encoded.buffer.asByteData(), (ByteData? data) {
|
||||
result.complete(data!.buffer.asUint8List());
|
||||
});
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -25,7 +25,7 @@ void main() {
|
||||
);
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
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');
|
||||
|
||||
@@ -23,7 +23,7 @@ void main() {
|
||||
);
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
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();
|
||||
|
||||
@@ -75,7 +75,7 @@ void main() {
|
||||
}
|
||||
|
||||
final Completer<PlatformResponse> completer = Completer<PlatformResponse>();
|
||||
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)));
|
||||
|
||||
@@ -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.
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"}');
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user