From 0ffc2a12a5783de86894abbb0d86a5b711042a07 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 18 Jun 2021 16:19:01 -0700 Subject: [PATCH] Migrate //testing to nullsafety (flutter/engine#26825) --- .../src/flutter/testing/dart/canvas_test.dart | 21 ++--- .../testing/dart/channel_buffers_test.dart | 88 +++++++++---------- .../src/flutter/testing/dart/codec_test.dart | 1 - .../testing/dart/color_filter_test.dart | 11 +-- .../src/flutter/testing/dart/color_test.dart | 1 - .../testing/dart/compositing_test.dart | 63 +++++++------ .../src/flutter/testing/dart/dart_test.dart | 1 - .../flutter/testing/dart/encoding_test.dart | 11 ++- .../flutter/testing/dart/geometry_test.dart | 1 - .../flutter/testing/dart/gradient_test.dart | 3 +- .../http_allow_http_connections_test.dart | 2 - .../http_disallow_http_connections_test.dart | 2 - .../testing/dart/image_descriptor_test.dart | 1 - .../testing/dart/image_dispose_test.dart | 13 ++- .../testing/dart/image_filter_test.dart | 49 +---------- .../testing/dart/image_resize_test.dart | 7 +- .../dart/isolate_name_server_test.dart | 3 +- .../src/flutter/testing/dart/lerp_test.dart | 1 - .../src/flutter/testing/dart/locale_test.dart | 1 - .../testing/dart/observatory/skp_test.dart | 2 - .../testing/dart/paragraph_builder_test.dart | 1 - .../flutter/testing/dart/paragraph_test.dart | 1 - .../src/flutter/testing/dart/path_test.dart | 18 ++-- .../testing/dart/plugin_utilities_test.dart | 13 +-- engine/src/flutter/testing/dart/pubspec.yaml | 2 +- .../flutter/testing/dart/semantics_test.dart | 1 - .../testing/dart/spirv_exception_test.dart | 2 +- .../flutter/testing/dart/task_order_test.dart | 1 - .../src/flutter/testing/dart/text_test.dart | 12 +-- .../src/flutter/testing/dart/window_test.dart | 5 +- .../testing/smoke_test_failure/fail_test.dart | 2 - 31 files changed, 123 insertions(+), 217 deletions(-) diff --git a/engine/src/flutter/testing/dart/canvas_test.dart b/engine/src/flutter/testing/dart/canvas_test.dart index ecb48a339c..3896559ba6 100644 --- a/engine/src/flutter/testing/dart/canvas_test.dart +++ b/engine/src/flutter/testing/dart/canvas_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. -// @dart = 2.6 - import 'dart:async'; import 'dart:io'; import 'dart:typed_data'; @@ -54,8 +52,6 @@ void testNoCrashes() { final Picture picture = recorder.endRecording(); final Image image = await picture.toImage(1, 1); - try { Canvas(null, null); } catch (error) { } // ignore: empty_catches - try { Canvas(null, rect); } catch (error) { } // ignore: empty_catches try { Canvas(PictureRecorder(), null); } catch (error) { } // ignore: empty_catches try { Canvas(PictureRecorder(), rect); } catch (error) { } // ignore: empty_catches @@ -88,19 +84,18 @@ void testNoCrashes() { testCanvas((Canvas canvas) => canvas.drawRawPoints(PointMode.points, Float32List(0), paint)); testCanvas((Canvas canvas) => canvas.drawRect(rect, paint)); testCanvas((Canvas canvas) => canvas.drawRRect(rrect, paint)); - testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, null)); testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, false)); testCanvas((Canvas canvas) => canvas.drawShadow(path, color, double.nan, true)); - testCanvas((Canvas canvas) => canvas.drawVertices(Vertices(VertexMode.triangles, []), null, paint)); + testCanvas((Canvas canvas) => canvas.drawVertices(Vertices(VertexMode.triangles, []), BlendMode.screen, paint)); testCanvas((Canvas canvas) => canvas.getSaveCount()); testCanvas((Canvas canvas) => canvas.restore()); testCanvas((Canvas canvas) => canvas.rotate(double.nan)); testCanvas((Canvas canvas) => canvas.save()); testCanvas((Canvas canvas) => canvas.saveLayer(rect, paint)); - testCanvas((Canvas canvas) => canvas.saveLayer(null, null)); + testCanvas((Canvas canvas) => canvas.saveLayer(null, paint)); testCanvas((Canvas canvas) => canvas.scale(double.nan, double.nan)); testCanvas((Canvas canvas) => canvas.skew(double.nan, double.nan)); - testCanvas((Canvas canvas) => canvas.transform(null)); + testCanvas((Canvas canvas) => canvas.transform(Float64List(16))); testCanvas((Canvas canvas) => canvas.translate(double.nan, double.nan)); }); } @@ -112,8 +107,8 @@ Future fuzzyCompareImages(Image golden, Image img) async { return false; } int getPixel(ByteData data, int x, int y) => data.getUint32((x + y * golden.width) * 4); - final ByteData goldenData = await golden.toByteData(); - final ByteData imgData = await img.toByteData(); + final ByteData goldenData = (await golden.toByteData())!; + final ByteData imgData = (await img.toByteData())!; for (int y = 0; y < golden.height; y++) { for (int x = 0; x < golden.width; x++) { if (getPixel(goldenData, x, y) != getPixel(imgData, x, y)) { @@ -144,7 +139,7 @@ Future fuzzyGoldenImageCompare( } if (!areEqual) { - final ByteData pngData = await image.toByteData(format: ImageByteFormat.png); + final ByteData pngData = (await image.toByteData(format: ImageByteFormat.png))!; final String outPath = path.join(imagesPath, 'found_' + goldenImageName); File(outPath).writeAsBytesSync(pngData.buffer.asUint8List()); print('wrote: ' + outPath); @@ -231,11 +226,7 @@ void main() { canvas.drawRawAtlas(image, Float32List(0), Float32List(0), Int32List(0), BlendMode.src, null, paint); canvas.drawRawAtlas(image, Float32List(0), Float32List(0), null, null, rect, paint); - expectAssertion(() => canvas.drawAtlas(image, [transform], [rect], [color], BlendMode.src, rect, null)); expectAssertion(() => canvas.drawAtlas(image, [transform], [rect], [color], null, rect, paint)); - expectAssertion(() => canvas.drawAtlas(image, [transform], null, [color], BlendMode.src, rect, paint)); - expectAssertion(() => canvas.drawAtlas(image, null, [rect], [color], BlendMode.src, rect, paint)); - expectAssertion(() => canvas.drawAtlas(null, [transform], [rect], [color], BlendMode.src, rect, paint)); }); test('Data lengths must match for drawAtlas methods', () async { diff --git a/engine/src/flutter/testing/dart/channel_buffers_test.dart b/engine/src/flutter/testing/dart/channel_buffers_test.dart index aa715d6a10..a1495d3788 100644 --- a/engine/src/flutter/testing/dart/channel_buffers_test.dart +++ b/engine/src/flutter/testing/dart/channel_buffers_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. -// @dart = 2.6 - // KEEP THIS SYNCHRONIZED WITH ../../lib/web_ui/test/channel_buffers_test.dart import 'dart:async'; @@ -29,16 +27,15 @@ void main() { final ByteData data = _makeByteData('bar'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); bool called = false; - void callback(ByteData responseData) { + void callback(ByteData? responseData) { called = true; } buffers.push(channel, data, callback); - await buffers.drain(channel, (ByteData drainedData, ui.PlatformMessageResponseCallback drainedCallback) { + await buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { expect(drainedData, equals(data)); assert(!called); drainedCallback(drainedData); assert(called); - return; }); }); @@ -46,13 +43,13 @@ void main() { const String channel = 'foo'; final ByteData data = _makeByteData('message'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); - void callback(ByteData responseData) {} + void callback(ByteData? responseData) {} buffers.push(channel, data, callback); final List log = []; final Completer completer = Completer(); scheduleMicrotask(() { log.add('before drain, microtask'); }); log.add('before drain'); - buffers.drain(channel, (ByteData drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { + buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { log.add('callback'); completer.complete(); }); @@ -73,13 +70,12 @@ void main() { final ByteData data = _makeByteData('bar'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); - void callback(ByteData responseData) {} + void callback(ByteData? responseData) {} _resize(buffers, channel, 0); buffers.push(channel, data, callback); bool didCall = false; - await buffers.drain(channel, (ByteData drainedData, ui.PlatformMessageResponseCallback drainedCallback) { + await buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { didCall = true; - return; }); expect(didCall, equals(false)); }); @@ -88,9 +84,8 @@ void main() { const String channel = 'foo'; final ui.ChannelBuffers buffers = ui.ChannelBuffers(); bool didCall = false; - await buffers.drain(channel, (ByteData drainedData, ui.PlatformMessageResponseCallback drainedCallback) { + await buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { didCall = true; - return; }); expect(didCall, equals(false)); }); @@ -102,14 +97,14 @@ void main() { final ByteData three = _makeByteData('three'); final ByteData four = _makeByteData('four'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); - void callback(ByteData responseData) {} + void callback(ByteData? responseData) {} _resize(buffers, channel, 3); buffers.push(channel, one, callback); buffers.push(channel, two, callback); buffers.push(channel, three, callback); buffers.push(channel, four, callback); int counter = 0; - await buffers.drain(channel, (ByteData drainedData, ui.PlatformMessageResponseCallback drainedCallback) { + await buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { switch (counter) { case 0: expect(drainedData, equals(two)); @@ -122,7 +117,6 @@ void main() { break; } counter += 1; - return; }); expect(counter, equals(3)); }); @@ -133,18 +127,17 @@ void main() { final ByteData two = _makeByteData('two'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); _resize(buffers, channel, 100); - void callback(ByteData responseData) {} + void callback(ByteData? responseData) {} buffers.push(channel, one, callback); buffers.push(channel, two, callback); _resize(buffers, channel, 1); int counter = 0; - await buffers.drain(channel, (ByteData drainedData, ui.PlatformMessageResponseCallback drainedCallback) { + await buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { switch (counter) { case 0: expect(drainedData, equals(two)); } counter += 1; - return; }); expect(counter, equals(1)); }); @@ -155,11 +148,11 @@ void main() { final ByteData two = _makeByteData('two'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); bool didCallCallback = false; - void oneCallback(ByteData responseData) { + void oneCallback(ByteData? responseData) { expect(responseData, isNull); didCallCallback = true; } - void twoCallback(ByteData responseData) { + void twoCallback(ByteData? responseData) { fail('wrong callback called'); } _resize(buffers, channel, 100); @@ -176,11 +169,11 @@ void main() { final ByteData two = _makeByteData('two'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); bool didCallCallback = false; - void oneCallback(ByteData responseData) { + void oneCallback(ByteData? responseData) { expect(responseData, isNull); didCallCallback = true; } - void twoCallback(ByteData responseData) { + void twoCallback(ByteData? responseData) { fail('wrong callback called'); } _resize(buffers, channel, 1); @@ -211,37 +204,40 @@ void main() { final ByteData five = _makeByteData('five'); final ByteData six = _makeByteData('six'); final ByteData seven = _makeByteData('seven'); - buffers.push('a', one, (ByteData data) { }); - buffers.push('b', two, (ByteData data) { }); - buffers.push('a', three, (ByteData data) { }); + buffers.push('a', one, (ByteData? data) { }); + buffers.push('b', two, (ByteData? data) { }); + buffers.push('a', three, (ByteData? data) { }); log.add('top'); - buffers.setListener('a', (ByteData data, ui.PlatformMessageResponseCallback callback) { - log.add('a1: ${utf8.decode(data.buffer.asUint8List())}'); + buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { + assert(data != null); + log.add('a1: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-1'); await null; log.add('-2'); - buffers.setListener('a', (ByteData data, ui.PlatformMessageResponseCallback callback) { - log.add('a2: ${utf8.decode(data.buffer.asUint8List())}'); + buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { + assert(data != null); + log.add('a2: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-3'); await null; log.add('-4'); - buffers.setListener('b', (ByteData data, ui.PlatformMessageResponseCallback callback) { - log.add('b: ${utf8.decode(data.buffer.asUint8List())}'); + buffers.setListener('b', (ByteData? data, ui.PlatformMessageResponseCallback callback) { + assert(data != null); + log.add('b: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-5'); await null; // first microtask after setting listener drains the first message await null; // second microtask ends the draining. log.add('-6'); - buffers.push('b', four, (ByteData data) { }); - buffers.push('a', five, (ByteData data) { }); + buffers.push('b', four, (ByteData? data) { }); + buffers.push('a', five, (ByteData? data) { }); log.add('-7'); await null; log.add('-8'); buffers.clearListener('a'); - buffers.push('a', six, (ByteData data) { }); - buffers.push('b', seven, (ByteData data) { }); + buffers.push('a', six, (ByteData? data) { }); + buffers.push('b', seven, (ByteData? data) { }); await null; log.add('-9'); expect(log, [ @@ -271,24 +267,26 @@ void main() { final ByteData three = _makeByteData('three'); final ByteData four = _makeByteData('four'); buffers.handleMessage(_makeByteData('resize\ra\r10')); - buffers.push('a', one, (ByteData data) { }); - buffers.push('a', two, (ByteData data) { }); - buffers.push('a', three, (ByteData data) { }); + buffers.push('a', one, (ByteData? data) { }); + buffers.push('a', two, (ByteData? data) { }); + buffers.push('a', three, (ByteData? data) { }); log.add('-1'); - buffers.setListener('a', (ByteData data, ui.PlatformMessageResponseCallback callback) { - log.add('a1: ${utf8.decode(data.buffer.asUint8List())}'); + buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { + assert(data != null); + log.add('a1: ${utf8.decode(data!.buffer.asUint8List())}'); }); await null; // handles one log.add('-2'); buffers.clearListener('a'); await null; log.add('-3'); - buffers.setListener('a', (ByteData data, ui.PlatformMessageResponseCallback callback) { - log.add('a2: ${utf8.decode(data.buffer.asUint8List())}'); + buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { + assert(data != null); + log.add('a2: ${utf8.decode(data!.buffer.asUint8List())}'); }); log.add('-4'); await null; - buffers.push('a', four, (ByteData data) { }); + buffers.push('a', four, (ByteData? data) { }); log.add('-5'); await null; log.add('-6'); @@ -337,14 +335,14 @@ void main() { final Zone zone2 = Zone.current.fork(); zone1.run(() { log.add('first zone run: ${Zone.current == zone1}'); - buffers.setListener('a', (ByteData data, ui.PlatformMessageResponseCallback callback) { + buffers.setListener('a', (ByteData? data, ui.PlatformMessageResponseCallback callback) { log.add('callback1: ${Zone.current == zone1}'); callback(data); }); }); zone2.run(() { log.add('second zone run: ${Zone.current == zone2}'); - buffers.push('a', ByteData.sublistView(Uint8List.fromList([]), 0, 0), (ByteData data) { + buffers.push('a', ByteData.sublistView(Uint8List.fromList([]), 0, 0), (ByteData? data) { log.add('callback2: ${Zone.current == zone2}'); }); }); diff --git a/engine/src/flutter/testing/dart/codec_test.dart b/engine/src/flutter/testing/dart/codec_test.dart index a06a579818..86ce31a8d6 100644 --- a/engine/src/flutter/testing/dart/codec_test.dart +++ b/engine/src/flutter/testing/dart/codec_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:io'; import 'dart:typed_data'; import 'dart:ui' as ui; diff --git a/engine/src/flutter/testing/dart/color_filter_test.dart b/engine/src/flutter/testing/dart/color_filter_test.dart index c804c47541..9fb5869806 100644 --- a/engine/src/flutter/testing/dart/color_filter_test.dart +++ b/engine/src/flutter/testing/dart/color_filter_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:typed_data'; import 'dart:ui'; @@ -36,20 +35,12 @@ void main() { recorderCanvas.drawPaint(paint); final Picture picture = recorder.endRecording(); final Image image = await picture.toImage(width, height); - final ByteData bytes = await image.toByteData(); + final ByteData bytes = (await image.toByteData())!; expect(bytes.lengthInBytes, width * height * 4); return bytes.buffer.asUint32List(); } - test('ColorFilter - nulls', () async { - final Paint paint = Paint()..colorFilter = const ColorFilter.mode(null, null); - expect(paint.colorFilter, null); - - paint.colorFilter = const ColorFilter.matrix(null); - expect(paint.colorFilter, null); - }); - test('ColorFilter - mode', () async { final Paint paint = Paint() ..color = green diff --git a/engine/src/flutter/testing/dart/color_test.dart b/engine/src/flutter/testing/dart/color_test.dart index f1a24b803e..55105ed80f 100644 --- a/engine/src/flutter/testing/dart/color_test.dart +++ b/engine/src/flutter/testing/dart/color_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:ui'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/compositing_test.dart b/engine/src/flutter/testing/dart/compositing_test.dart index 48fe5b7756..a6f0d09479 100644 --- a/engine/src/flutter/testing/dart/compositing_test.dart +++ b/engine/src/flutter/testing/dart/compositing_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:typed_data' show Float64List; import 'dart:ui'; @@ -292,28 +291,28 @@ void main() { } test('SceneBuilder does not share a layer between addRetained and push*', () { - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushOffset(0, 0, oldLayer: oldLayer as OffsetEngineLayer); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushOffset(0, 0, oldLayer: oldLayer as OffsetEngineLayer?); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushTransform(Float64List(16), oldLayer: oldLayer as TransformEngineLayer); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushTransform(Float64List(16), oldLayer: oldLayer as TransformEngineLayer?); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushClipRect(Rect.zero, oldLayer: oldLayer as ClipRectEngineLayer); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushClipRect(Rect.zero, oldLayer: oldLayer as ClipRectEngineLayer?); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushClipRRect(RRect.zero, oldLayer: oldLayer as ClipRRectEngineLayer); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushClipRRect(RRect.zero, oldLayer: oldLayer as ClipRRectEngineLayer?); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushClipPath(Path(), oldLayer: oldLayer as ClipPathEngineLayer); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushClipPath(Path(), oldLayer: oldLayer as ClipPathEngineLayer?); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushOpacity(100, oldLayer: oldLayer as OpacityEngineLayer); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushOpacity(100, oldLayer: oldLayer as OpacityEngineLayer?); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushBackdropFilter(ImageFilter.blur(), oldLayer: oldLayer as BackdropFilterEngineLayer); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushBackdropFilter(ImageFilter.blur(), oldLayer: oldLayer as BackdropFilterEngineLayer?); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { return builder.pushShaderMask( Gradient.radial( const Offset(0, 0), @@ -322,22 +321,22 @@ void main() { ), Rect.zero, BlendMode.color, - oldLayer: oldLayer as ShaderMaskEngineLayer, + oldLayer: oldLayer as ShaderMaskEngineLayer?, ); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { - return builder.pushPhysicalShape(path: Path(), color: const Color.fromARGB(0, 0, 0, 0), oldLayer: oldLayer as PhysicalShapeEngineLayer, elevation: 0.0); + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { + return builder.pushPhysicalShape(path: Path(), color: const Color.fromARGB(0, 0, 0, 0), oldLayer: oldLayer as PhysicalShapeEngineLayer?, elevation: 0.0); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { return builder.pushColorFilter( const ColorFilter.mode( Color.fromARGB(0, 0, 0, 0), BlendMode.color, ), - oldLayer: oldLayer as ColorFilterEngineLayer, + oldLayer: oldLayer as ColorFilterEngineLayer?, ); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { return builder.pushColorFilter( const ColorFilter.matrix([ 1, 0, 0, 0, 0, @@ -345,28 +344,28 @@ void main() { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, ]), - oldLayer: oldLayer as ColorFilterEngineLayer, + oldLayer: oldLayer as ColorFilterEngineLayer?, ); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { return builder.pushColorFilter( const ColorFilter.linearToSrgbGamma(), - oldLayer: oldLayer as ColorFilterEngineLayer, + oldLayer: oldLayer as ColorFilterEngineLayer?, ); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { return builder.pushColorFilter( const ColorFilter.srgbToLinearGamma(), - oldLayer: oldLayer as ColorFilterEngineLayer, + oldLayer: oldLayer as ColorFilterEngineLayer?, ); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { return builder.pushImageFilter( ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), - oldLayer: oldLayer as ImageFilterEngineLayer, + oldLayer: oldLayer as ImageFilterEngineLayer?, ); }); - testNoSharing((SceneBuilder builder, EngineLayer oldLayer) { + testNoSharing((SceneBuilder builder, EngineLayer? oldLayer) { return builder.pushImageFilter( ImageFilter.matrix(Float64List.fromList([ 1, 0, 0, 0, @@ -374,10 +373,10 @@ void main() { 0, 0, 1, 0, 0, 0, 0, 1, ])), - oldLayer: oldLayer as ImageFilterEngineLayer, + oldLayer: oldLayer as ImageFilterEngineLayer?, ); }); }); } -typedef _TestNoSharingFunction = EngineLayer Function(SceneBuilder builder, EngineLayer oldLayer); +typedef _TestNoSharingFunction = EngineLayer Function(SceneBuilder builder, EngineLayer? oldLayer); diff --git a/engine/src/flutter/testing/dart/dart_test.dart b/engine/src/flutter/testing/dart/dart_test.dart index a58389691c..4979efe37c 100644 --- a/engine/src/flutter/testing/dart/dart_test.dart +++ b/engine/src/flutter/testing/dart/dart_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:async'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/encoding_test.dart b/engine/src/flutter/testing/dart/encoding_test.dart index f24bfbfde3..52559f297a 100644 --- a/engine/src/flutter/testing/dart/encoding_test.dart +++ b/engine/src/flutter/testing/dart/encoding_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:async'; import 'dart:io'; import 'dart:typed_data'; @@ -20,13 +19,13 @@ const Color _kGreen = Color.fromRGBO(0, 255, 0, 1.0); void main() { test('Image.toByteData RGBA format works with simple image', () async { final Image image = await Square4x4Image.image; - final ByteData data = await image.toByteData(); + final ByteData data = (await image.toByteData())!; expect(Uint8List.view(data.buffer), Square4x4Image.bytes); }); test('Image.toByteData RGBA format converts grayscale images', () async { final Image image = await GrayscaleImage.load(); - final ByteData data = await image.toByteData(); + final ByteData data = (await image.toByteData())!; final Uint8List bytes = data.buffer.asUint8List(); expect(bytes, hasLength(16)); expect(bytes, GrayscaleImage.bytesAsRgba); @@ -34,13 +33,13 @@ void main() { test('Image.toByteData Unmodified format works with simple image', () async { final Image image = await Square4x4Image.image; - final ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified); + final ByteData data = (await image.toByteData(format: ImageByteFormat.rawUnmodified))!; expect(Uint8List.view(data.buffer), Square4x4Image.bytes); }); test('Image.toByteData Unmodified format works with grayscale images', () async { final Image image = await GrayscaleImage.load(); - final ByteData data = await image.toByteData(format: ImageByteFormat.rawUnmodified); + final ByteData data = (await image.toByteData(format: ImageByteFormat.rawUnmodified))!; final Uint8List bytes = data.buffer.asUint8List(); expect(bytes, hasLength(4)); expect(bytes, GrayscaleImage.bytesUnmodified); @@ -48,7 +47,7 @@ void main() { test('Image.toByteData PNG format works with simple image', () async { final Image image = await Square4x4Image.image; - final ByteData data = await image.toByteData(format: ImageByteFormat.png); + final ByteData data = (await image.toByteData(format: ImageByteFormat.png))!; final List expected = await readFile('square.png'); expect(Uint8List.view(data.buffer), expected); }); diff --git a/engine/src/flutter/testing/dart/geometry_test.dart b/engine/src/flutter/testing/dart/geometry_test.dart index 7959d5f1ff..73010b19fd 100644 --- a/engine/src/flutter/testing/dart/geometry_test.dart +++ b/engine/src/flutter/testing/dart/geometry_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:math' as math show sqrt; import 'dart:math' show pi; import 'dart:ui'; diff --git a/engine/src/flutter/testing/dart/gradient_test.dart b/engine/src/flutter/testing/dart/gradient_test.dart index 0d5b32563b..1c1c92f922 100644 --- a/engine/src/flutter/testing/dart/gradient_test.dart +++ b/engine/src/flutter/testing/dart/gradient_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:ui'; import 'package:litetest/litetest.dart'; @@ -12,7 +11,7 @@ void main() { expect( Gradient.radial( Offset.zero, - null, + 0.0, [const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)], [0.0, 1.0], TileMode.mirror), diff --git a/engine/src/flutter/testing/dart/http_allow_http_connections_test.dart b/engine/src/flutter/testing/dart/http_allow_http_connections_test.dart index 299dd3cee6..165b50d53c 100644 --- a/engine/src/flutter/testing/dart/http_allow_http_connections_test.dart +++ b/engine/src/flutter/testing/dart/http_allow_http_connections_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. -// @dart = 2.9 - import 'dart:async'; import 'dart:io'; diff --git a/engine/src/flutter/testing/dart/http_disallow_http_connections_test.dart b/engine/src/flutter/testing/dart/http_disallow_http_connections_test.dart index cc740d5887..f9b8e4ebd5 100644 --- a/engine/src/flutter/testing/dart/http_disallow_http_connections_test.dart +++ b/engine/src/flutter/testing/dart/http_disallow_http_connections_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. -// @dart = 2.9 - // FlutterTesterOptions=--disallow-insecure-connections import 'dart:async'; diff --git a/engine/src/flutter/testing/dart/image_descriptor_test.dart b/engine/src/flutter/testing/dart/image_descriptor_test.dart index 499ace6ddf..a032fafe7b 100644 --- a/engine/src/flutter/testing/dart/image_descriptor_test.dart +++ b/engine/src/flutter/testing/dart/image_descriptor_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:async'; import 'dart:io'; import 'dart:typed_data'; diff --git a/engine/src/flutter/testing/dart/image_dispose_test.dart b/engine/src/flutter/testing/dart/image_dispose_test.dart index 4955d80de1..d1c1d308cd 100644 --- a/engine/src/flutter/testing/dart/image_dispose_test.dart +++ b/engine/src/flutter/testing/dart/image_dispose_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:io'; import 'dart:typed_data'; import 'dart:ui'; @@ -58,9 +57,9 @@ void main() { final Picture picture = recorder.endRecording(); final Image rasterizedImage = await picture.toImage(2, 2); - final ByteData sourceData = await frame.image.toByteData(); - final ByteData handleData = await handle1.toByteData(); - final ByteData rasterizedData = await rasterizedImage.toByteData(); + final ByteData sourceData = (await frame.image.toByteData())!; + final ByteData handleData = (await handle1.toByteData())!; + final ByteData rasterizedData = (await rasterizedImage.toByteData())!; expect(sourceData.buffer.asUint8List(), equals(handleData.buffer.asUint8List())); expect(sourceData.buffer.asUint8List(), equals(rasterizedData.buffer.asUint8List())); @@ -74,17 +73,17 @@ void main() { final Image handle1 = frame.image.clone(); final Image handle2 = handle1.clone(); - List stackTraces = frame.image.debugGetOpenHandleStackTraces(); + List stackTraces = (frame.image.debugGetOpenHandleStackTraces())!; expect(stackTraces.length, 3); expect(stackTraces, equals(handle1.debugGetOpenHandleStackTraces())); handle1.dispose(); - stackTraces = frame.image.debugGetOpenHandleStackTraces(); + stackTraces = (frame.image.debugGetOpenHandleStackTraces())!; expect(stackTraces.length, 2); expect(stackTraces, equals(handle2.debugGetOpenHandleStackTraces())); handle2.dispose(); - stackTraces = frame.image.debugGetOpenHandleStackTraces(); + stackTraces = (frame.image.debugGetOpenHandleStackTraces())!; expect(stackTraces.length, 1); expect(stackTraces, equals(frame.image.debugGetOpenHandleStackTraces())); diff --git a/engine/src/flutter/testing/dart/image_filter_test.dart b/engine/src/flutter/testing/dart/image_filter_test.dart index 0abbe86b67..87af30ab6e 100644 --- a/engine/src/flutter/testing/dart/image_filter_test.dart +++ b/engine/src/flutter/testing/dart/image_filter_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:typed_data'; import 'dart:ui'; @@ -54,7 +53,7 @@ void main() { recorderCanvas.drawRect(const Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), paint); final Picture picture = recorder.endRecording(); final Image image = await picture.toImage(width, height); - final ByteData bytes = await image.toByteData(); + final ByteData bytes = (await image.toByteData())!; expect(bytes.lengthInBytes, equals(width * height * 4)); return bytes.buffer.asUint32List(); @@ -66,7 +65,7 @@ void main() { recorderCanvas.drawPaint(paint); final Picture picture = recorder.endRecording(); final Image image = await picture.toImage(width, height); - final ByteData bytes = await image.toByteData(); + final ByteData bytes = (await image.toByteData())!; expect(bytes.lengthInBytes, width * height * 4); return bytes.buffer.asUint32List(); @@ -91,11 +90,9 @@ void main() { List colorFilters() { // Create new color filter instances on each invocation. return [ // ignore: prefer_const_constructors - ColorFilter.mode(null, null), // ignore: prefer_const_constructors ColorFilter.mode(green, BlendMode.color), // ignore: prefer_const_constructors ColorFilter.mode(red, BlendMode.color), // ignore: prefer_const_constructors ColorFilter.mode(red, BlendMode.screen), // ignore: prefer_const_constructors - ColorFilter.matrix(null), // ignore: prefer_const_constructors ColorFilter.matrix(grayscaleColorMatrix), // ignore: prefer_const_constructors ColorFilter.linearToSrgbGamma(), // ignore: prefer_const_constructors ColorFilter.srgbToLinearGamma(), // ignore: prefer_const_constructors @@ -199,20 +196,6 @@ void main() { expect(filter.toString(), originalDescription); }); - test('ImageFilter - null color filters do not throw', () { - dynamic error; - final Paint paint = Paint(); - try { - paint - ..color = green - ..imageFilter = const ColorFilter.mode(null, null); - } catch (e) { - error = e; - } - - expect(error, isNull); - }); - test('ImageFilter - from color filters', () async { final Paint paint = Paint() ..color = green @@ -222,30 +205,6 @@ void main() { expect(bytes[0], 0xFF020202); }); - test('ImageFilter - null filter composition', () async { - const ImageFilter nullFilter = ColorFilter.mode(null, null); - const ImageFilter identityFilter = ColorFilter.matrix(identityColorMatrix); - - // Verify that null filter == identity. - Future verifyAgainst(ImageFilter filter) async { - final ImageFilter comp0 = ImageFilter.compose(outer: filter, inner: identityFilter); - final ImageFilter comp1 = ImageFilter.compose(outer: filter, inner: nullFilter); - final ImageFilter comp2 = ImageFilter.compose(outer: nullFilter, inner: filter); - final Paint paint = Paint()..color = green; - - paint.imageFilter = comp0; - final Uint32List bytes = await getBytesForColorPaint(paint); - - paint.imageFilter = comp1; - expect(bytes, equals(await getBytesForColorPaint(paint))); - - paint.imageFilter = comp2; - expect(bytes, equals(await getBytesForColorPaint(paint))); - } - - makeList().forEach(verifyAgainst); - }); - test('ImageFilter - color filter composition', () async { final ImageFilter compOrder1 = ImageFilter.compose( outer: const ColorFilter.matrix(halvesBrightnessColorMatrix), @@ -282,13 +241,13 @@ void main() { ImageFilter.compose( outer: ImageFilter.compose(outer: makeBlur(30.0, 30.0, TileMode.mirror), inner: makeBlur(20.0, 20.0, TileMode.repeated)), inner: ImageFilter.compose( - outer: const ColorFilter.mode(null, null), + outer: const ColorFilter.mode(Color(0xFFABCDEF), BlendMode.color), inner: makeScale(10.0, 10.0), ), ).toString(), contains( 'matrix([10.0, 0.0, 0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.0, -0.0, 0.0, 1.0], FilterQuality.low) -> ' - 'ColorFilter.mode(null, null) -> ' + 'ColorFilter.mode(Color(0xffabcdef), BlendMode.color) -> ' 'blur(20.0, 20.0, repeated) -> ' 'blur(30.0, 30.0, mirror)' ), diff --git a/engine/src/flutter/testing/dart/image_resize_test.dart b/engine/src/flutter/testing/dart/image_resize_test.dart index cd2b090f95..3ea8a1010c 100644 --- a/engine/src/flutter/testing/dart/image_resize_test.dart +++ b/engine/src/flutter/testing/dart/image_resize_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:async'; import 'dart:io'; import 'dart:typed_data'; @@ -127,7 +126,7 @@ void main() { blackSquare.width, blackSquare.height, PixelFormat.rgba8888, - (Image image) => null, + (Image image) {}, targetHeight: 10, allowUpscaling: false, ); @@ -155,7 +154,7 @@ void main() { blackSquare.width, blackSquare.height, PixelFormat.rgba8888, - (Image image) => null, + (Image image) {}, targetHeight: 10, targetWidth: 1, allowUpscaling: false, @@ -184,7 +183,7 @@ class BlackSquare { return BlackSquare._(width, height, pixels); } - Future resize({int targetWidth, int targetHeight, bool allowUpscaling = false}) async { + Future resize({int? targetWidth, int? targetHeight, bool allowUpscaling = false}) async { final Completer imageCompleter = Completer(); decodeImageFromPixels( pixels, diff --git a/engine/src/flutter/testing/dart/isolate_name_server_test.dart b/engine/src/flutter/testing/dart/isolate_name_server_test.dart index 78cb358933..bad6c7acaa 100644 --- a/engine/src/flutter/testing/dart/isolate_name_server_test.dart +++ b/engine/src/flutter/testing/dart/isolate_name_server_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:async'; import 'dart:isolate'; import 'dart:ui'; @@ -28,7 +27,7 @@ void isolateSpawnEntrypoint(IsolateSpawnInfo info) { port.send([code, message]); } - final SendPort shared = IsolateNameServer.lookupPortByName(portName); + final SendPort? shared = IsolateNameServer.lookupPortByName(portName); if (shared == null) { sendHelper(kErrorCode, 'Could not find port: $portName'); return; diff --git a/engine/src/flutter/testing/dart/lerp_test.dart b/engine/src/flutter/testing/dart/lerp_test.dart index d096c1efef..b3ce4e2f8c 100644 --- a/engine/src/flutter/testing/dart/lerp_test.dart +++ b/engine/src/flutter/testing/dart/lerp_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.10 import 'dart:ui'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/locale_test.dart b/engine/src/flutter/testing/dart/locale_test.dart index 064301ce97..efef6ea857 100644 --- a/engine/src/flutter/testing/dart/locale_test.dart +++ b/engine/src/flutter/testing/dart/locale_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:ui'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/observatory/skp_test.dart b/engine/src/flutter/testing/dart/observatory/skp_test.dart index 574ac6a19c..0303702c7a 100644 --- a/engine/src/flutter/testing/dart/observatory/skp_test.dart +++ b/engine/src/flutter/testing/dart/observatory/skp_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. -// @dart=2.12 - import 'dart:async'; import 'dart:convert'; import 'dart:developer' as developer; diff --git a/engine/src/flutter/testing/dart/paragraph_builder_test.dart b/engine/src/flutter/testing/dart/paragraph_builder_test.dart index dc2fdeac54..d7a6ebc875 100644 --- a/engine/src/flutter/testing/dart/paragraph_builder_test.dart +++ b/engine/src/flutter/testing/dart/paragraph_builder_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:ui'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/paragraph_test.dart b/engine/src/flutter/testing/dart/paragraph_test.dart index e95ede0fad..61cd0bedfd 100644 --- a/engine/src/flutter/testing/dart/paragraph_test.dart +++ b/engine/src/flutter/testing/dart/paragraph_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:ui'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/path_test.dart b/engine/src/flutter/testing/dart/path_test.dart index cb754247ad..a707f063e5 100644 --- a/engine/src/flutter/testing/dart/path_test.dart +++ b/engine/src/flutter/testing/dart/path_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:typed_data' show Float64List; import 'dart:ui'; @@ -130,8 +129,7 @@ void main() { expect(simpleHorizontalMetrics.iterator.current.isClosed, isFalse); final Path simpleExtract = simpleHorizontalMetrics.iterator.current.extractPath(1.0, 9.0); expect(simpleExtract.getBounds(), equals(const Rect.fromLTRB(1.0, 0.0, 9.0, 0.0))); - final Tangent posTan = simpleHorizontalMetrics.iterator.current.getTangentForOffset(1.0); - expect(posTan, isNotNull); + final Tangent posTan = simpleHorizontalMetrics.iterator.current.getTangentForOffset(1.0)!; expect(posTan.position, equals(const Offset(1.0, 0.0))); expect(posTan.angle, equals(0.0)); @@ -152,7 +150,7 @@ void main() { // test getTangentForOffset with vertical line final Path simpleVerticalLine = Path()..lineTo(0.0, 10.0); final PathMetrics simpleMetricsVertical = simpleVerticalLine.computeMetrics()..iterator.moveNext(); - final Tangent posTanVertical = simpleMetricsVertical.iterator.current.getTangentForOffset(5.0); + final Tangent posTanVertical = simpleMetricsVertical.iterator.current.getTangentForOffset(5.0)!; expect(posTanVertical.position, equals(const Offset(0.0, 5.0))); expect(posTanVertical.angle, closeTo(-1.5708, .0001)); // 90 degrees @@ -160,7 +158,7 @@ void main() { final Path simpleDiagonalLine = Path()..lineTo(10.0, 10.0); final PathMetrics simpleMetricsDiagonal = simpleDiagonalLine.computeMetrics()..iterator.moveNext(); final double midPoint = simpleMetricsDiagonal.iterator.current.length / 2; - final Tangent posTanDiagonal = simpleMetricsDiagonal.iterator.current.getTangentForOffset(midPoint); + final Tangent posTanDiagonal = simpleMetricsDiagonal.iterator.current.getTangentForOffset(midPoint)!; expect(posTanDiagonal.position, equals(const Offset(5.0, 5.0))); expect(posTanDiagonal.angle, closeTo(-0.7853981633974483, .00001)); // ~45 degrees @@ -191,11 +189,11 @@ void main() { expect(metrics.length, 2); expect(metrics[0].length, 20); expect(metrics[0].isClosed, true); - expect(metrics[0].getTangentForOffset(4.0).vector, const Offset(0.0, 1.0)); + expect(metrics[0].getTangentForOffset(4.0)!.vector, const Offset(0.0, 1.0)); expect(metrics[0].extractPath(4.0, 10.0).computeMetrics().first.length, 6.0); expect(metrics[1].length, 10); expect(metrics[1].isClosed, false); - expect(metrics[1].getTangentForOffset(4.0).vector, const Offset(1.0, 0.0)); + expect(metrics[1].getTangentForOffset(4.0)!.vector, const Offset(1.0, 0.0)); expect(metrics[1].extractPath(4.0, 6.0).computeMetrics().first.length, 2.0); }); @@ -207,7 +205,7 @@ void main() { expect(metrics, isEmpty); expect(firstMetric.length, 10); expect(firstMetric.isClosed, false); - expect(firstMetric.getTangentForOffset(4.0).vector, const Offset(0.0, 1.0)); + expect(firstMetric.getTangentForOffset(4.0)!.vector, const Offset(0.0, 1.0)); expect(firstMetric.extractPath(4.0, 10.0).computeMetrics().first.length, 6.0); path..lineTo(10, 10)..lineTo(10, 0)..close(); @@ -215,7 +213,7 @@ void main() { expect(metrics, isEmpty); expect(firstMetric.length, 10); expect(firstMetric.isClosed, false); - expect(firstMetric.getTangentForOffset(4.0).vector, const Offset(0.0, 1.0)); + expect(firstMetric.getTangentForOffset(4.0)!.vector, const Offset(0.0, 1.0)); expect(firstMetric.extractPath(4.0, 10.0).computeMetrics().first.length, 6.0); // getting a new iterator should update us. @@ -224,7 +222,7 @@ void main() { expect(newMetrics, isEmpty); expect(newFirstMetric.length, 40); expect(newFirstMetric.isClosed, true); - expect(newFirstMetric.getTangentForOffset(4.0).vector, const Offset(0.0, 1.0)); + expect(newFirstMetric.getTangentForOffset(4.0)!.vector, const Offset(0.0, 1.0)); expect(newFirstMetric.extractPath(4.0, 10.0).computeMetrics().first.length, 6.0); }); } diff --git a/engine/src/flutter/testing/dart/plugin_utilities_test.dart b/engine/src/flutter/testing/dart/plugin_utilities_test.dart index e9be4f761b..34684e05bd 100644 --- a/engine/src/flutter/testing/dart/plugin_utilities_test.dart +++ b/engine/src/flutter/testing/dart/plugin_utilities_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:ui'; import 'package:litetest/litetest.dart'; @@ -20,21 +19,17 @@ const Foo foo = Foo(); void main() { test('PluginUtilities Callback Handles', () { // Top level callback. - final CallbackHandle hTop = PluginUtilities.getCallbackHandle(top); - expect(hTop, isNotNull); + final CallbackHandle hTop = PluginUtilities.getCallbackHandle(top)!; expect(hTop, notEquals(0)); expect(PluginUtilities.getCallbackHandle(top), hTop); - final Function topClosure = PluginUtilities.getCallbackFromHandle(hTop); - expect(topClosure, isNotNull); + final Function topClosure = PluginUtilities.getCallbackFromHandle(hTop)!; expect(topClosure(), 'top'); // Static method callback. - final CallbackHandle hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt); - expect(hGetInt, isNotNull); + final CallbackHandle hGetInt = PluginUtilities.getCallbackHandle(Foo.getInt)!; expect(hGetInt, notEquals(0)); expect(PluginUtilities.getCallbackHandle(Foo.getInt), hGetInt); - final Function getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt); - expect(getIntClosure, isNotNull); + final Function getIntClosure = PluginUtilities.getCallbackFromHandle(hGetInt)!; expect(getIntClosure(), 1); // Instance method callbacks cannot be looked up. diff --git a/engine/src/flutter/testing/dart/pubspec.yaml b/engine/src/flutter/testing/dart/pubspec.yaml index 1d125350b6..c6e0ae9d11 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.8.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: litetest: any diff --git a/engine/src/flutter/testing/dart/semantics_test.dart b/engine/src/flutter/testing/dart/semantics_test.dart index 27054d8195..103722b0b9 100644 --- a/engine/src/flutter/testing/dart/semantics_test.dart +++ b/engine/src/flutter/testing/dart/semantics_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:ui'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/spirv_exception_test.dart b/engine/src/flutter/testing/dart/spirv_exception_test.dart index c33d451941..e67c7b0136 100644 --- a/engine/src/flutter/testing/dart/spirv_exception_test.dart +++ b/engine/src/flutter/testing/dart/spirv_exception_test.dart @@ -45,7 +45,7 @@ Stream exceptionShaders() async* { if (entry is! File) { continue; } - final File file = entry as File; + final File file = entry; if (path.extension(file.path) != '.spv') { continue; } diff --git a/engine/src/flutter/testing/dart/task_order_test.dart b/engine/src/flutter/testing/dart/task_order_test.dart index d759cf71ef..018c2bee85 100644 --- a/engine/src/flutter/testing/dart/task_order_test.dart +++ b/engine/src/flutter/testing/dart/task_order_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:async'; import 'package:litetest/litetest.dart'; diff --git a/engine/src/flutter/testing/dart/text_test.dart b/engine/src/flutter/testing/dart/text_test.dart index f52a4b20ca..cd726935ac 100644 --- a/engine/src/flutter/testing/dart/text_test.dart +++ b/engine/src/flutter/testing/dart/text_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:convert'; import 'dart:typed_data'; import 'dart:ui'; @@ -173,12 +172,13 @@ void testTextRange() { void testLoadFontFromList() { test('loadFontFromList will send platform message after font is loaded', () async { - final PlatformMessageCallback oldHandler = window.onPlatformMessage; - String actualName; - String message; - window.onPlatformMessage = (String name, ByteData data, PlatformMessageResponseCallback callback) { + final PlatformMessageCallback? oldHandler = window.onPlatformMessage; + late String actualName; + late String message; + window.onPlatformMessage = (String name, ByteData? data, PlatformMessageResponseCallback? callback) { + assert(data != null); actualName = name; - final Uint8List list = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); + final Uint8List list = data!.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); message = utf8.decode(list); }; final Uint8List fontData = Uint8List(0); diff --git a/engine/src/flutter/testing/dart/window_test.dart b/engine/src/flutter/testing/dart/window_test.dart index 8b733328f9..2b8526bd0c 100644 --- a/engine/src/flutter/testing/dart/window_test.dart +++ b/engine/src/flutter/testing/dart/window_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.6 import 'dart:async'; import 'dart:typed_data'; import 'dart:ui'; @@ -13,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) { + window.sendPlatformMessage('test', ByteData.view(Uint8List(0).buffer), expectAsync1((ByteData? data) { final Zone runZone = Zone.current; expect(runZone, isNotNull); expect(runZone, same(innerZone)); @@ -41,7 +40,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 = window.computePlatformResolvedLocale(supportedLocales); expect(result, null); }); } diff --git a/engine/src/flutter/testing/smoke_test_failure/fail_test.dart b/engine/src/flutter/testing/smoke_test_failure/fail_test.dart index 5c9419afb7..90087f62df 100644 --- a/engine/src/flutter/testing/smoke_test_failure/fail_test.dart +++ b/engine/src/flutter/testing/smoke_test_failure/fail_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. -// @dart = 2.12 - import 'package:litetest/litetest.dart'; void main() {