Migrate more tests from litetest to package:test (flutter/engine#55119)
Partial work towards https://github.com/flutter/flutter/issues/133569. Commentary on removal of `assert`-conditionals here: https://github.com/flutter/flutter/issues/155054.
This commit is contained in:
@@ -10,10 +10,10 @@ import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
final engine = Engine.findWithin();
|
||||
final manualBuildDir = io.Platform.environment['ENGINE_BUILD_DIR'];
|
||||
final manualBuildDir = io.Platform.environment['FLUTTER_BUILD_DIRECTORY'];
|
||||
final buildDir = manualBuildDir ?? engine.latestOutput()?.path.path;
|
||||
if (buildDir == null) {
|
||||
fail('No build directory found. Set ENGINE_BUILD_DIR');
|
||||
fail('No build directory found. Set FLUTTER_BUILD_DIRECTORY');
|
||||
}
|
||||
final frontendServer = path.join(
|
||||
buildDir,
|
||||
|
||||
@@ -8,8 +8,8 @@ import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import 'goldens.dart';
|
||||
@@ -189,7 +189,10 @@ void main() async {
|
||||
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], null, rect, paint));
|
||||
expect(
|
||||
() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[rect], <Color>[color], null, rect, paint),
|
||||
throwsA(isA<AssertionError>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('Data lengths must match for drawAtlas methods', () async {
|
||||
@@ -208,15 +211,15 @@ void main() async {
|
||||
canvas.drawRawAtlas(image, Float32List(4), Float32List(4), Int32List(1), BlendMode.src, rect, paint);
|
||||
canvas.drawRawAtlas(image, Float32List(4), Float32List(4), null, null, rect, paint);
|
||||
|
||||
expectArgumentError(() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[], <Color>[color], BlendMode.src, rect, paint));
|
||||
expectArgumentError(() => canvas.drawAtlas(image, <RSTransform>[], <Rect>[rect], <Color>[color], BlendMode.src, rect, paint));
|
||||
expectArgumentError(() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[rect], <Color>[color, color], BlendMode.src, rect, paint));
|
||||
expectArgumentError(() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[rect, rect], <Color>[color], BlendMode.src, rect, paint));
|
||||
expectArgumentError(() => canvas.drawAtlas(image, <RSTransform>[transform, transform], <Rect>[rect], <Color>[color], BlendMode.src, rect, paint));
|
||||
expectArgumentError(() => canvas.drawRawAtlas(image, Float32List(3), Float32List(3), null, null, rect, paint));
|
||||
expectArgumentError(() => canvas.drawRawAtlas(image, Float32List(4), Float32List(0), null, null, rect, paint));
|
||||
expectArgumentError(() => canvas.drawRawAtlas(image, Float32List(0), Float32List(4), null, null, rect, paint));
|
||||
expectArgumentError(() => canvas.drawRawAtlas(image, Float32List(4), Float32List(4), Int32List(2), BlendMode.src, rect, paint));
|
||||
expect(() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[], <Color>[color], BlendMode.src, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawAtlas(image, <RSTransform>[], <Rect>[rect], <Color>[color], BlendMode.src, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[rect], <Color>[color, color], BlendMode.src, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawAtlas(image, <RSTransform>[transform], <Rect>[rect, rect], <Color>[color], BlendMode.src, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawAtlas(image, <RSTransform>[transform, transform], <Rect>[rect], <Color>[color], BlendMode.src, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawRawAtlas(image, Float32List(3), Float32List(3), null, null, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawRawAtlas(image, Float32List(4), Float32List(0), null, null, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawRawAtlas(image, Float32List(0), Float32List(4), null, null, rect, paint), throwsArgumentError);
|
||||
expect(() => canvas.drawRawAtlas(image, Float32List(4), Float32List(4), Int32List(2), BlendMode.src, rect, paint), throwsArgumentError);
|
||||
});
|
||||
|
||||
test('Canvas preserves perspective data in Matrix4', () async {
|
||||
@@ -489,7 +492,7 @@ void main() async {
|
||||
|
||||
final ByteData dataSync = await drawOnCanvas(toImageImage);
|
||||
final ByteData data = await drawOnCanvas(toImageSyncImage);
|
||||
expect(data, listEquals(dataSync));
|
||||
expect(data.buffer.asUint8List(), equals(dataSync.buffer.asUint8List()));
|
||||
});
|
||||
|
||||
test('Canvas.drawParagraph throws when Paragraph.layout was not called', () async {
|
||||
@@ -646,39 +649,6 @@ void main() async {
|
||||
await comparer.addGoldenImage(image, 'render_unordered_rects.png');
|
||||
});
|
||||
|
||||
Matcher closeToTransform(Float64List expected) => (dynamic v) {
|
||||
Expect.type<Float64List>(v);
|
||||
final Float64List value = v as Float64List;
|
||||
expect(expected.length, equals(16));
|
||||
expect(value.length, equals(16));
|
||||
for (int r = 0; r < 4; r++) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
final double vActual = value[r*4 + c];
|
||||
final double vExpected = expected[r*4 + c];
|
||||
if ((vActual - vExpected).abs() > 1e-10) {
|
||||
Expect.fail('matrix mismatch at $r, $c, $vActual not close to $vExpected');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Matcher notCloseToTransform(Float64List expected) => (dynamic v) {
|
||||
Expect.type<Float64List>(v);
|
||||
final Float64List value = v as Float64List;
|
||||
expect(expected.length, equals(16));
|
||||
expect(value.length, equals(16));
|
||||
for (int r = 0; r < 4; r++) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
final double vActual = value[r*4 + c];
|
||||
final double vExpected = expected[r*4 + c];
|
||||
if ((vActual - vExpected).abs() > 1e-10) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Expect.fail('$value is too close to $expected');
|
||||
};
|
||||
|
||||
test('Canvas.translate affects canvas.getTransform', () async {
|
||||
final PictureRecorder recorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(recorder);
|
||||
@@ -688,7 +658,7 @@ void main() async {
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
canvas.translate(10, 10);
|
||||
final Float64List newCurMatrix = canvas.getTransform();
|
||||
expect(newCurMatrix, notCloseToTransform(matrix));
|
||||
expect(newCurMatrix, isNot(closeToTransform(matrix)));
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
});
|
||||
|
||||
@@ -701,7 +671,7 @@ void main() async {
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
canvas.scale(10, 10);
|
||||
final Float64List newCurMatrix = canvas.getTransform();
|
||||
expect(newCurMatrix, notCloseToTransform(matrix));
|
||||
expect(newCurMatrix, isNot(closeToTransform(matrix)));
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
});
|
||||
|
||||
@@ -714,7 +684,7 @@ void main() async {
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
canvas.rotate(pi / 2);
|
||||
final Float64List newCurMatrix = canvas.getTransform();
|
||||
expect(newCurMatrix, notCloseToTransform(matrix));
|
||||
expect(newCurMatrix, isNot(closeToTransform(matrix)));
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
});
|
||||
|
||||
@@ -727,7 +697,7 @@ void main() async {
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
canvas.skew(10, 10);
|
||||
final Float64List newCurMatrix = canvas.getTransform();
|
||||
expect(newCurMatrix, notCloseToTransform(matrix));
|
||||
expect(newCurMatrix, isNot(closeToTransform(matrix)));
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
});
|
||||
|
||||
@@ -740,31 +710,10 @@ void main() async {
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
canvas.translate(10, 10);
|
||||
final Float64List newCurMatrix = canvas.getTransform();
|
||||
expect(newCurMatrix, notCloseToTransform(matrix));
|
||||
expect(newCurMatrix, isNot(closeToTransform(matrix)));
|
||||
expect(curMatrix, closeToTransform(matrix));
|
||||
});
|
||||
|
||||
Matcher closeToRect(Rect expected) => (dynamic v) {
|
||||
Expect.type<Rect>(v);
|
||||
final Rect value = v as Rect;
|
||||
expect(value.left, closeTo(expected.left, 1e-6));
|
||||
expect(value.top, closeTo(expected.top, 1e-6));
|
||||
expect(value.right, closeTo(expected.right, 1e-6));
|
||||
expect(value.bottom, closeTo(expected.bottom, 1e-6));
|
||||
};
|
||||
|
||||
Matcher notCloseToRect(Rect expected) => (dynamic v) {
|
||||
Expect.type<Rect>(v);
|
||||
final Rect value = v as Rect;
|
||||
if ((value.left - expected.left).abs() > 1e-6 ||
|
||||
(value.top - expected.top).abs() > 1e-6 ||
|
||||
(value.right - expected.right).abs() > 1e-6 ||
|
||||
(value.bottom - expected.bottom).abs() > 1e-6) {
|
||||
return;
|
||||
}
|
||||
Expect.fail('$value is too close to $expected');
|
||||
};
|
||||
|
||||
test('Canvas.clipRect affects canvas.getClipBounds', () async {
|
||||
void testRect(Rect clipRect, bool doAA) {
|
||||
final PictureRecorder recorder = PictureRecorder();
|
||||
@@ -798,8 +747,8 @@ void main() async {
|
||||
canvas.save();
|
||||
canvas.clipRect(const Rect.fromLTRB(0, 0, 15, 15));
|
||||
// Both clip bounds have changed
|
||||
expect(canvas.getLocalClipBounds(), notCloseToRect(clipExpandedBounds));
|
||||
expect(canvas.getDestinationClipBounds(), notCloseToRect(clipExpandedBounds));
|
||||
expect(canvas.getLocalClipBounds(), isNot(closeToRect(clipExpandedBounds)));
|
||||
expect(canvas.getDestinationClipBounds(), isNot(closeToRect(clipExpandedBounds)));
|
||||
// Previous return values have not changed
|
||||
expect(initialLocalBounds, closeToRect(clipExpandedBounds));
|
||||
expect(initialDestinationBounds, closeToRect(clipExpandedBounds));
|
||||
@@ -881,8 +830,8 @@ void main() async {
|
||||
canvas.save();
|
||||
canvas.clipRect(const Rect.fromLTRB(0, 0, 15, 15));
|
||||
// Both clip bounds have changed
|
||||
expect(canvas.getLocalClipBounds(), notCloseToRect(clipExpandedBounds));
|
||||
expect(canvas.getDestinationClipBounds(), notCloseToRect(clipExpandedBounds));
|
||||
expect(canvas.getLocalClipBounds(), isNot(closeToRect(clipExpandedBounds)));
|
||||
expect(canvas.getDestinationClipBounds(), isNot(closeToRect(clipExpandedBounds)));
|
||||
// Previous return values have not changed
|
||||
expect(initialLocalBounds, closeToRect(clipExpandedBounds));
|
||||
expect(initialDestinationBounds, closeToRect(clipExpandedBounds));
|
||||
@@ -921,8 +870,8 @@ void main() async {
|
||||
canvas.save();
|
||||
canvas.clipRect(const Rect.fromLTRB(0, 0, 15, 15), doAntiAlias: false);
|
||||
// Both clip bounds have changed
|
||||
expect(canvas.getLocalClipBounds(), notCloseToRect(clipBounds));
|
||||
expect(canvas.getDestinationClipBounds(), notCloseToRect(clipBounds));
|
||||
expect(canvas.getLocalClipBounds(), isNot(closeToRect(clipBounds)));
|
||||
expect(canvas.getDestinationClipBounds(), isNot(closeToRect(clipBounds)));
|
||||
// Previous return values have not changed
|
||||
expect(initialLocalBounds, closeToRect(clipBounds));
|
||||
expect(initialDestinationBounds, closeToRect(clipBounds));
|
||||
@@ -985,8 +934,8 @@ void main() async {
|
||||
canvas.save();
|
||||
canvas.clipRect(const Rect.fromLTRB(0, 0, 15, 15));
|
||||
// Both clip bounds have changed
|
||||
expect(canvas.getLocalClipBounds(), notCloseToRect(clipExpandedBounds));
|
||||
expect(canvas.getDestinationClipBounds(), notCloseToRect(clipExpandedBounds));
|
||||
expect(canvas.getLocalClipBounds(), isNot(closeToRect(clipExpandedBounds)));
|
||||
expect(canvas.getDestinationClipBounds(), isNot(closeToRect(clipExpandedBounds)));
|
||||
// Previous return values have not changed
|
||||
expect(initialLocalBounds, closeToRect(clipExpandedBounds));
|
||||
expect(initialDestinationBounds, closeToRect(clipExpandedBounds));
|
||||
@@ -1025,8 +974,8 @@ void main() async {
|
||||
canvas.save();
|
||||
canvas.clipRect(const Rect.fromLTRB(0, 0, 15, 15), doAntiAlias: false);
|
||||
// Both clip bounds have changed
|
||||
expect(canvas.getLocalClipBounds(), notCloseToRect(clipBounds));
|
||||
expect(canvas.getDestinationClipBounds(), notCloseToRect(clipBounds));
|
||||
expect(canvas.getLocalClipBounds(), isNot(closeToRect(clipBounds)));
|
||||
expect(canvas.getDestinationClipBounds(), isNot(closeToRect(clipBounds)));
|
||||
// Previous return values have not changed
|
||||
expect(initialLocalBounds, closeToRect(clipBounds));
|
||||
expect(initialDestinationBounds, closeToRect(clipBounds));
|
||||
@@ -1300,7 +1249,6 @@ void main() async {
|
||||
final ByteData? data = await resultImage.toByteData();
|
||||
if (data == null) {
|
||||
fail('Expected non-null byte data');
|
||||
return;
|
||||
}
|
||||
final int rgba = data.buffer.asUint32List()[0];
|
||||
expect(rgba, 0xFF0000FF);
|
||||
@@ -1315,11 +1263,51 @@ Future<Image> createTestImage() async {
|
||||
return picture.toImage(1, 1);
|
||||
}
|
||||
|
||||
Matcher listEquals(ByteData expected) => (dynamic v) {
|
||||
Expect.type<ByteData>(v);
|
||||
final ByteData value = v as ByteData;
|
||||
expect(value.lengthInBytes, expected.lengthInBytes);
|
||||
for (int i = 0; i < value.lengthInBytes; i++) {
|
||||
expect(value.getUint8(i), expected.getUint8(i));
|
||||
Matcher closeToRect(Rect rect) => _CloseToRectMatcher(rect);
|
||||
final class _CloseToRectMatcher extends Matcher {
|
||||
const _CloseToRectMatcher(this._expectedRect);
|
||||
final Rect _expectedRect;
|
||||
|
||||
@override
|
||||
bool matches(Object? item, Map<Object?, Object?> matchState) {
|
||||
if (item is! Rect) {
|
||||
return false;
|
||||
}
|
||||
return (item.left - _expectedRect.left).abs() < 1e-6 &&
|
||||
(item.top - _expectedRect.top).abs() < 1e-6 &&
|
||||
(item.right - _expectedRect.right).abs() < 1e-6 &&
|
||||
(item.bottom - _expectedRect.bottom).abs() < 1e-6;
|
||||
}
|
||||
};
|
||||
|
||||
@override
|
||||
Description describe(Description description) {
|
||||
return description.add('Rect is close (within 1e-6) to $_expectedRect');
|
||||
}
|
||||
}
|
||||
|
||||
Matcher closeToTransform(Float64List expected) => _CloseToTransformMatcher(expected);
|
||||
final class _CloseToTransformMatcher extends Matcher {
|
||||
_CloseToTransformMatcher(this._expected);
|
||||
final Float64List _expected;
|
||||
|
||||
@override
|
||||
bool matches(Object? item, Map<Object?, Object?> matchState) {
|
||||
if (item is! Float64List) {
|
||||
return false;
|
||||
}
|
||||
if (item.length != 16 || _expected.length != 16) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((item[i] - _expected[i]).abs() > 1e-10) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Description describe(Description description) {
|
||||
return description.add('Transform is close (within 1e-10) to $_expected');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
/// Positive result when the Colors will map to the same argb8888 color.
|
||||
Matcher colorMatches(dynamic o) => (v) {
|
||||
@@ -23,10 +23,6 @@ class NotAColor extends Color {
|
||||
const NotAColor(super.value);
|
||||
}
|
||||
|
||||
Matcher approxEquals(dynamic o) => (v) {
|
||||
Expect.approxEquals(o as num, v as num);
|
||||
};
|
||||
|
||||
void main() {
|
||||
test('color accessors should work', () {
|
||||
const Color foo = Color(0x12345678);
|
||||
@@ -58,9 +54,9 @@ void main() {
|
||||
test('two colors are only == if they have the same runtime type', () {
|
||||
expect(const Color(0x12345678), equals(const Color(0x12345678)));
|
||||
expect(const Color(0x12345678), equals(Color(0x12345678))); // ignore: prefer_const_constructors
|
||||
expect(const Color(0x12345678), notEquals(const Color(0x87654321)));
|
||||
expect(const Color(0x12345678), notEquals(const NotAColor(0x12345678)));
|
||||
expect(const NotAColor(0x12345678), notEquals(const Color(0x12345678)));
|
||||
expect(const Color(0x12345678), isNot(const Color(0x87654321)));
|
||||
expect(const Color(0x12345678), isNot(const NotAColor(0x12345678)));
|
||||
expect(const NotAColor(0x12345678), isNot(const Color(0x12345678)));
|
||||
expect(const NotAColor(0x12345678), equals(const NotAColor(0x12345678)));
|
||||
});
|
||||
|
||||
@@ -257,9 +253,9 @@ void main() {
|
||||
alpha: 1, red: 1, green: 0, blue: 0, colorSpace: ColorSpace.displayP3);
|
||||
final Color srgb = p3.withValues(colorSpace: ColorSpace.extendedSRGB);
|
||||
expect(srgb.a, equals(1.0));
|
||||
expect(srgb.r, approxEquals(1.0931));
|
||||
expect(srgb.g, approxEquals(-0.22684034705162098));
|
||||
expect(srgb.b, approxEquals(-0.15007957816123998));
|
||||
expect(srgb.r, closeTo(1.0931, 1e-4));
|
||||
expect(srgb.g, closeTo(-0.22684034705162098, 1e-4));
|
||||
expect(srgb.b, closeTo(-0.15007957816123998, 1e-4));
|
||||
expect(srgb.colorSpace, equals(ColorSpace.extendedSRGB));
|
||||
});
|
||||
|
||||
@@ -268,9 +264,9 @@ void main() {
|
||||
alpha: 1, red: 1, green: 0, blue: 0, colorSpace: ColorSpace.displayP3);
|
||||
final Color srgb = p3.withValues(colorSpace: ColorSpace.sRGB);
|
||||
expect(srgb.a, equals(1.0));
|
||||
expect(srgb.r, approxEquals(1));
|
||||
expect(srgb.g, approxEquals(0));
|
||||
expect(srgb.b, approxEquals(0));
|
||||
expect(srgb.r, closeTo(1, 1e-4));
|
||||
expect(srgb.g, closeTo(0, 1e-4));
|
||||
expect(srgb.b, closeTo(0, 1e-4));
|
||||
expect(srgb.colorSpace, equals(ColorSpace.sRGB));
|
||||
});
|
||||
|
||||
@@ -283,9 +279,9 @@ void main() {
|
||||
colorSpace: ColorSpace.extendedSRGB);
|
||||
final Color p3 = srgb.withValues(colorSpace: ColorSpace.displayP3);
|
||||
expect(p3.a, equals(1.0));
|
||||
expect(p3.r, approxEquals(1));
|
||||
expect(p3.g, approxEquals(0));
|
||||
expect(p3.b, approxEquals(0));
|
||||
expect(p3.r, closeTo(1, 1e-4));
|
||||
expect(p3.g, closeTo(0, 1e-4));
|
||||
expect(p3.b, closeTo(0, 1e-4));
|
||||
expect(p3.colorSpace, equals(ColorSpace.displayP3));
|
||||
});
|
||||
|
||||
@@ -311,7 +307,7 @@ void main() {
|
||||
alpha: 1, red: 1, green: 0, blue: 0);
|
||||
const Color p3 = Color.from(
|
||||
alpha: 1, red: 1, green: 0, blue: 0, colorSpace: ColorSpace.displayP3);
|
||||
expect(srgb.hashCode, notEquals(p3.hashCode));
|
||||
expect(srgb.hashCode, isNot(p3.hashCode));
|
||||
});
|
||||
|
||||
test('equality considers colorspace', () {
|
||||
@@ -319,7 +315,7 @@ void main() {
|
||||
alpha: 1, red: 1, green: 0, blue: 0);
|
||||
const Color p3 = Color.from(
|
||||
alpha: 1, red: 1, green: 0, blue: 0, colorSpace: ColorSpace.displayP3);
|
||||
expect(srgb, notEquals(p3));
|
||||
expect(srgb, isNot(p3));
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/41257
|
||||
|
||||
@@ -9,8 +9,8 @@ import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'impeller_enabled.dart';
|
||||
import 'shader_test_file_utils.dart';
|
||||
@@ -402,7 +402,6 @@ void main() async {
|
||||
path.join('supported_glsl_op_shaders', 'iplr'),
|
||||
'.iplr',
|
||||
);
|
||||
expect(iplrSupportedGLSLOpShaders.isNotEmpty, true);
|
||||
_expectFragmentShadersRenderGreen(iplrSupportedGLSLOpShaders);
|
||||
|
||||
// Test all supported instructions. See lib/spirv/lib/src/constants.dart
|
||||
@@ -410,7 +409,6 @@ void main() async {
|
||||
path.join('supported_op_shaders', 'iplr'),
|
||||
'.iplr',
|
||||
);
|
||||
expect(iplrSupportedOpShaders.isNotEmpty, true);
|
||||
_expectFragmentShadersRenderGreen(iplrSupportedOpShaders);
|
||||
}
|
||||
|
||||
@@ -418,6 +416,9 @@ void main() async {
|
||||
// Keeping the outer loop of the test synchronous allows for easy printing
|
||||
// of the file name within the test case.
|
||||
void _expectFragmentShadersRenderGreen(Map<String, FragmentProgram> programs) {
|
||||
if (programs.isEmpty) {
|
||||
fail('No shaders found.');
|
||||
}
|
||||
for (final String key in programs.keys) {
|
||||
test('FragmentProgram $key renders green', () async {
|
||||
final FragmentProgram program = programs[key]!;
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'goldens.dart';
|
||||
import 'impeller_enabled.dart';
|
||||
@@ -133,9 +133,9 @@ void main() async {
|
||||
expect(a[i].hashCode, equals(b[j].hashCode));
|
||||
expect(a[i].toString(), equals(b[j].toString()));
|
||||
} else {
|
||||
expect(a[i], notEquals(b[j]));
|
||||
expect(a[i], isNot(b[j]));
|
||||
// No expectations on hashCode if objects are not equal
|
||||
expect(a[i].toString(), notEquals(b[j].toString()));
|
||||
expect(a[i].toString(), isNot(b[j].toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ void main() async {
|
||||
});
|
||||
|
||||
// Tests that FilterQuality.<value> produces the expected golden file.
|
||||
group('ImageFilter|FilterQuality', () async {
|
||||
group('ImageFilter|FilterQuality', () {
|
||||
/// Draw a red-green checkerboard pattern with 1x1 squares (pixels).
|
||||
Future<Image> drawCheckerboard({
|
||||
int width = 100,
|
||||
|
||||
@@ -5,16 +5,11 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'canvas_test.dart' show createImage, testCanvas;
|
||||
|
||||
void main() {
|
||||
bool assertsEnabled = false;
|
||||
assert(() {
|
||||
assertsEnabled = true;
|
||||
return true;
|
||||
}());
|
||||
|
||||
test('Construct an ImageShader', () async {
|
||||
final Image image = await createImage(50, 50);
|
||||
final ImageShader shader = ImageShader(image, TileMode.clamp, TileMode.clamp, Float64List(16));
|
||||
@@ -22,13 +17,9 @@ void main() {
|
||||
const Rect rect = Rect.fromLTRB(0, 0, 100, 100);
|
||||
testCanvas((Canvas canvas) => canvas.drawRect(rect, paint));
|
||||
|
||||
if (assertsEnabled) {
|
||||
expect(shader.debugDisposed, false);
|
||||
}
|
||||
expect(shader.debugDisposed, false);
|
||||
shader.dispose();
|
||||
if (assertsEnabled) {
|
||||
expect(shader.debugDisposed, true);
|
||||
}
|
||||
expect(shader.debugDisposed, true);
|
||||
|
||||
image.dispose();
|
||||
});
|
||||
@@ -37,11 +28,10 @@ void main() {
|
||||
final Image image = await createImage(50, 50);
|
||||
image.dispose();
|
||||
|
||||
if (assertsEnabled) {
|
||||
expectAssertion(() => ImageShader(image, TileMode.clamp, TileMode.clamp, Float64List(16)));
|
||||
} else {
|
||||
throwsException(() => ImageShader(image, TileMode.clamp, TileMode.clamp, Float64List(16)));
|
||||
}
|
||||
expect(
|
||||
() => ImageShader(image, TileMode.clamp, TileMode.clamp, Float64List(16)),
|
||||
throwsA(isA<AssertionError>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('Disposed image shader in a paint', () async {
|
||||
@@ -49,15 +39,7 @@ void main() {
|
||||
final ImageShader shader = ImageShader(image, TileMode.clamp, TileMode.clamp, Float64List(16));
|
||||
shader.dispose();
|
||||
|
||||
if (assertsEnabled) {
|
||||
expectAssertion(() => Paint()..shader = shader);
|
||||
return;
|
||||
}
|
||||
final Paint paint = Paint()..shader = shader;
|
||||
const Rect rect = Rect.fromLTRB(0, 0, 100, 100);
|
||||
testCanvas((Canvas canvas) => canvas.drawRect(rect, paint));
|
||||
image.dispose();
|
||||
|
||||
expect(() => Paint()..shader = shader, throwsA(isA<AssertionError>()));
|
||||
});
|
||||
|
||||
test('Construct an ImageShader - GPU image', () async {
|
||||
@@ -73,13 +55,9 @@ void main() {
|
||||
const Rect rect = Rect.fromLTRB(0, 0, 100, 100);
|
||||
testCanvas((Canvas canvas) => canvas.drawRect(rect, paint));
|
||||
|
||||
if (assertsEnabled) {
|
||||
expect(shader.debugDisposed, false);
|
||||
}
|
||||
expect(shader.debugDisposed, false);
|
||||
shader.dispose();
|
||||
if (assertsEnabled) {
|
||||
expect(shader.debugDisposed, true);
|
||||
}
|
||||
expect(shader.debugDisposed, true);
|
||||
|
||||
image.dispose();
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'dart:developer' as developer;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vms;
|
||||
import 'package:vm_service/vm_service_io.dart';
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'dart:developer' as developer;
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vms;
|
||||
import 'package:vm_service/vm_service_io.dart';
|
||||
|
||||
|
||||
@@ -7,13 +7,12 @@ import 'dart:convert' show base64Decode;
|
||||
import 'dart:developer' as developer;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vms;
|
||||
import 'package:vm_service/vm_service_io.dart';
|
||||
import 'package:vm_service_protos/vm_service_protos.dart';
|
||||
|
||||
import '../impeller_enabled.dart';
|
||||
import '../serialized_test_suite.dart';
|
||||
|
||||
Future<void> _testChromeFormatTrace(vms.VmService vmService) async {
|
||||
final vms.Timeline timeline = await vmService.getVMTimeline();
|
||||
@@ -70,9 +69,7 @@ Future<void> _testPerfettoFormatTrace(vms.VmService vmService) async {
|
||||
}
|
||||
|
||||
void main() {
|
||||
final SerializedTestSuite suite = SerializedTestSuite();
|
||||
|
||||
suite.test('Canvas.saveLayer emits tracing', () async {
|
||||
test('Canvas.saveLayer emits tracing', () async {
|
||||
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
|
||||
|
||||
if (info.serverUri == null) {
|
||||
@@ -116,7 +113,7 @@ void main() {
|
||||
await vmService.dispose();
|
||||
});
|
||||
|
||||
suite.test('Frame request pending begin/end pairs are matched', () async {
|
||||
test('Frame request pending begin/end pairs are matched', () async {
|
||||
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
|
||||
|
||||
if (info.serverUri == null) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'dart:developer' as developer;
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vms;
|
||||
import 'package:vm_service/vm_service_io.dart';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:async';
|
||||
import 'dart:isolate';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
int counter = 0;
|
||||
|
||||
@@ -62,34 +62,47 @@ void main() {
|
||||
expect(await future3, 3);
|
||||
});
|
||||
|
||||
test('PlatformIsolate runOnPlatformThread, send and receive messages',
|
||||
() async {
|
||||
// Send numbers 1 to 10 to the platform isolate. The platform isolate
|
||||
// multiplies them by 100 and sends them back.
|
||||
int sum = 0;
|
||||
final RawReceivePort recvPort = RawReceivePort((Object message) {
|
||||
if (message is SendPort) {
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
message.send(i);
|
||||
}
|
||||
} else {
|
||||
sum += message as int;
|
||||
test('PlatformIsolate runOnPlatformThread, send/receive messages', () async {
|
||||
late SendPort toPlatformThread;
|
||||
var sumOfReceivedMessages = 0;
|
||||
var countofReceivedMessages = 0;
|
||||
final recvPort = RawReceivePort((Object message) {
|
||||
switch (message) {
|
||||
case final SendPort sendPort:
|
||||
toPlatformThread = sendPort;
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
sendPort.send(i);
|
||||
}
|
||||
case final int value:
|
||||
sumOfReceivedMessages += value;
|
||||
countofReceivedMessages++;
|
||||
if (countofReceivedMessages == 10) {
|
||||
toPlatformThread.send(true);
|
||||
}
|
||||
default:
|
||||
fail('Unexpected message: $message');
|
||||
}
|
||||
});
|
||||
final SendPort sendPort = recvPort.sendPort;
|
||||
|
||||
final sendPort = recvPort.sendPort;
|
||||
await runOnPlatformThread(() async {
|
||||
final Completer<void> completer = Completer<void>();
|
||||
final RawReceivePort recvPort = RawReceivePort((Object message) {
|
||||
sendPort.send((message as int) * 100);
|
||||
if (message == 10) {
|
||||
completer.complete();
|
||||
final completer = Completer<void>();
|
||||
final recvPort = RawReceivePort((Object message) {
|
||||
switch (message) {
|
||||
case final int value:
|
||||
sendPort.send(value * 100);
|
||||
case true:
|
||||
completer.complete();
|
||||
default:
|
||||
fail('Unexpected message: $message');
|
||||
}
|
||||
});
|
||||
sendPort.send(recvPort.sendPort);
|
||||
await completer.future;
|
||||
recvPort.close();
|
||||
});
|
||||
expect(sum, 5500); // sum(1 to 10) * 100
|
||||
|
||||
expect(sumOfReceivedMessages, 5500); // sum(1 to 10) * 100
|
||||
recvPort.close();
|
||||
});
|
||||
|
||||
@@ -122,9 +135,11 @@ void main() {
|
||||
|
||||
test('PlatformIsolate runOnPlatformThread, disabled on helper isolates',
|
||||
() async {
|
||||
await Isolate.run(() {
|
||||
expect(() => runOnPlatformThread(() => print('Unreachable')), throws);
|
||||
});
|
||||
await expectLater(() async {
|
||||
await Isolate.run(() {
|
||||
return runOnPlatformThread(() => print('Unreachable'));
|
||||
});
|
||||
}, throws);
|
||||
});
|
||||
|
||||
test('PlatformIsolate runOnPlatformThread, on platform isolate', () async {
|
||||
@@ -134,7 +149,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('PlatformIsolate runOnPlatformThread, exit disabled', () async {
|
||||
await runOnPlatformThread(() => expect(() => Isolate.exit(), throws));
|
||||
await expectLater(runOnPlatformThread(() => Isolate.exit()), throws);
|
||||
});
|
||||
|
||||
test('PlatformIsolate runOnPlatformThread, unsendable object', () async {
|
||||
|
||||
@@ -14,7 +14,6 @@ resolution: workspace
|
||||
|
||||
dependencies:
|
||||
ffi: any
|
||||
litetest: any
|
||||
path: any
|
||||
skia_gold_client: any
|
||||
sky_engine: any
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:litetest/litetest.dart' as litetest;
|
||||
|
||||
// A group of tests that must be run without concurrency.
|
||||
// This is useful for tests that modify global state.
|
||||
class SerializedTestSuite {
|
||||
Completer<void>? _previousTestCompleter;
|
||||
|
||||
void test(String name, Future<void> Function() body) {
|
||||
final Completer<void>? lastTestCompleter = _previousTestCompleter;
|
||||
final Completer<void> currentTestCompleter = Completer<void>();
|
||||
_previousTestCompleter = currentTestCompleter;
|
||||
Future<void> wrappedBody() async {
|
||||
if (lastTestCompleter != null) {
|
||||
await lastTestCompleter.future;
|
||||
}
|
||||
await body();
|
||||
currentTestCompleter.complete();
|
||||
}
|
||||
litetest.test(name, wrappedBody);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import 'dart:isolate';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
// This import is used in a test, but not in a way that the analyzer can understand.
|
||||
// ignore: unused_import
|
||||
@@ -43,8 +43,7 @@ const String kTestEntrypointRouteName = 'testEntrypoint';
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void testEntrypoint() {
|
||||
expect(PlatformDispatcher.instance.defaultRouteName, kTestEntrypointRouteName);
|
||||
IsolateNameServer.lookupPortByName(kTestEntrypointRouteName)!.send(null);
|
||||
IsolateNameServer.lookupPortByName(kTestEntrypointRouteName)!.send(PlatformDispatcher.instance.defaultRouteName);
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -54,7 +53,7 @@ void main() {
|
||||
test('Spawn a different entrypoint with a special route name', () async {
|
||||
final ReceivePort port = ReceivePort();
|
||||
spawn(port: port.sendPort, entrypoint: 'testEntrypoint', route: kTestEntrypointRouteName);
|
||||
expect(await port.first, isNull);
|
||||
expect(await port.first, kTestEntrypointRouteName);
|
||||
port.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('Message loop flushes microtasks between iterations', () async {
|
||||
|
||||
@@ -978,7 +978,7 @@ def uses_package_test_runner(package):
|
||||
def build_dart_host_test_list(build_dir):
|
||||
dart_host_tests = [
|
||||
(os.path.join('flutter', 'ci'), []),
|
||||
(os.path.join('flutter', 'flutter_frontend_server'), {'ENGINE_BUILD_DIR': build_dir}),
|
||||
(os.path.join('flutter', 'flutter_frontend_server'), []),
|
||||
(os.path.join('flutter', 'testing', 'litetest'), []),
|
||||
(os.path.join('flutter', 'testing', 'skia_gold_client'), []),
|
||||
(os.path.join('flutter', 'testing', 'scenario_app'), []),
|
||||
|
||||
@@ -19,8 +19,5 @@ dependencies:
|
||||
source_span: any
|
||||
|
||||
dev_dependencies:
|
||||
async_helper: any
|
||||
expect: any
|
||||
litetest: any
|
||||
process_fakes: any
|
||||
smith: any
|
||||
|
||||
|
||||
Reference in New Issue
Block a user