forked from firka/flutter
[web] more null-safe tests (flutter/engine#26712)
This commit is contained in:
@@ -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 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
@@ -29,7 +28,7 @@ void testMain() {
|
||||
canvas.drawVertices(
|
||||
vertices,
|
||||
ui.BlendMode.srcOver,
|
||||
ui.Paint(),
|
||||
CkPaint(),
|
||||
);
|
||||
vertices.delete();
|
||||
});
|
||||
@@ -37,7 +36,7 @@ void testMain() {
|
||||
}, skip: isIosSafari);
|
||||
}
|
||||
|
||||
ui.Vertices _testVertices() {
|
||||
CkVertices _testVertices() {
|
||||
return ui.Vertices(
|
||||
ui.VertexMode.triangles,
|
||||
<ui.Offset>[
|
||||
@@ -56,5 +55,5 @@ ui.Vertices _testVertices() {
|
||||
ui.Color.fromRGBO(0, 0, 255, 1.0),
|
||||
],
|
||||
indices: <int>[0, 1, 2],
|
||||
);
|
||||
) as CkVertices;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -103,7 +102,7 @@ void testMain() async {
|
||||
group('ImageCodecUrl', () {
|
||||
test('loads sample image from web', () async {
|
||||
final Uri uri = Uri.base.resolve('sample_image1.png');
|
||||
final HtmlCodec codec = await ui.webOnlyInstantiateImageCodecFromUrl(uri);
|
||||
final HtmlCodec codec = await ui.webOnlyInstantiateImageCodecFromUrl(uri) as HtmlCodec;
|
||||
final ui.FrameInfo frameInfo = await codec.getNextFrame();
|
||||
expect(frameInfo.image, isNotNull);
|
||||
expect(frameInfo.image.width, 100);
|
||||
@@ -114,7 +113,7 @@ void testMain() async {
|
||||
final HtmlCodec codec = await ui.webOnlyInstantiateImageCodecFromUrl(uri,
|
||||
chunkCallback: (int loaded, int total) {
|
||||
buffer.write('$loaded/$total,');
|
||||
});
|
||||
}) as HtmlCodec;
|
||||
await codec.getNextFrame();
|
||||
expect(buffer.toString(), '0/100,100/100,');
|
||||
});
|
||||
|
||||
@@ -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' show Future;
|
||||
import 'dart:html';
|
||||
|
||||
@@ -10,7 +9,7 @@ import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
|
||||
const MessageCodec<dynamic> codec = StandardMessageCodec();
|
||||
const StandardMessageCodec codec = StandardMessageCodec();
|
||||
const String testMessage = 'This is an tooltip.';
|
||||
const Map<dynamic, dynamic> testInput = <dynamic, dynamic>{
|
||||
'data': <dynamic, dynamic>{'message': testMessage}
|
||||
@@ -21,7 +20,7 @@ void main() {
|
||||
}
|
||||
|
||||
void testMain() {
|
||||
AccessibilityAnnouncements accessibilityAnnouncements;
|
||||
late AccessibilityAnnouncements accessibilityAnnouncements;
|
||||
|
||||
group('$AccessibilityAnnouncements', () {
|
||||
setUp(() {
|
||||
@@ -45,7 +44,7 @@ void testMain() {
|
||||
isNotNull,
|
||||
);
|
||||
final LabelElement input =
|
||||
document.getElementById('accessibility-element');
|
||||
document.getElementById('accessibility-element') as LabelElement;
|
||||
expect(input.getAttribute('aria-live'), equals('polite'));
|
||||
expect(input.text, testMessage);
|
||||
|
||||
|
||||
@@ -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.9
|
||||
@TestOn('chrome || safari || firefox')
|
||||
|
||||
import 'dart:async';
|
||||
@@ -88,7 +87,7 @@ void _testEngineSemanticsOwner() {
|
||||
|
||||
// Synthesize a click on the placeholder.
|
||||
final html.Element placeholder =
|
||||
appShadowRoot.querySelector('flt-semantics-placeholder');
|
||||
appShadowRoot.querySelector('flt-semantics-placeholder')!;
|
||||
|
||||
expect(placeholder.isConnected, isTrue);
|
||||
|
||||
@@ -101,7 +100,7 @@ void _testEngineSemanticsOwner() {
|
||||
|
||||
// On mobile semantics is enabled asynchronously.
|
||||
if (isMobile) {
|
||||
while (placeholder.isConnected) {
|
||||
while (placeholder.isConnected!) {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
}
|
||||
}
|
||||
@@ -114,7 +113,7 @@ void _testEngineSemanticsOwner() {
|
||||
expect(semantics().semanticsEnabled, isFalse);
|
||||
|
||||
final html.Element placeholder =
|
||||
appShadowRoot.querySelector('flt-semantics-placeholder');
|
||||
appShadowRoot.querySelector('flt-semantics-placeholder')!;
|
||||
|
||||
expect(placeholder.isConnected, isTrue);
|
||||
|
||||
@@ -159,12 +158,12 @@ void _testEngineSemanticsOwner() {
|
||||
// Create
|
||||
renderLabel('Hello');
|
||||
|
||||
final Map<int, SemanticsObject> tree = semantics().debugSemanticsTree;
|
||||
final Map<int, SemanticsObject> tree = semantics().debugSemanticsTree!;
|
||||
expect(tree.length, 2);
|
||||
expect(tree[0].id, 0);
|
||||
expect(tree[0].element.tagName.toLowerCase(), 'flt-semantics');
|
||||
expect(tree[1].id, 1);
|
||||
expect(tree[1].label, 'Hello');
|
||||
expect(tree[0]!.id, 0);
|
||||
expect(tree[0]!.element.tagName.toLowerCase(), 'flt-semantics');
|
||||
expect(tree[1]!.id, 1);
|
||||
expect(tree[1]!.label, 'Hello');
|
||||
|
||||
expectSemanticsTree('''
|
||||
<sem style="$rootSemanticStyle">
|
||||
@@ -383,9 +382,9 @@ void _testContainer() {
|
||||
</sem>''');
|
||||
|
||||
final html.Element parentElement =
|
||||
appShadowRoot.querySelector('flt-semantics');
|
||||
appShadowRoot.querySelector('flt-semantics')!;
|
||||
final html.Element container =
|
||||
appShadowRoot.querySelector('flt-semantics-container');
|
||||
appShadowRoot.querySelector('flt-semantics-container')!;
|
||||
|
||||
if (isMacOrIOS) {
|
||||
expect(parentElement.style.top, '0px');
|
||||
@@ -431,9 +430,9 @@ void _testContainer() {
|
||||
</sem>''');
|
||||
|
||||
final html.Element parentElement =
|
||||
appShadowRoot.querySelector('flt-semantics');
|
||||
appShadowRoot.querySelector('flt-semantics')!;
|
||||
final html.Element container =
|
||||
appShadowRoot.querySelector('flt-semantics-container');
|
||||
appShadowRoot.querySelector('flt-semantics-container')!;
|
||||
|
||||
expect(parentElement.style.transform, 'matrix(1, 0, 0, 1, 10, 10)');
|
||||
expect(parentElement.style.transformOrigin, '0px 0px 0px');
|
||||
@@ -477,9 +476,9 @@ void _testContainer() {
|
||||
}
|
||||
|
||||
final html.Element parentElement =
|
||||
appShadowRoot.querySelector('flt-semantics');
|
||||
appShadowRoot.querySelector('flt-semantics')!;
|
||||
final html.Element container =
|
||||
appShadowRoot.querySelector('flt-semantics-container');
|
||||
appShadowRoot.querySelector('flt-semantics-container')!;
|
||||
|
||||
if (isMacOrIOS) {
|
||||
expect(parentElement.style.top, '0px');
|
||||
@@ -550,12 +549,12 @@ void _testVerticalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element scrollable = findScrollable();
|
||||
final html.Element? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's less content than the available size the neutral scrollTop
|
||||
// is 0.
|
||||
expect(scrollable.scrollTop, 0);
|
||||
expect(scrollable!.scrollTop, 0);
|
||||
|
||||
semantics().semanticsEnabled = false;
|
||||
});
|
||||
@@ -574,7 +573,7 @@ void _testVerticalScrolling() {
|
||||
final Zone testZone = Zone.current;
|
||||
|
||||
ui.window.onSemanticsAction =
|
||||
(int id, ui.SemanticsAction action, ByteData args) {
|
||||
(int id, ui.SemanticsAction action, ByteData? args) {
|
||||
idLogController.add(id);
|
||||
actionLogController.add(action);
|
||||
testZone.run(() {
|
||||
@@ -620,7 +619,7 @@ void _testVerticalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element scrollable = findScrollable();
|
||||
final html.Element? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's more content than the available size the neutral scrollTop
|
||||
@@ -633,7 +632,7 @@ void _testVerticalScrolling() {
|
||||
browserMaxScrollDiff = 1;
|
||||
}
|
||||
|
||||
expect(scrollable.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
|
||||
expect(scrollable!.scrollTop >= (10 - browserMaxScrollDiff), isTrue);
|
||||
|
||||
scrollable.scrollTop = 20;
|
||||
expect(scrollable.scrollTop, 20);
|
||||
@@ -702,12 +701,12 @@ void _testHorizontalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element scrollable = findScrollable();
|
||||
final html.Element? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's less content than the available size the neutral
|
||||
// scrollLeft is 0.
|
||||
expect(scrollable.scrollLeft, 0);
|
||||
expect(scrollable!.scrollLeft, 0);
|
||||
|
||||
semantics().semanticsEnabled = false;
|
||||
});
|
||||
@@ -753,7 +752,7 @@ void _testHorizontalScrolling() {
|
||||
</sem-c>
|
||||
</sem>''');
|
||||
|
||||
final html.Element scrollable = findScrollable();
|
||||
final html.Element? scrollable = findScrollable();
|
||||
expect(scrollable, isNotNull);
|
||||
|
||||
// When there's more content than the available size the neutral scrollTop
|
||||
@@ -765,7 +764,7 @@ void _testHorizontalScrolling() {
|
||||
operatingSystem == OperatingSystem.macOs) {
|
||||
browserMaxScrollDiff = 1;
|
||||
}
|
||||
expect(scrollable.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
|
||||
expect(scrollable!.scrollLeft >= (10 - browserMaxScrollDiff), isTrue);
|
||||
|
||||
scrollable.scrollLeft = 20;
|
||||
expect(scrollable.scrollLeft, 20);
|
||||
@@ -835,7 +834,7 @@ void _testIncrementables() {
|
||||
<input aria-valuenow="1" aria-valuetext="d" aria-valuemax="2" aria-valuemin="1">
|
||||
</sem>''');
|
||||
|
||||
final html.InputElement input = appShadowRoot.querySelector('input');
|
||||
final html.InputElement input = appShadowRoot.querySelector('input') as html.InputElement;
|
||||
input.value = '2';
|
||||
input.dispatchEvent(html.Event('change'));
|
||||
|
||||
@@ -869,7 +868,7 @@ void _testIncrementables() {
|
||||
<input aria-valuenow="1" aria-valuetext="d" aria-valuemax="1" aria-valuemin="0">
|
||||
</sem>''');
|
||||
|
||||
final html.InputElement input = appShadowRoot.querySelector('input');
|
||||
final html.InputElement input = appShadowRoot.querySelector('input') as html.InputElement;
|
||||
input.value = '0';
|
||||
input.dispatchEvent(html.Event('change'));
|
||||
|
||||
@@ -963,7 +962,7 @@ void _testTextField() {
|
||||
semantics().updateSemantics(builder.build());
|
||||
|
||||
final html.Element textField =
|
||||
appShadowRoot.querySelector('input[data-semantics-role="text-field"]');
|
||||
appShadowRoot.querySelector('input[data-semantics-role="text-field"]')!;
|
||||
|
||||
expect(appShadowRoot.activeElement, isNot(textField));
|
||||
|
||||
@@ -1491,10 +1490,10 @@ void updateNode(
|
||||
String increasedValue = '',
|
||||
String decreasedValue = '',
|
||||
ui.TextDirection textDirection = ui.TextDirection.ltr,
|
||||
Float64List transform,
|
||||
Int32List childrenInTraversalOrder,
|
||||
Int32List childrenInHitTestOrder,
|
||||
Int32List additionalActions,
|
||||
Float64List? transform,
|
||||
Int32List? childrenInTraversalOrder,
|
||||
Int32List? childrenInHitTestOrder,
|
||||
Int32List? additionalActions,
|
||||
}) {
|
||||
transform ??= Float64List.fromList(Matrix4.identity().storage);
|
||||
childrenInTraversalOrder ??= Int32List(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:typed_data';
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.6
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
@@ -15,7 +14,7 @@ void main() {
|
||||
|
||||
void testMain() {
|
||||
setUp(() async {
|
||||
await initializeEngine();
|
||||
initializeEngine();
|
||||
});
|
||||
|
||||
test('collects frame timings', () 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:html' as html;
|
||||
|
||||
@@ -22,7 +21,7 @@ void main() {
|
||||
}
|
||||
|
||||
void testMain() {
|
||||
PersistedPlatformView view;
|
||||
late PersistedPlatformView view;
|
||||
|
||||
group('PersistedPlatformView', () {
|
||||
setUp(() 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 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine/html/shaders/normalized_gradient.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 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
@@ -25,7 +24,7 @@ void testMain() {
|
||||
')';
|
||||
|
||||
setUpAll(() async {
|
||||
await webOnlyInitializeEngine();
|
||||
webOnlyInitializeEngine();
|
||||
});
|
||||
|
||||
group('Shader Declarations', () {
|
||||
|
||||
@@ -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 'dart:js_util' as js_util;
|
||||
@@ -48,7 +47,7 @@ void testMain() async {
|
||||
}
|
||||
}
|
||||
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 {
|
||||
@@ -68,7 +67,7 @@ void testMain() async {
|
||||
final RecordingCanvas rc =
|
||||
RecordingCanvas(const Rect.fromLTRB(0, 0, 400, 300));
|
||||
rc.save();
|
||||
rc.drawImage(createTestImage(), Offset(0, 0), new Paint());
|
||||
rc.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_image');
|
||||
});
|
||||
@@ -79,7 +78,7 @@ void testMain() async {
|
||||
rc.save();
|
||||
rc.translate(50.0, 100.0);
|
||||
rc.rotate(math.pi / 4.0);
|
||||
rc.drawImage(createTestImage(), Offset(0, 0), new Paint());
|
||||
rc.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_image_with_transform');
|
||||
});
|
||||
@@ -90,7 +89,7 @@ void testMain() async {
|
||||
rc.save();
|
||||
rc.translate(50.0, 100.0);
|
||||
rc.rotate(math.pi / 4.0);
|
||||
rc.drawImage(createTestImage(), Offset(30, 20), new Paint());
|
||||
rc.drawImage(createTestImage(), Offset(30, 20), SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_image_with_transform_and_offset');
|
||||
});
|
||||
@@ -105,7 +104,7 @@ void testMain() async {
|
||||
double testWidth = testImage.width.toDouble();
|
||||
double testHeight = testImage.height.toDouble();
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), new Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_image_rect_with_transform');
|
||||
});
|
||||
@@ -121,7 +120,7 @@ void testMain() async {
|
||||
testImage,
|
||||
Rect.fromLTRB(testWidth / 2, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight),
|
||||
new Paint());
|
||||
SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_image_rect_with_source');
|
||||
});
|
||||
@@ -139,7 +138,7 @@ void testMain() async {
|
||||
testImage,
|
||||
Rect.fromLTRB(testWidth / 2, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight),
|
||||
new Paint());
|
||||
SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_image_rect_with_source_and_clip');
|
||||
});
|
||||
@@ -157,7 +156,7 @@ void testMain() async {
|
||||
testImage,
|
||||
Rect.fromLTRB(testWidth / 2, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight),
|
||||
new Paint());
|
||||
SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_image_rect_with_transform_source');
|
||||
});
|
||||
@@ -172,11 +171,11 @@ void testMain() async {
|
||||
double testWidth = testImage.width.toDouble();
|
||||
double testHeight = testImage.height.toDouble();
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), new Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.drawCircle(
|
||||
Offset(100, 100),
|
||||
50.0,
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color.fromARGB(128, 0, 0, 0));
|
||||
rc.restore();
|
||||
@@ -195,11 +194,11 @@ void testMain() async {
|
||||
rc.drawCircle(
|
||||
Offset(100, 100),
|
||||
50.0,
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color.fromARGB(128, 0, 0, 0));
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), new Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.restore();
|
||||
await _checkScreenshot(rc, 'draw_circle_below_image');
|
||||
});
|
||||
@@ -215,11 +214,11 @@ void testMain() async {
|
||||
double testHeight = testImage.height.toDouble();
|
||||
rc.clipRect(Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), new Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.drawCircle(
|
||||
Offset(100, 100),
|
||||
50.0,
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color.fromARGB(128, 0, 0, 0));
|
||||
rc.restore();
|
||||
@@ -241,11 +240,11 @@ void testMain() async {
|
||||
rc.translate(-100, -100);
|
||||
rc.clipRect(Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), new Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.drawCircle(
|
||||
Offset(100, 100),
|
||||
50.0,
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color.fromARGB(128, 0, 0, 0));
|
||||
rc.restore();
|
||||
@@ -268,11 +267,11 @@ void testMain() async {
|
||||
rc.translate(-100, -100);
|
||||
rc.clipRect(Rect.fromLTRB(75, 75, 160, 160), ClipOp.intersect);
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), new Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.drawCircle(
|
||||
Offset(100, 100),
|
||||
50.0,
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color.fromARGB(128, 0, 0, 0));
|
||||
rc.restore();
|
||||
@@ -291,11 +290,11 @@ void testMain() async {
|
||||
double testHeight = testImage.height.toDouble();
|
||||
rc.clipRRect(RRect.fromLTRBR(75, 75, 160, 160, Radius.circular(5)));
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.drawCircle(
|
||||
Offset(100, 100),
|
||||
50.0,
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color.fromARGB(128, 0, 0, 0));
|
||||
rc.restore();
|
||||
@@ -318,11 +317,11 @@ void testMain() async {
|
||||
path.lineTo(160, 160);
|
||||
rc.clipPath(path);
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), Paint());
|
||||
Rect.fromLTRB(100, 30, 2 * testWidth, 2 * testHeight), SurfacePaint());
|
||||
rc.drawCircle(
|
||||
Offset(100, 100),
|
||||
50.0,
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color.fromARGB(128, 0, 0, 0));
|
||||
rc.restore();
|
||||
@@ -349,10 +348,10 @@ void testMain() async {
|
||||
paragraph1.layout(const ParagraphConstraints(width: 400.0));
|
||||
rc.drawParagraph(paragraph1, const Offset(20, 100));
|
||||
rc.drawImageRect(testImage, Rect.fromLTRB(0, 0, testWidth, testHeight),
|
||||
Rect.fromLTRB(100, 100, 200, 200), Paint());
|
||||
Rect.fromLTRB(100, 100, 200, 200), SurfacePaint());
|
||||
rc.drawRect(
|
||||
Rect.fromLTWH(50, 50, 100, 200),
|
||||
Paint()
|
||||
SurfacePaint()
|
||||
..strokeWidth = 3
|
||||
..color = Color(0xA0000000));
|
||||
final Color cyan = Color(0xFF0097A7);
|
||||
@@ -378,7 +377,7 @@ void testMain() async {
|
||||
Image testImage = createNineSliceImage();
|
||||
canvas.clipRect(Rect.fromLTWH(0, 0, 420, 200));
|
||||
canvas.drawImageNine(testImage, Rect.fromLTWH(20, 20, 20, 20),
|
||||
Rect.fromLTWH(20, 20, 400, 400), Paint());
|
||||
Rect.fromLTWH(20, 20, 400, 400), SurfacePaint());
|
||||
Picture picture = recorder.endRecording();
|
||||
|
||||
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
|
||||
@@ -387,8 +386,8 @@ void testMain() async {
|
||||
// Wrap in <flt-scene> so that our CSS selectors kick in.
|
||||
final html.Element sceneElement = html.Element.tag('flt-scene');
|
||||
try {
|
||||
sceneElement.append(builder.build().webOnlyRootElement);
|
||||
html.document.body.append(sceneElement);
|
||||
sceneElement.append(builder.build().webOnlyRootElement!);
|
||||
html.document.body!.append(sceneElement);
|
||||
await matchGoldenFile('draw_nine_slice.png',
|
||||
region: region, maxDiffRatePercent: 0);
|
||||
} finally {
|
||||
@@ -411,7 +410,7 @@ void testMain() async {
|
||||
// of the image are 40x40. Drawing into a destination that is smaller
|
||||
// than that will not provide enough room to draw the center portion.
|
||||
canvas.drawImageNine(testImage, Rect.fromLTWH(20, 20, 20, 20),
|
||||
Rect.fromLTWH(20, 20, 36, 36), Paint());
|
||||
Rect.fromLTWH(20, 20, 36, 36), SurfacePaint());
|
||||
Picture picture = recorder.endRecording();
|
||||
|
||||
final SurfaceSceneBuilder builder = SurfaceSceneBuilder();
|
||||
@@ -420,8 +419,8 @@ void testMain() async {
|
||||
// Wrap in <flt-scene> so that our CSS selectors kick in.
|
||||
final html.Element sceneElement = html.Element.tag('flt-scene');
|
||||
try {
|
||||
sceneElement.append(builder.build().webOnlyRootElement);
|
||||
html.document.body.append(sceneElement);
|
||||
sceneElement.append(builder.build().webOnlyRootElement!);
|
||||
html.document.body!.append(sceneElement);
|
||||
await matchGoldenFile('draw_nine_slice_empty_center.png',
|
||||
region: region, maxDiffRatePercent: 0);
|
||||
} finally {
|
||||
@@ -447,7 +446,7 @@ void testMain() async {
|
||||
..lineTo(50, 30)
|
||||
..lineTo(10, 30)
|
||||
..close());
|
||||
canvas.drawImage(createNineSliceImage(), Offset.zero, Paint());
|
||||
canvas.drawImage(createNineSliceImage(), Offset.zero, SurfacePaint());
|
||||
await _checkScreenshot(canvas, 'draw_clipped_and_transformed_image',
|
||||
region: region, maxDiffRatePercent: 1.0);
|
||||
});
|
||||
@@ -457,12 +456,12 @@ void testMain() async {
|
||||
final Rect region = const Rect.fromLTRB(0, 0, 200, 200);
|
||||
final RecordingCanvas canvas = RecordingCanvas(region);
|
||||
canvas.translate(10, 10);
|
||||
canvas.drawImage(createTestImage(), Offset(0, 0), new Paint());
|
||||
canvas.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
|
||||
Matrix4 transform = Matrix4.identity()
|
||||
..setRotationY(0.8)
|
||||
..setEntry(3, 2, 0.0005); // perspective
|
||||
canvas.transform(transform.storage);
|
||||
canvas.drawImage(createTestImage(), Offset(0, 100), new Paint());
|
||||
canvas.drawImage(createTestImage(), Offset(0, 100), SurfacePaint());
|
||||
await _checkScreenshot(canvas, 'draw_3d_image',
|
||||
region: region,
|
||||
maxDiffRatePercent: 6.0,
|
||||
@@ -473,17 +472,17 @@ void testMain() async {
|
||||
test('Should render image with perspective inside clip area', () async {
|
||||
final Rect region = const Rect.fromLTRB(0, 0, 200, 200);
|
||||
final RecordingCanvas canvas = RecordingCanvas(region);
|
||||
canvas.drawRect(region, Paint()..color = Color(0xFFE0E0E0));
|
||||
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0));
|
||||
canvas.translate(10, 10);
|
||||
canvas.drawImage(createTestImage(), Offset(0, 0), new Paint());
|
||||
canvas.drawImage(createTestImage(), Offset(0, 0), SurfacePaint());
|
||||
Matrix4 transform = Matrix4.identity()
|
||||
..setRotationY(0.8)
|
||||
..setEntry(3, 2, 0.0005); // perspective
|
||||
canvas.transform(transform.storage);
|
||||
canvas.clipRect(region, ClipOp.intersect);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 0, 100, 200), Paint()..color = Color(0x801080E0));
|
||||
canvas.drawImage(createTestImage(), Offset(0, 100), new Paint());
|
||||
canvas.drawRect(Rect.fromLTWH(50, 150, 50, 20), Paint()..color = Color(0x80000000));
|
||||
canvas.drawRect(Rect.fromLTWH(0, 0, 100, 200), SurfacePaint()..color = Color(0x801080E0));
|
||||
canvas.drawImage(createTestImage(), Offset(0, 100), SurfacePaint());
|
||||
canvas.drawRect(Rect.fromLTWH(50, 150, 50, 20), SurfacePaint()..color = Color(0x80000000));
|
||||
await _checkScreenshot(canvas, 'draw_3d_image_clipped',
|
||||
region: region,
|
||||
maxDiffRatePercent: 5.0,
|
||||
@@ -493,21 +492,21 @@ void testMain() async {
|
||||
test('Should render rect with perspective transform', () async {
|
||||
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
|
||||
final RecordingCanvas canvas = RecordingCanvas(region);
|
||||
canvas.drawRect(region, Paint()..color = Color(0xFFE0E0E0));
|
||||
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFE0E0E0));
|
||||
canvas.translate(20, 20);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 0, 100, 40),
|
||||
Paint()..color = Color(0xFF000000));
|
||||
SurfacePaint()..color = Color(0xFF000000));
|
||||
Matrix4 transform = Matrix4.identity()
|
||||
..setRotationY(0.8)
|
||||
..setEntry(3, 2, 0.001); // perspective
|
||||
canvas.transform(transform.storage);
|
||||
canvas.clipRect(region, ClipOp.intersect);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 60, 120, 40), Paint()..color = Color(0x801080E0));
|
||||
canvas.drawRect(Rect.fromLTWH(300, 250, 120, 40), Paint()..color = Color(0x80E010E0));
|
||||
canvas.drawRect(Rect.fromLTWH(0, 60, 120, 40), SurfacePaint()..color = Color(0x801080E0));
|
||||
canvas.drawRect(Rect.fromLTWH(300, 250, 120, 40), SurfacePaint()..color = Color(0x80E010E0));
|
||||
canvas.drawRRect(RRect.fromRectAndRadius(Rect.fromLTWH(0, 120, 160, 40), Radius.circular(5)),
|
||||
Paint()..color = Color(0x801080E0));
|
||||
SurfacePaint()..color = Color(0x801080E0));
|
||||
canvas.drawRRect(RRect.fromRectAndRadius(Rect.fromLTWH(300, 320, 90, 40), Radius.circular(20)),
|
||||
Paint()..color = Color(0x80E010E0));
|
||||
SurfacePaint()..color = Color(0x80E010E0));
|
||||
await _checkScreenshot(canvas, 'draw_3d_rect_clipped',
|
||||
region: region,
|
||||
maxDiffRatePercent: 1.0,
|
||||
@@ -517,22 +516,22 @@ void testMain() async {
|
||||
test('Should render color and ovals with perspective transform', () async {
|
||||
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
|
||||
final RecordingCanvas canvas = RecordingCanvas(region);
|
||||
canvas.drawRect(region, Paint()..color = Color(0xFFFF0000));
|
||||
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000));
|
||||
canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src);
|
||||
canvas.translate(20, 20);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 0, 100, 40),
|
||||
Paint()..color = Color(0xFF000000));
|
||||
SurfacePaint()..color = Color(0xFF000000));
|
||||
Matrix4 transform = Matrix4.identity()
|
||||
..setRotationY(0.8)
|
||||
..setEntry(3, 2, 0.001); // perspective
|
||||
canvas.transform(transform.storage);
|
||||
canvas.clipRect(region, ClipOp.intersect);
|
||||
canvas.drawOval(Rect.fromLTWH(0, 120, 130, 40),
|
||||
Paint()..color = Color(0x801080E0));
|
||||
SurfacePaint()..color = Color(0x801080E0));
|
||||
canvas.drawOval(Rect.fromLTWH(300, 290, 90, 40),
|
||||
Paint()..color = Color(0x80E010E0));
|
||||
canvas.drawCircle(Offset(60, 240), 50, Paint()..color = Color(0x801080E0));
|
||||
canvas.drawCircle(Offset(360, 370), 30, Paint()..color = Color(0x80E010E0));
|
||||
SurfacePaint()..color = Color(0x80E010E0));
|
||||
canvas.drawCircle(Offset(60, 240), 50, SurfacePaint()..color = Color(0x801080E0));
|
||||
canvas.drawCircle(Offset(360, 370), 30, SurfacePaint()..color = Color(0x80E010E0));
|
||||
await _checkScreenshot(canvas, 'draw_3d_oval_clipped',
|
||||
region: region,
|
||||
maxDiffRatePercent: 1.0,
|
||||
@@ -542,29 +541,29 @@ void testMain() async {
|
||||
test('Should render path with perspective transform', () async {
|
||||
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
|
||||
final RecordingCanvas canvas = RecordingCanvas(region);
|
||||
canvas.drawRect(region, Paint()..color = Color(0xFFFF0000));
|
||||
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000));
|
||||
canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src);
|
||||
canvas.translate(20, 20);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 0, 100, 20),
|
||||
Paint()..color = Color(0xFF000000));
|
||||
SurfacePaint()..color = Color(0xFF000000));
|
||||
Matrix4 transform = Matrix4.identity()
|
||||
..setRotationY(0.8)
|
||||
..setEntry(3, 2, 0.001); // perspective
|
||||
canvas.transform(transform.storage);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 120, 130, 40),
|
||||
Paint()..color = Color(0x801080E0));
|
||||
SurfacePaint()..color = Color(0x801080E0));
|
||||
canvas.drawOval(Rect.fromLTWH(300, 290, 90, 40),
|
||||
Paint()..color = Color(0x80E010E0));
|
||||
SurfacePaint()..color = Color(0x80E010E0));
|
||||
Path path = Path();
|
||||
path.moveTo(50, 50);
|
||||
path.lineTo(100, 50);
|
||||
path.lineTo(100, 100);
|
||||
path.close();
|
||||
canvas.drawPath(path, Paint()..color = Color(0x801080E0));
|
||||
canvas.drawPath(path, SurfacePaint()..color = Color(0x801080E0));
|
||||
|
||||
canvas.drawCircle(Offset(50, 50), 4, Paint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 100), 4, Paint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 50), 4, Paint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(50, 50), 4, SurfacePaint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 100), 4, SurfacePaint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 50), 4, SurfacePaint()..color = Color(0xFF000000));
|
||||
await _checkScreenshot(canvas, 'draw_3d_path',
|
||||
region: region,
|
||||
maxDiffRatePercent: 1.0,
|
||||
@@ -574,30 +573,30 @@ void testMain() async {
|
||||
test('Should render path with perspective transform', () async {
|
||||
final Rect region = const Rect.fromLTRB(0, 0, 400, 400);
|
||||
final RecordingCanvas canvas = RecordingCanvas(region);
|
||||
canvas.drawRect(region, Paint()..color = Color(0xFFFF0000));
|
||||
canvas.drawRect(region, SurfacePaint()..color = Color(0xFFFF0000));
|
||||
canvas.drawColor(Color(0xFFE0E0E0), BlendMode.src);
|
||||
canvas.translate(20, 20);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 0, 100, 20),
|
||||
Paint()..color = Color(0xFF000000));
|
||||
SurfacePaint()..color = Color(0xFF000000));
|
||||
Matrix4 transform = Matrix4.identity()
|
||||
..setRotationY(0.8)
|
||||
..setEntry(3, 2, 0.001); // perspective
|
||||
canvas.transform(transform.storage);
|
||||
//canvas.clipRect(region, ClipOp.intersect);
|
||||
canvas.drawRect(Rect.fromLTWH(0, 120, 130, 40),
|
||||
Paint()..color = Color(0x801080E0));
|
||||
SurfacePaint()..color = Color(0x801080E0));
|
||||
canvas.drawOval(Rect.fromLTWH(300, 290, 90, 40),
|
||||
Paint()..color = Color(0x80E010E0));
|
||||
SurfacePaint()..color = Color(0x80E010E0));
|
||||
Path path = Path();
|
||||
path.moveTo(50, 50);
|
||||
path.lineTo(100, 50);
|
||||
path.lineTo(100, 100);
|
||||
path.close();
|
||||
canvas.drawPath(path, Paint()..color = Color(0x801080E0));
|
||||
canvas.drawPath(path, SurfacePaint()..color = Color(0x801080E0));
|
||||
|
||||
canvas.drawCircle(Offset(50, 50), 4, Paint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 100), 4, Paint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 50), 4, Paint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(50, 50), 4, SurfacePaint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 100), 4, SurfacePaint()..color = Color(0xFF000000));
|
||||
canvas.drawCircle(Offset(100, 50), 4, SurfacePaint()..color = Color(0xFF000000));
|
||||
await _checkScreenshot(canvas, 'draw_3d_path_clipped',
|
||||
region: region,
|
||||
maxDiffRatePercent: 1.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:html' as html;
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
@@ -19,7 +18,7 @@ void main() {
|
||||
void testMain() async {
|
||||
final Rect region = Rect.fromLTWH(0, 0, 150, 420);
|
||||
|
||||
BitmapCanvas canvas;
|
||||
late BitmapCanvas canvas;
|
||||
|
||||
setUp(() {
|
||||
canvas = BitmapCanvas(region, RenderStrategy());
|
||||
@@ -33,7 +32,7 @@ void testMain() async {
|
||||
|
||||
paintRects(canvas);
|
||||
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_rect_flipped.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 'package:test/bootstrap/browser.dart';
|
||||
@@ -19,7 +18,7 @@ void main() {
|
||||
void testMain() async {
|
||||
final Rect region = Rect.fromLTWH(8, 8, 500, 100); // Compensate for old scuba tester padding
|
||||
|
||||
BitmapCanvas canvas;
|
||||
late BitmapCanvas canvas;
|
||||
|
||||
final SurfacePaintData niceRRectPaint = SurfacePaintData()
|
||||
..color = const Color.fromRGBO(250, 186, 218, 1.0) // #fabada
|
||||
@@ -48,7 +47,7 @@ void testMain() async {
|
||||
niceRRectPaint);
|
||||
}
|
||||
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_rrect_round_square.png', region: region);
|
||||
});
|
||||
|
||||
@@ -61,7 +60,7 @@ void testMain() async {
|
||||
Radius.circular(30)),
|
||||
niceRRectPaint);
|
||||
canvas.drawPath(Path()..moveTo(0, 0)..lineTo(20, 0), niceRRectPaint);
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_rrect_flipped.png',
|
||||
region: Rect.fromLTWH(0, 0, 100, 200));
|
||||
});
|
||||
@@ -78,7 +77,7 @@ void testMain() async {
|
||||
canvas.drawRRect(rrect, niceRRectPaint);
|
||||
}
|
||||
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_rrect_overlapping_radius.png', region: region);
|
||||
});
|
||||
|
||||
@@ -101,7 +100,7 @@ void testMain() async {
|
||||
canvas.drawDRRect(outerRRect, innerRRect, niceRRectPaint);
|
||||
}
|
||||
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_drrect_overlapping_radius.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 'package:test/bootstrap/browser.dart';
|
||||
@@ -19,7 +18,7 @@ void main() {
|
||||
void testMain() async {
|
||||
final Rect region = Rect.fromLTWH(0, 0, 300, 300);
|
||||
|
||||
BitmapCanvas canvas;
|
||||
late BitmapCanvas canvas;
|
||||
|
||||
setUp(() {
|
||||
canvas = BitmapCanvas(region, RenderStrategy());
|
||||
@@ -33,7 +32,7 @@ void testMain() async {
|
||||
|
||||
paintStrokeJoins(canvas);
|
||||
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_stroke_joins.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:math' as math;
|
||||
|
||||
@@ -20,7 +19,7 @@ void main() {
|
||||
void testMain() async {
|
||||
final Rect region = Rect.fromLTWH(0, 0, 300, 300);
|
||||
|
||||
BitmapCanvas canvas;
|
||||
late BitmapCanvas canvas;
|
||||
|
||||
setUp(() {
|
||||
canvas = BitmapCanvas(region, RenderStrategy());
|
||||
@@ -34,7 +33,7 @@ void testMain() async {
|
||||
|
||||
paintSideBySideRects(canvas);
|
||||
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_stroke_rects.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 'package:test/bootstrap/browser.dart';
|
||||
@@ -19,7 +18,7 @@ void main() {
|
||||
void testMain() async {
|
||||
final Rect region = Rect.fromLTWH(0, 0, 500, 500);
|
||||
|
||||
BitmapCanvas canvas;
|
||||
late BitmapCanvas canvas;
|
||||
|
||||
setUp(() {
|
||||
canvas = BitmapCanvas(region, RenderStrategy());
|
||||
@@ -31,7 +30,7 @@ void testMain() async {
|
||||
|
||||
test('draws paths using nonzero and evenodd winding rules', () async {
|
||||
paintPaths(canvas);
|
||||
html.document.body.append(canvas.rootElement);
|
||||
html.document.body!.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_path_winding.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 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/ui.dart';
|
||||
@@ -23,7 +22,7 @@ void testMain() async {
|
||||
final Rect region = const Rect.fromLTRB(0, 0, 400, 300);
|
||||
final RecordingCanvas canvas = RecordingCanvas(region);
|
||||
final Rect titleRect = Rect.fromLTWH(20, 0, 50, 20);
|
||||
final Paint paint = Paint()
|
||||
final SurfacePaint paint = SurfacePaint()
|
||||
..style = PaintingStyle.stroke
|
||||
..color = const Color(0xff000000)
|
||||
..strokeWidth = 1;
|
||||
|
||||
@@ -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';
|
||||
@@ -25,13 +24,13 @@ void testMain() async {
|
||||
RenderStrategy());
|
||||
final RecordingCanvas canvas = RecordingCanvas(canvasBounds);
|
||||
|
||||
Paint paint = Paint()
|
||||
SurfacePaint paint = SurfacePaint()
|
||||
..color = const Color(0x7F7F7F7F)
|
||||
..style = PaintingStyle.fill;
|
||||
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
paint = Paint()
|
||||
paint = SurfacePaint()
|
||||
..strokeWidth = 2.0
|
||||
..color = const Color(0xFF7F007F)
|
||||
..style = PaintingStyle.stroke;
|
||||
@@ -39,7 +38,7 @@ void testMain() async {
|
||||
canvas.drawPath(path, paint);
|
||||
canvas.endRecording();
|
||||
|
||||
html.document.body.append(bitmapCanvas.rootElement);
|
||||
html.document.body!.append(bitmapCanvas.rootElement);
|
||||
canvas.apply(bitmapCanvas, canvasBounds);
|
||||
await matchGoldenFile('$scubaFileName.png', region: region);
|
||||
bitmapCanvas.rootElement.remove();
|
||||
|
||||
@@ -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';
|
||||
@@ -23,7 +22,7 @@ void main() {
|
||||
void testMain() async {
|
||||
final Rect region = Rect.fromLTWH(0, 0, 550, 300);
|
||||
|
||||
SurfaceSceneBuilder builder;
|
||||
late SurfaceSceneBuilder builder;
|
||||
|
||||
setUpStableTestFonts();
|
||||
|
||||
@@ -32,7 +31,7 @@ void testMain() async {
|
||||
});
|
||||
|
||||
void _paintShapeOutline() {
|
||||
final EnginePictureRecorder recorder = PictureRecorder();
|
||||
final EnginePictureRecorder recorder = EnginePictureRecorder();
|
||||
final RecordingCanvas canvas = recorder.beginRecording(Rect.largest);
|
||||
canvas.drawRect(
|
||||
const Rect.fromLTRB(0.0, 0.0, 20.0, 20.0),
|
||||
@@ -81,7 +80,7 @@ void testMain() async {
|
||||
..addRect(const Rect.fromLTRB(0, 0, 20, 20));
|
||||
builder.pushOffset(offset.dx, offset.dy);
|
||||
|
||||
final EnginePictureRecorder recorder = PictureRecorder();
|
||||
final EnginePictureRecorder recorder = EnginePictureRecorder();
|
||||
final RecordingCanvas canvas = recorder.beginRecording(Rect.largest);
|
||||
canvas
|
||||
.debugEnforceArbitraryPaint(); // make sure DOM canvas doesn't take over
|
||||
@@ -107,7 +106,7 @@ void testMain() async {
|
||||
..close();
|
||||
builder.pushOffset(offset.dx, offset.dy);
|
||||
|
||||
final EnginePictureRecorder recorder = PictureRecorder();
|
||||
final EnginePictureRecorder recorder = EnginePictureRecorder();
|
||||
final RecordingCanvas canvas = recorder.beginRecording(Rect.largest);
|
||||
canvas
|
||||
.debugEnforceArbitraryPaint(); // make sure DOM canvas doesn't take over
|
||||
@@ -157,8 +156,8 @@ void testMain() async {
|
||||
|
||||
builder.pop();
|
||||
|
||||
final html.Element sceneElement = builder.build().webOnlyRootElement;
|
||||
html.document.body.append(sceneElement);
|
||||
final html.Element sceneElement = builder.build().webOnlyRootElement!;
|
||||
html.document.body!.append(sceneElement);
|
||||
|
||||
await matchGoldenFile(
|
||||
'shadows.png',
|
||||
|
||||
@@ -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() {
|
||||
group('$FontManager', () {
|
||||
FontManager fontManager;
|
||||
late FontManager fontManager;
|
||||
const String _testFontUrl = 'packages/ui/assets/ahem.ttf';
|
||||
|
||||
setUp(() {
|
||||
@@ -24,7 +23,7 @@ void testMain() {
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
html.document.fonts.clear();
|
||||
html.document.fonts!.clear();
|
||||
});
|
||||
|
||||
group('regular special characters', () {
|
||||
@@ -35,9 +34,9 @@ void testMain() {
|
||||
fontManager.registerAsset(
|
||||
_testFontFamily, 'url($_testFontUrl)', const <String, String>{});
|
||||
await fontManager.ensureFontsLoaded();
|
||||
html.document.fonts
|
||||
html.document.fonts!
|
||||
.forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) {
|
||||
fontFamilyList.add(f.family);
|
||||
fontFamilyList.add(f.family!);
|
||||
});
|
||||
|
||||
expect(fontFamilyList.length, equals(1));
|
||||
@@ -53,9 +52,9 @@ void testMain() {
|
||||
fontManager.registerAsset(
|
||||
_testFontFamily, 'url($_testFontUrl)', const <String, String>{});
|
||||
await fontManager.ensureFontsLoaded();
|
||||
html.document.fonts
|
||||
html.document.fonts!
|
||||
.forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) {
|
||||
fontFamilyList.add(f.family);
|
||||
fontFamilyList.add(f.family!);
|
||||
});
|
||||
|
||||
expect(fontFamilyList.length, equals(1));
|
||||
@@ -73,9 +72,9 @@ void testMain() {
|
||||
fontManager.registerAsset(
|
||||
_testFontFamily, 'url($_testFontUrl)', const <String, String>{});
|
||||
await fontManager.ensureFontsLoaded();
|
||||
html.document.fonts
|
||||
html.document.fonts!
|
||||
.forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) {
|
||||
fontFamilyList.add(f.family);
|
||||
fontFamilyList.add(f.family!);
|
||||
});
|
||||
|
||||
expect(fontFamilyList.length, equals(1));
|
||||
@@ -93,9 +92,9 @@ void testMain() {
|
||||
fontManager.registerAsset(
|
||||
_testFontFamily, 'url($_testFontUrl)', const <String, String>{});
|
||||
await fontManager.ensureFontsLoaded();
|
||||
html.document.fonts
|
||||
html.document.fonts!
|
||||
.forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) {
|
||||
fontFamilyList.add(f.family);
|
||||
fontFamilyList.add(f.family!);
|
||||
});
|
||||
|
||||
if (browserEngine != BrowserEngine.firefox) {
|
||||
@@ -119,9 +118,9 @@ void testMain() {
|
||||
fontManager.registerAsset(
|
||||
_testFontFamily, 'url($_testFontUrl)', const <String, String>{});
|
||||
await fontManager.ensureFontsLoaded();
|
||||
html.document.fonts
|
||||
html.document.fonts!
|
||||
.forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) {
|
||||
fontFamilyList.add(f.family);
|
||||
fontFamilyList.add(f.family!);
|
||||
});
|
||||
|
||||
if (browserEngine != BrowserEngine.firefox) {
|
||||
@@ -145,9 +144,9 @@ void testMain() {
|
||||
fontManager.registerAsset(
|
||||
_testFontFamily, 'url($_testFontUrl)', const <String, String>{});
|
||||
await fontManager.ensureFontsLoaded();
|
||||
html.document.fonts
|
||||
html.document.fonts!
|
||||
.forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) {
|
||||
fontFamilyList.add(f.family);
|
||||
fontFamilyList.add(f.family!);
|
||||
});
|
||||
|
||||
if (browserEngine != BrowserEngine.firefox) {
|
||||
@@ -172,9 +171,9 @@ void testMain() {
|
||||
fontManager.registerAsset(
|
||||
testFontFamily, 'url($_testFontUrl)', const <String, String>{});
|
||||
await fontManager.ensureFontsLoaded();
|
||||
html.document.fonts
|
||||
html.document.fonts!
|
||||
.forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) {
|
||||
fontFamilyList.add(f.family);
|
||||
fontFamilyList.add(f.family!);
|
||||
});
|
||||
|
||||
if (browserEngine != BrowserEngine.firefox) {
|
||||
|
||||
@@ -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:convert';
|
||||
import 'dart:html' as html;
|
||||
@@ -23,7 +22,7 @@ void testMain() async {
|
||||
const String _testFontUrl = 'packages/ui/assets/ahem.ttf';
|
||||
|
||||
tearDown(() {
|
||||
html.document.fonts.clear();
|
||||
html.document.fonts!.clear();
|
||||
});
|
||||
|
||||
test('surfaces error from invalid font buffer', () async {
|
||||
@@ -53,7 +52,7 @@ void testMain() async {
|
||||
browserEngine == BrowserEngine.webkit));
|
||||
|
||||
test('loading font should clear measurement caches', () async {
|
||||
final ui.ParagraphStyle style = ui.ParagraphStyle();
|
||||
final EngineParagraphStyle style = EngineParagraphStyle();
|
||||
final ui.ParagraphConstraints constraints =
|
||||
ui.ParagraphConstraints(width: 30.0);
|
||||
|
||||
@@ -61,7 +60,7 @@ void testMain() async {
|
||||
domBuilder.addText('test');
|
||||
// Triggers the measuring and verifies the result has been cached.
|
||||
domBuilder.build().layout(constraints);
|
||||
expect(TextMeasurementService.rulerManager.rulers.length, 1);
|
||||
expect(TextMeasurementService.rulerManager!.rulers.length, 1);
|
||||
|
||||
final CanvasParagraphBuilder canvasBuilder = CanvasParagraphBuilder(style);
|
||||
canvasBuilder.addText('test');
|
||||
@@ -79,7 +78,7 @@ void testMain() async {
|
||||
|
||||
// Verifies the font is loaded, and the cache is cleaned.
|
||||
expect(_containsFontFamily('Blehm'), isTrue);
|
||||
expect(TextMeasurementService.rulerManager.rulers.length, 0);
|
||||
expect(TextMeasurementService.rulerManager!.rulers.length, 0);
|
||||
expect(Spanometer.rulers.length, 0);
|
||||
},
|
||||
// TODO(nurhan): https://github.com/flutter/flutter/issues/56702
|
||||
@@ -88,13 +87,13 @@ void testMain() async {
|
||||
browserEngine == BrowserEngine.webkit));
|
||||
|
||||
test('loading font should send font change message', () async {
|
||||
final ui.PlatformMessageCallback oldHandler = ui.window.onPlatformMessage;
|
||||
String actualName;
|
||||
String message;
|
||||
window.onPlatformMessage = (String name, ByteData data,
|
||||
ui.PlatformMessageResponseCallback callback) {
|
||||
final ui.PlatformMessageCallback? oldHandler = ui.window.onPlatformMessage;
|
||||
String? actualName;
|
||||
String? message;
|
||||
window.onPlatformMessage = (String name, ByteData? data,
|
||||
ui.PlatformMessageResponseCallback? callback) {
|
||||
actualName = name;
|
||||
final buffer = data.buffer;
|
||||
final buffer = data!.buffer;
|
||||
final Uint8List list =
|
||||
buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
|
||||
message = utf8.decode(list);
|
||||
@@ -120,7 +119,7 @@ void testMain() async {
|
||||
|
||||
bool _containsFontFamily(String family) {
|
||||
bool found = false;
|
||||
html.document.fonts.forEach((html.FontFace fontFace,
|
||||
html.document.fonts!.forEach((html.FontFace fontFace,
|
||||
html.FontFace fontFaceAgain, html.FontFaceSet fontFaceSet) {
|
||||
if (fontFace.family == family) {
|
||||
found = true;
|
||||
|
||||
Reference in New Issue
Block a user