From 33515242ed90cc3c8a038541ad95c2d3ca292dca Mon Sep 17 00:00:00 2001 From: Yegor Date: Mon, 5 Oct 2020 12:44:33 -0700 Subject: [PATCH] test CkPath.reset() (#21567) --- lib/web_ui/lib/src/engine/canvaskit/path.dart | 2 ++ .../{path_metrics_test.dart => path_test.dart} | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) rename lib/web_ui/test/canvaskit/{path_metrics_test.dart => path_test.dart} (82%) diff --git a/lib/web_ui/lib/src/engine/canvaskit/path.dart b/lib/web_ui/lib/src/engine/canvaskit/path.dart index 13027365874241..86a758baf15fb0 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/path.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/path.dart @@ -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(); } diff --git a/lib/web_ui/test/canvaskit/path_metrics_test.dart b/lib/web_ui/test/canvaskit/path_test.dart similarity index 82% rename from lib/web_ui/test/canvaskit/path_metrics_test.dart rename to lib/web_ui/test/canvaskit/path_test.dart index eece12c15b5725..4266afa5046e71 100644 --- a/lib/web_ui/test/canvaskit/path_metrics_test.dart +++ b/lib/web_ui/test/canvaskit/path_test.dart @@ -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()); + 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 }