未验证 提交 e5abd98c 编写于 作者: F Ferhat 提交者: GitHub

migrate tests to nullsafe (#25616)

上级 65e36e43
......@@ -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:html' as html;
import 'package:test/bootstrap/browser.dart';
......@@ -56,9 +55,9 @@ void testMain() async {
builder.pop();
builder.pop();
html.document.body.append(builder
html.document.body!.append(builder
.build()
.webOnlyRootElement);
.webOnlyRootElement!);
await matchGoldenFile('backdrop_filter_clip.png', region: region,
maxDiffRatePercent: 0.8);
......@@ -107,9 +106,9 @@ void testMain() async {
builder2.pop();
builder2.pop();
html.document.body.append(builder2
html.document.body!.append(builder2
.build()
.webOnlyRootElement);
.webOnlyRootElement!);
await matchGoldenFile('backdrop_filter_clip_moved.png', region: region,
maxDiffRatePercent: 0.8);
......@@ -139,9 +138,9 @@ void testMain() async {
builder.pop();
builder.pop();
html.document.body.append(builder
html.document.body!.append(builder
.build()
.webOnlyRootElement);
.webOnlyRootElement!);
await matchGoldenFile('backdrop_filter_no_child_rendering.png', region: region,
maxDiffRatePercent: 0.8);
......@@ -149,39 +148,39 @@ void testMain() async {
}
Picture _drawTestPictureWithCircles(Rect region, double offsetX, double offsetY) {
final EnginePictureRecorder recorder = PictureRecorder();
final EnginePictureRecorder recorder = PictureRecorder() as EnginePictureRecorder;
final RecordingCanvas canvas =
recorder.beginRecording(region);
canvas.drawCircle(
Offset(offsetX + 10, offsetY + 10), 10, Paint()..style = PaintingStyle.fill);
Offset(offsetX + 10, offsetY + 10), 10, SurfacePaint()..style = PaintingStyle.fill);
canvas.drawCircle(
Offset(offsetX + 60, offsetY + 10),
10,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromRGBO(255, 0, 0, 1));
canvas.drawCircle(
Offset(offsetX + 10, offsetY + 60),
10,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromRGBO(0, 255, 0, 1));
canvas.drawCircle(
Offset(offsetX + 60, offsetY + 60),
10,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromRGBO(0, 0, 255, 1));
return recorder.endRecording();
}
Picture _drawBackground(Rect region) {
final EnginePictureRecorder recorder = PictureRecorder();
final EnginePictureRecorder recorder = PictureRecorder() as EnginePictureRecorder;
final RecordingCanvas canvas =
recorder.beginRecording(region);
canvas.drawRect(
region.deflate(8.0),
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = Color(0xFFE0FFE0)
);
......
......@@ -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:html' as html;
import 'dart:math' as math;
import 'package:test/bootstrap/browser.dart';
......@@ -19,7 +18,7 @@ void main() {
void testMain() async {
final Rect region = Rect.fromLTWH(0, 0, 400, 600);
BitmapCanvas canvas;
late BitmapCanvas canvas;
setUp(() {
canvas = BitmapCanvas(region, RenderStrategy());
......@@ -48,7 +47,7 @@ void testMain() async {
largeArc: true, clockwise: true, distance: -20);
html.document.body.append(canvas.rootElement);
html.document.body!.append(canvas.rootElement);
await matchGoldenFile('canvas_arc_to_point.png', region: region);
});
......@@ -63,7 +62,7 @@ void testMain() async {
..color = Color(0xFFFF9800) // orange
..style = PaintingStyle.fill);
html.document.body.append(canvas.rootElement);
html.document.body!.append(canvas.rootElement);
await matchGoldenFile('canvas_addarc.png', region: region);
});
......@@ -81,7 +80,7 @@ void testMain() async {
..color = Color(0xFFFF9800) // orange
..style = PaintingStyle.fill);
html.document.body.append(canvas.rootElement);
html.document.body!.append(canvas.rootElement);
await matchGoldenFile('canvas_addarc_ccw.png', region: region);
});
}
......
......@@ -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:html' as html;
import 'dart:js_util' as js_util;
......@@ -35,7 +34,7 @@ void testMain() async {
final html.Element sceneElement = html.Element.tag('flt-scene');
try {
sceneElement.append(engineCanvas.rootElement);
html.document.body.append(sceneElement);
html.document.body!.append(sceneElement);
await matchGoldenFile('$fileName.png', region: region,
maxDiffRatePercent: maxDiffRatePercent, write: write);
} finally {
......@@ -58,13 +57,13 @@ void testMain() async {
rc.save();
rc.drawRect(
Rect.fromLTRB(0, 0, 400, 400),
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(255, 255, 255, 255));
rc.drawCircle(
Offset(100, 100),
80.0,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(128, 255, 0, 0)
..blendMode = BlendMode.difference);
......@@ -72,7 +71,7 @@ void testMain() async {
rc.drawCircle(
Offset(170, 100),
80.0,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..blendMode = BlendMode.color
..color = const Color.fromARGB(128, 0, 255, 0));
......@@ -80,7 +79,7 @@ void testMain() async {
rc.drawCircle(
Offset(135, 170),
80.0,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(128, 255, 0, 0));
rc.restore();
......@@ -95,20 +94,20 @@ void testMain() async {
rc.save();
rc.drawRect(
Rect.fromLTRB(0, 0, 400, 400),
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(255, 255, 255, 255));
rc.drawCircle(
Offset(100, 100),
80.0,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(128, 255, 0, 0)
..blendMode = BlendMode.difference);
rc.drawCircle(
Offset(170, 100),
80.0,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..blendMode = BlendMode.color
..color = const Color.fromARGB(128, 0, 255, 0));
......@@ -116,11 +115,11 @@ void testMain() async {
rc.drawCircle(
Offset(135, 170),
80.0,
Paint()
SurfacePaint()
..style = PaintingStyle.fill
..color = const Color.fromARGB(128, 255, 0, 0));
rc.drawImage(createTestImage(), Offset(135.0, 130.0),
Paint()..blendMode = BlendMode.multiply);
SurfacePaint()..blendMode = BlendMode.multiply);
rc.restore();
await _checkScreenshot(rc, 'canvas_blend_image_multiply',
maxDiffRatePercent: operatingSystem == OperatingSystem.macOs ? 2.95 :
......
......@@ -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:html' as html;
import 'dart:js_util' as js_util;
......@@ -42,7 +41,7 @@ void testMain() async {
path.addOval(Rect.fromLTWH(100, 30, testWidth, testHeight));
rc.clipPath(path);
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTWH(100, 30, testWidth, testHeight), Paint());
Rect.fromLTWH(100, 30, testWidth, testHeight), engine.SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'image_clipped_by_oval',
region: screenRect);
......@@ -65,7 +64,7 @@ void testMain() async {
paintPath.close();
rc.drawPath(
paintPath,
Paint()
engine.SurfacePaint()
..color = Color(0xFF00FF00)
..style = PaintingStyle.fill);
rc.restore();
......@@ -85,7 +84,7 @@ void testMain() async {
paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight));
paintPath.close();
rc.drawPath(paintPath,
Paint()
engine.SurfacePaint()
..color = Color(0xFF000000)
..style = PaintingStyle.stroke);
......@@ -96,7 +95,7 @@ void testMain() async {
path.close();
rc.clipPath(path);
rc.drawImageRect(createTestImage(), Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTWH(-50, 0, testWidth, testHeight), Paint());
Rect.fromLTWH(-50, 0, testWidth, testHeight), engine.SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'image_clipped_by_triangle_off_screen');
});
......@@ -113,7 +112,7 @@ void testMain() async {
paintPath.addRect(Rect.fromLTWH(-50, 0, testWidth, testHeight));
paintPath.close();
rc.drawPath(paintPath,
Paint()
engine.SurfacePaint()
..color = Color(0xFF000000)
..style = PaintingStyle.stroke);
......@@ -121,7 +120,7 @@ void testMain() async {
path.addOval(Rect.fromLTRB(-200, 0, 100, 150));
rc.clipPath(path);
rc.drawImageRect(createTestImage(), Rect.fromLTRB(0, 0, testWidth, testHeight),
Rect.fromLTWH(-50, 0, testWidth, testHeight), Paint());
Rect.fromLTWH(-50, 0, testWidth, testHeight), engine.SurfacePaint());
rc.restore();
await canvasScreenshot(rc, 'image_clipped_by_oval_path');
});
......
......@@ -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:html' as html;
import 'package:test/bootstrap/browser.dart';
......@@ -35,7 +34,7 @@ void testMain() async {
final html.Element sceneElement = html.Element.tag('flt-scene');
try {
sceneElement.append(engineCanvas.rootElement);
html.document.body.append(sceneElement);
html.document.body!.append(sceneElement);
// TODO(yjbanov): 10% diff rate is excessive. Update goldens.
await matchGoldenFile('$fileName.png', region: region, maxDiffRatePercent: 10);
} finally {
......@@ -57,7 +56,7 @@ void testMain() async {
test('Clips image with oval clip path', () async {
final engine.RecordingCanvas rc =
engine.RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
final Paint paint = Paint()
final engine.SurfacePaint paint = Paint() as engine.SurfacePaint
..color = Color(0xFF00FF00)
..style = PaintingStyle.fill;
rc.save();
......@@ -98,11 +97,11 @@ void testMain() async {
rc.save();
rc.restore();
// The rectangle should be clipped against oval.
rc.drawRect(Rect.fromLTWH(0, 0, 300, 300), badPaint);
rc.drawRect(Rect.fromLTWH(0, 0, 300, 300), badPaint as engine.SurfacePaint);
rc.restore();
// The rectangle should paint without clipping since we restored
// context.
rc.drawRect(Rect.fromLTWH(0, 0, 200, 200), goodPaint);
rc.drawRect(Rect.fromLTWH(0, 0, 200, 200), goodPaint as engine.SurfacePaint);
await _checkScreenshot(rc, 'context_save_restore_clip');
});
}
......@@ -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:html' as html;
import 'package:ui/ui.dart' as ui;
import 'package:ui/src/engine.dart';
......@@ -23,7 +22,7 @@ Future<void> canvasScreenshot(RecordingCanvas rc, String fileName,
final html.Element sceneElement = html.Element.tag('flt-scene');
try {
sceneElement.append(engineCanvas.rootElement);
html.document.body.append(sceneElement);
html.document.body!.append(sceneElement);
await matchGoldenFile('$fileName.png',
region: region, maxDiffRatePercent: maxDiffRatePercent, write: write);
} finally {
......
......@@ -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:html' as html;
import 'package:test/bootstrap/browser.dart';
......@@ -16,7 +15,7 @@ void main() {
void testMain() {
test('screenshot test reports failure', () async {
html.document.body.innerHtml = 'Text that does not appear on the screenshot!';
html.document.body!.innerHtml = 'Text that does not appear on the screenshot!';
await matchGoldenFile('__local__/smoke_test.png', region: Rect.fromLTWH(0, 0, 320, 200));
});
}
......@@ -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:html' as html;
import 'package:test/bootstrap/browser.dart';
......@@ -20,8 +19,8 @@ void testMain() async {
await webOnlyInitializePlatform(assetManager: WebOnlyMockAssetManager());
test('screenshot test reports success', () async {
html.document.body.style.fontFamily = 'Roboto';
html.document.body.innerHtml = 'Hello world!';
html.document.body!.style.fontFamily = 'Roboto';
html.document.body!.innerHtml = 'Hello world!';
// TODO: https://github.com/flutter/flutter/issues/74702 , reduce webkit percentage.
await matchGoldenFile('__local__/smoke_test.png', region: Rect.fromLTWH(0, 0, 320, 200),
maxDiffRatePercent: browserEngine == BrowserEngine.webkit ? 3.0 : 0.28);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册