From 09ed6b3e386abf52e046e75d14242ba623d1b140 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 31 Jul 2024 13:54:18 -0700 Subject: [PATCH 1/3] ++ --- lib/snapshot/pubspec.yaml | 1 + runtime/fixtures/split_lib_test.dart | 2 - .../Source/fixtures/flutter_desktop_test.dart | 18 ++-- shell/platform/windows/fixtures/main.dart | 101 ++++++++++-------- 4 files changed, 66 insertions(+), 56 deletions(-) diff --git a/lib/snapshot/pubspec.yaml b/lib/snapshot/pubspec.yaml index 0fa6a26f9ecaa..cba35438d9020 100644 --- a/lib/snapshot/pubspec.yaml +++ b/lib/snapshot/pubspec.yaml @@ -3,6 +3,7 @@ # found in the LICENSE file. # This file is needed by Fuchsia's dart_library template. +name: _snapshot_but_this_package_name_is_not_used environment: sdk: '>=3.2.0-0 <4.0.0' diff --git a/runtime/fixtures/split_lib_test.dart b/runtime/fixtures/split_lib_test.dart index 5d811fc14c374..24ca6741ea87a 100644 --- a/runtime/fixtures/split_lib_test.dart +++ b/runtime/fixtures/split_lib_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -library splitlib; - int splitAdd(int i, int j) { return i + j; } diff --git a/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart b/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart index 0f5b1ef33cde6..9563dd80e7974 100644 --- a/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart +++ b/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: avoid_print + import 'dart:io'; import 'dart:typed_data'; import 'dart:ui'; @@ -38,11 +40,11 @@ void canLogToStdout() { @pragma('vm:entry-point') void canCompositePlatformViews() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - SceneBuilder builder = SceneBuilder(); - builder.addPicture(Offset(1.0, 1.0), _createSimplePicture()); + final builder = SceneBuilder(); + builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture()); builder.pushOffset(1.0, 2.0); builder.addPlatformView(42, width: 123.0, height: 456.0); - builder.addPicture(Offset(1.0, 1.0), _createSimplePicture()); + builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture()); builder.pop(); // offset PlatformDispatcher.instance.views.first.render(builder.build()); }; @@ -53,7 +55,7 @@ void canCompositePlatformViews() { void drawIntoAllViews() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { SceneBuilder builder = SceneBuilder(); - builder.addPicture(Offset(1.0, 1.0), _createSimplePicture()); + builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture()); for (final FlutterView view in PlatformDispatcher.instance.views) { view.render(builder.build()); } @@ -63,10 +65,10 @@ void drawIntoAllViews() { /// Returns a [Picture] of a simple black square. Picture _createSimplePicture() { - Paint blackPaint = Paint(); - PictureRecorder baseRecorder = PictureRecorder(); - Canvas canvas = Canvas(baseRecorder); - canvas.drawRect(Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint); + final blackPaint = Paint(); + final baseRecorder = PictureRecorder(); + final canvas = Canvas(baseRecorder); + canvas.drawRect(const Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint); return baseRecorder.endRecording(); } diff --git a/shell/platform/windows/fixtures/main.dart b/shell/platform/windows/fixtures/main.dart index e24c9d872b87a..a50e4c6fc0455 100644 --- a/shell/platform/windows/fixtures/main.dart +++ b/shell/platform/windows/fixtures/main.dart @@ -3,10 +3,10 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:convert'; import 'dart:io' as io; -import 'dart:typed_data' show ByteData, Endian, Uint8List; +import 'dart:typed_data' show ByteData, Uint8List; import 'dart:ui' as ui; -import 'dart:convert'; // Signals a waiting latch in the native test. @pragma('vm:external-name', 'Signal') @@ -53,7 +53,7 @@ Future get semanticsChanged { } @pragma('vm:entry-point') -void sendAccessibilityAnnouncement() async { +Future sendAccessibilityAnnouncement() async { // Wait until semantics are enabled. if (!ui.PlatformDispatcher.instance.semanticsEnabled) { await semanticsChanged; @@ -91,7 +91,7 @@ void sendAccessibilityAnnouncement() async { } @pragma('vm:entry-point') -void sendAccessibilityTooltipEvent() async { +Future sendAccessibilityTooltipEvent() async { // Wait until semantics are enabled. if (!ui.PlatformDispatcher.instance.semanticsEnabled) { await semanticsChanged; @@ -129,10 +129,13 @@ void sendAccessibilityTooltipEvent() async { } @pragma('vm:entry-point') -void exitTestExit() async { +Future exitTestExit() async { final Completer closed = Completer(); - ui.channelBuffers.setListener('flutter/platform', (ByteData? data, ui.PlatformMessageResponseCallback callback) async { - final String jsonString = json.encode(>[{'response': 'exit'}]); + ui.channelBuffers.setListener('flutter/platform', + (ByteData? data, ui.PlatformMessageResponseCallback callback) async { + final String jsonString = json.encode(>[ + {'response': 'exit'} + ]); final ByteData responseData = ByteData.sublistView(utf8.encode(jsonString)); callback(responseData); closed.complete(data); @@ -141,10 +144,13 @@ void exitTestExit() async { } @pragma('vm:entry-point') -void exitTestCancel() async { +Future exitTestCancel() async { final Completer closed = Completer(); - ui.channelBuffers.setListener('flutter/platform', (ByteData? data, ui.PlatformMessageResponseCallback callback) async { - final String jsonString = json.encode(>[{'response': 'cancel'}]); + ui.channelBuffers.setListener('flutter/platform', + (ByteData? data, ui.PlatformMessageResponseCallback callback) async { + final String jsonString = json.encode(>[ + {'response': 'cancel'} + ]); final ByteData responseData = ByteData.sublistView(utf8.encode(jsonString)); callback(responseData); closed.complete(data); @@ -155,53 +161,52 @@ void exitTestCancel() async { final Completer exited = Completer(); final String jsonString = json.encode({ 'method': 'System.exitApplication', - 'args': { - 'type': 'required', 'exitCode': 0 - } - }); + 'args': {'type': 'required', 'exitCode': 0} + }); ui.PlatformDispatcher.instance.sendPlatformMessage( - 'flutter/platform', - ByteData.sublistView(utf8.encode(jsonString)), - (ByteData? reply) { - exited.complete(reply); - }); + 'flutter/platform', ByteData.sublistView(utf8.encode(jsonString)), + (ByteData? reply) { + exited.complete(reply); + }); await exited.future; } @pragma('vm:entry-point') -void enableLifecycleTest() async { +Future enableLifecycleTest() async { final Completer finished = Completer(); - ui.channelBuffers.setListener('flutter/lifecycle', (ByteData? data, ui.PlatformMessageResponseCallback callback) async { + ui.channelBuffers.setListener('flutter/lifecycle', + (ByteData? data, ui.PlatformMessageResponseCallback callback) async { if (data != null) { - ui.PlatformDispatcher.instance.sendPlatformMessage( - 'flutter/unittest', - data, - (ByteData? reply) { - finished.complete(); - }); + ui.PlatformDispatcher.instance + .sendPlatformMessage('flutter/unittest', data, (ByteData? reply) { + finished.complete(); + }); } }); await finished.future; } @pragma('vm:entry-point') -void enableLifecycleToFrom() async { - ui.channelBuffers.setListener('flutter/lifecycle', (ByteData? data, ui.PlatformMessageResponseCallback callback) async { +Future enableLifecycleToFrom() async { + ui.channelBuffers.setListener('flutter/lifecycle', + (ByteData? data, ui.PlatformMessageResponseCallback callback) async { if (data != null) { - ui.PlatformDispatcher.instance.sendPlatformMessage( - 'flutter/unittest', - data, - (ByteData? reply) {}); + ui.PlatformDispatcher.instance + .sendPlatformMessage('flutter/unittest', data, (ByteData? reply) {}); } }); final Completer enabledLifecycle = Completer(); - ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/platform', ByteData.sublistView(utf8.encode('{"method":"System.initializationComplete"}')), (ByteData? data) { + ui.PlatformDispatcher.instance.sendPlatformMessage( + 'flutter/platform', + ByteData.sublistView( + utf8.encode('{"method":"System.initializationComplete"}')), + (ByteData? data) { enabledLifecycle.complete(data); }); } @pragma('vm:entry-point') -void sendCreatePlatformViewMethod() async { +Future sendCreatePlatformViewMethod() async { // The platform view method channel uses the standard method codec. // See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/message_codecs.dart#L262 // for the implementation of the encoding and magic number identifiers. @@ -225,14 +230,15 @@ void sendCreatePlatformViewMethod() async { final Completer completed = Completer(); final ByteData bytes = ByteData.sublistView(Uint8List.fromList(data)); - ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/platform_views', bytes, (ByteData? response) { + ui.PlatformDispatcher.instance.sendPlatformMessage( + 'flutter/platform_views', bytes, (ByteData? response) { completed.complete(response); }); await completed.future; } @pragma('vm:entry-point') -void sendGetKeyboardState() async { +Future sendGetKeyboardState() async { // The keyboard method channel uses the standard method codec. // See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/message_codecs.dart#L262 // for the implementation of the encoding and magic number identifiers. @@ -250,7 +256,8 @@ void sendGetKeyboardState() async { final Completer completer = Completer(); final ByteData bytes = ByteData.sublistView(Uint8List.fromList(data)); - ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/keyboard', bytes, (ByteData? response) { + ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/keyboard', bytes, + (ByteData? response) { // For magic numbers for decoding a reply envelope, see: // https://github.com/flutter/flutter/blob/67271f69f7f88a4edba6d8023099e3bd27a072d2/packages/flutter/lib/src/services/message_codecs.dart#L577-L587 const int replyEnvelopeSuccess = 0; @@ -259,11 +266,14 @@ void sendGetKeyboardState() async { if (response == null) { signalStringValue('Unexpected null response'); } else if (response.lengthInBytes < 2) { - signalStringValue('Unexpected response length of ${response.lengthInBytes} bytes'); + signalStringValue( + 'Unexpected response length of ${response.lengthInBytes} bytes'); } else if (response.getUint8(0) != replyEnvelopeSuccess) { - signalStringValue('Unexpected response envelope status: ${response.getUint8(0)}'); + signalStringValue( + 'Unexpected response envelope status: ${response.getUint8(0)}'); } else if (response.getUint8(1) != valueMap) { - signalStringValue('Unexpected response value magic number: ${response.getUint8(1)}'); + signalStringValue( + 'Unexpected response value magic number: ${response.getUint8(1)}'); } else { signalStringValue('Success'); } @@ -287,7 +297,7 @@ void verifyNativeFunctionWithParameters() { @pragma('vm:entry-point') void verifyNativeFunctionWithReturn() { - bool value = signalBoolReturn(); + final value = signalBoolReturn(); signalBoolValue(value); } @@ -334,15 +344,14 @@ ui.Picture _createColoredBox(ui.Color color, ui.Size size) { @pragma('vm:entry-point') void renderImplicitView() { ui.PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - final ui.Size size = ui.Size(800.0, 600.0); - final ui.Color red = ui.Color.fromARGB(127, 255, 0, 0); + const ui.Size size = ui.Size(800.0, 600.0); + const ui.Color red = ui.Color.fromARGB(127, 255, 0, 0); final ui.SceneBuilder builder = ui.SceneBuilder(); builder.pushOffset(0.0, 0.0); - builder.addPicture( - ui.Offset(0.0, 0.0), _createColoredBox(red, size)); + builder.addPicture(Offset.zero, _createColoredBox(red, size)); builder.pop(); From 82682b928ab9340e7e62949be510330fe22eb2d7 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Wed, 31 Jul 2024 14:04:41 -0700 Subject: [PATCH 2/3] ++ --- .../Source/fixtures/flutter_desktop_test.dart | 11 +++++------ shell/platform/windows/fixtures/main.dart | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart b/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart index 9563dd80e7974..fce10360dea47 100644 --- a/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart +++ b/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart @@ -11,12 +11,10 @@ import 'dart:ui'; @pragma('vm:external-name', 'SignalNativeTest') external void signalNativeTest(); -void main() { -} +void main() {} @pragma('vm:entry-point') -void empty() { -} +void empty() {} /// Notifies the test of a string value. /// @@ -54,7 +52,7 @@ void canCompositePlatformViews() { @pragma('vm:entry-point') void drawIntoAllViews() { PlatformDispatcher.instance.onBeginFrame = (Duration duration) { - SceneBuilder builder = SceneBuilder(); + final builder = SceneBuilder(); builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture()); for (final FlutterView view in PlatformDispatcher.instance.views) { view.render(builder.build()); @@ -85,5 +83,6 @@ void backgroundTest() { @pragma('vm:entry-point') void sendFooMessage() { - PlatformDispatcher.instance.sendPlatformMessage('foo', null, (ByteData? result) {}); + PlatformDispatcher.instance + .sendPlatformMessage('foo', null, (ByteData? result) {}); } diff --git a/shell/platform/windows/fixtures/main.dart b/shell/platform/windows/fixtures/main.dart index a50e4c6fc0455..d786fce60fc55 100644 --- a/shell/platform/windows/fixtures/main.dart +++ b/shell/platform/windows/fixtures/main.dart @@ -7,6 +7,7 @@ import 'dart:convert'; import 'dart:io' as io; import 'dart:typed_data' show ByteData, Uint8List; import 'dart:ui' as ui; +import 'dart:ui'; // Signals a waiting latch in the native test. @pragma('vm:external-name', 'Signal') From a491f76335575e3e72cd93d7ab4a7c0b5c02879d Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Thu, 22 Aug 2024 13:02:29 -0700 Subject: [PATCH 3/3] ++ --- shell/platform/windows/fixtures/main.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shell/platform/windows/fixtures/main.dart b/shell/platform/windows/fixtures/main.dart index d786fce60fc55..721ade4b45f46 100644 --- a/shell/platform/windows/fixtures/main.dart +++ b/shell/platform/windows/fixtures/main.dart @@ -7,7 +7,6 @@ import 'dart:convert'; import 'dart:io' as io; import 'dart:typed_data' show ByteData, Uint8List; import 'dart:ui' as ui; -import 'dart:ui'; // Signals a waiting latch in the native test. @pragma('vm:external-name', 'Signal') @@ -352,7 +351,7 @@ void renderImplicitView() { builder.pushOffset(0.0, 0.0); - builder.addPicture(Offset.zero, _createColoredBox(red, size)); + builder.addPicture(ui.Offset.zero, _createColoredBox(red, size)); builder.pop();