test CkPath.reset() (#21567)

This commit is contained in:
Yegor 2020-10-05 12:44:33 -07:00 committed by GitHub
parent 948dd97025
commit 33515242ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -257,6 +257,8 @@ class CkPath implements ui.Path {
@override
void reset() {
// Only reset the local field. Skia will reset its internal state via
// SkPath.reset() below.
_fillType = ui.PathFillType.nonZero;
_skPath.reset();
}

View File

@ -16,7 +16,7 @@ void main() {
}
void testMain() {
group('Path Metrics', () {
group('CkPath', () {
setUpAll(() async {
await ui.webOnlyInitializePlatform();
});
@ -72,5 +72,20 @@ void testMain() {
expect(() => iter1.current, throwsRangeError);
expect(() => iter2.current, throwsRangeError);
});
test('CkPath.reset', () {
final ui.Path path = ui.Path();
expect(path, isA<CkPath>());
path.addRect(const ui.Rect.fromLTRB(0, 0, 10, 10));
expect(path.contains(const ui.Offset(5, 5)), isTrue);
expect(path.fillType, ui.PathFillType.nonZero);
path.fillType = ui.PathFillType.evenOdd;
expect(path.fillType, ui.PathFillType.evenOdd);
path.reset();
expect(path.fillType, ui.PathFillType.nonZero);
expect(path.contains(const ui.Offset(5, 5)), isFalse);
});
}, skip: isIosSafari); // TODO: https://github.com/flutter/flutter/issues/60040
}