Migrate //testing to nullsafety (flutter/engine#26825)
This commit is contained in:
@@ -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, <Offset>[]), null, paint));
|
||||
testCanvas((Canvas canvas) => canvas.drawVertices(Vertices(VertexMode.triangles, <Offset>[]), 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<bool> 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<bool> 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, <RSTransform>[transform], <Rect>[rect], <Color>[color], BlendMode.src, rect, null));
|
||||
expectAssertion(() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[rect], <Color>[color], null, rect, paint));
|
||||
expectAssertion(() => canvas.drawAtlas(image, <RSTransform>[transform], null, <Color>[color], BlendMode.src, rect, paint));
|
||||
expectAssertion(() => canvas.drawAtlas(image, null, <Rect>[rect], <Color>[color], BlendMode.src, rect, paint));
|
||||
expectAssertion(() => canvas.drawAtlas(null, <RSTransform>[transform], <Rect>[rect], <Color>[color], BlendMode.src, rect, paint));
|
||||
});
|
||||
|
||||
test('Data lengths must match for drawAtlas methods', () async {
|
||||
|
||||
@@ -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<String> log = <String>[];
|
||||
final Completer<void> completer = Completer<void>();
|
||||
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, <String>[
|
||||
@@ -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(<int>[]), 0, 0), (ByteData data) {
|
||||
buffers.push('a', ByteData.sublistView(Uint8List.fromList(<int>[]), 0, 0), (ByteData? data) {
|
||||
log.add('callback2: ${Zone.current == zone2}');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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(<double>[
|
||||
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(<double>[
|
||||
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);
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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<int> expected = await readFile('square.png');
|
||||
expect(Uint8List.view(data.buffer), expected);
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
<Color>[const Color(0xFFFFFFFF), const Color(0xFFFFFFFF)],
|
||||
<double>[0.0, 1.0],
|
||||
TileMode.mirror),
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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<StackTrace> stackTraces = frame.image.debugGetOpenHandleStackTraces();
|
||||
List<StackTrace> 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()));
|
||||
|
||||
|
||||
@@ -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<ColorFilter> colorFilters() {
|
||||
// Create new color filter instances on each invocation.
|
||||
return <ColorFilter> [ // 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<void> 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)'
|
||||
),
|
||||
|
||||
@@ -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<Image> resize({int targetWidth, int targetHeight, bool allowUpscaling = false}) async {
|
||||
Future<Image> resize({int? targetWidth, int? targetHeight, bool allowUpscaling = false}) async {
|
||||
final Completer<Image> imageCompleter = Completer<Image>();
|
||||
decodeImageFromPixels(
|
||||
pixels,
|
||||
|
||||
@@ -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(<dynamic>[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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -45,7 +45,7 @@ Stream<Uint8List> exceptionShaders() async* {
|
||||
if (entry is! File) {
|
||||
continue;
|
||||
}
|
||||
final File file = entry as File;
|
||||
final File file = entry;
|
||||
if (path.extension(file.path) != '.spv') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user