Skip to content

Commit

Permalink
test CkPath.reset() (flutter#21567)
Browse files Browse the repository at this point in the history
  • Loading branch information
yjbanov committed Oct 5, 2020
1 parent 948dd97 commit 3351524
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/web_ui/lib/src/engine/canvaskit/path.dart
Expand Up @@ -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();
}
Expand Down
Expand Up @@ -16,7 +16,7 @@ void main() {
}

void testMain() {
group('Path Metrics', () {
group('CkPath', () {
setUpAll(() async {
await ui.webOnlyInitializePlatform();
});
Expand Down Expand Up @@ -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
}

0 comments on commit 3351524

Please sign in to comment.