mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* change from build_runner to dart2js * add internalBootstrapBrowserTest to some of the tests * add internalBootstrapBrowserTest to all remaining tests * make tests build in paralel. Total time dropped from 586 to 177 seconds for 8 core MacBook * change isolates with pool * fixing analysis errors * skipping canvaskit tests for ios-safari * copy image files to the build directory * adding internalBootstrapBrowserTest to newly added tests * add internalBootstrapBrowserTest to faling path iterator test * necessary changes to make chrome windows work * in windows test in chrome instead of edge. our edge code was for legacy edge * do not run golden unit tests on Windows LUCI bots for now * addressing reviewer comments. Adding a method for deciding when to run integration tests. * remove lines that I forgot to remove * fixing analysis error. add issue for todo * add bootstap to a test file * adding bootstrap to another test * add internalBootstrapBrowserTest to a golden test * return test result in bat file. use archieve package to unzip * fixing logs for chrome_installer * use archieve and archieve entity instead of dynamic * adding comments for windows platform archieve part * addressing reviewer comments * change readme file
84 lines
2.8 KiB
Dart
84 lines
2.8 KiB
Dart
// 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.
|
|
|
|
// @dart = 2.6
|
|
import 'package:ui/src/engine.dart';
|
|
import 'package:ui/ui.dart' as ui;
|
|
|
|
import 'package:test/bootstrap/browser.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'mock_engine_canvas.dart';
|
|
|
|
void main() {
|
|
internalBootstrapBrowserTest(() => testMain);
|
|
}
|
|
|
|
void testMain() {
|
|
setUpAll(() {
|
|
WebExperiments.ensureInitialized();
|
|
});
|
|
|
|
group('EngineCanvas', () {
|
|
MockEngineCanvas mockCanvas;
|
|
ui.Paragraph paragraph;
|
|
|
|
void testCanvas(
|
|
String description, void Function(EngineCanvas canvas) testFn,
|
|
{ui.Rect canvasSize, ui.VoidCallback whenDone}) {
|
|
canvasSize ??= const ui.Rect.fromLTWH(0, 0, 100, 100);
|
|
test(description, () {
|
|
testFn(BitmapCanvas(canvasSize));
|
|
testFn(DomCanvas());
|
|
testFn(mockCanvas = MockEngineCanvas());
|
|
if (whenDone != null) {
|
|
whenDone();
|
|
}
|
|
});
|
|
}
|
|
|
|
testCanvas('draws laid out paragraph', (EngineCanvas canvas) {
|
|
final ui.Rect screenRect = const ui.Rect.fromLTWH(0, 0, 100, 100);
|
|
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);
|
|
final ui.ParagraphBuilder builder =
|
|
ui.ParagraphBuilder(ui.ParagraphStyle());
|
|
builder.addText('sample');
|
|
paragraph = builder.build();
|
|
paragraph.layout(const ui.ParagraphConstraints(width: 100));
|
|
recordingCanvas.drawParagraph(paragraph, const ui.Offset(10, 10));
|
|
recordingCanvas.endRecording();
|
|
canvas.clear();
|
|
recordingCanvas.apply(canvas, screenRect);
|
|
}, whenDone: () {
|
|
expect(mockCanvas.methodCallLog, hasLength(3));
|
|
|
|
MockCanvasCall call = mockCanvas.methodCallLog[0];
|
|
expect(call.methodName, 'clear');
|
|
|
|
call = mockCanvas.methodCallLog[1];
|
|
expect(call.methodName, 'drawParagraph');
|
|
expect(call.arguments['paragraph'], paragraph);
|
|
expect(call.arguments['offset'], const ui.Offset(10, 10));
|
|
});
|
|
|
|
testCanvas('ignores paragraphs that were not laid out',
|
|
(EngineCanvas canvas) {
|
|
final ui.Rect screenRect = const ui.Rect.fromLTWH(0, 0, 100, 100);
|
|
final RecordingCanvas recordingCanvas = RecordingCanvas(screenRect);
|
|
final ui.ParagraphBuilder builder =
|
|
ui.ParagraphBuilder(ui.ParagraphStyle());
|
|
builder.addText('sample');
|
|
final ui.Paragraph paragraph = builder.build();
|
|
recordingCanvas.drawParagraph(paragraph, const ui.Offset(10, 10));
|
|
recordingCanvas.endRecording();
|
|
canvas.clear();
|
|
recordingCanvas.apply(canvas, screenRect);
|
|
}, whenDone: () {
|
|
expect(mockCanvas.methodCallLog, hasLength(2));
|
|
expect(mockCanvas.methodCallLog[0].methodName, 'clear');
|
|
expect(mockCanvas.methodCallLog[1].methodName, 'endOfPaint');
|
|
});
|
|
});
|
|
}
|