Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 39f5465

Browse files
author
Harry Terkelsen
authored
Fix CanvasKit path tests (#37635)
1 parent 5471734 commit 39f5465

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

lib/web_ui/lib/src/engine/canvaskit/path_metrics.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class CkPathMetrics extends IterableBase<ui.PathMetric>
2323
late final Iterator<ui.PathMetric> iterator = _path.isEmpty
2424
? const CkPathMetricIteratorEmpty._()
2525
: CkContourMeasureIter(this);
26+
27+
/// A fresh [CkContourMeasureIter] which is only used for resurrecting a
28+
/// [CkContourMeasure]. We can't use [iterator] here because [iterator] is
29+
/// memoized.
30+
CkContourMeasureIter _iteratorForResurrection() => CkContourMeasureIter(this);
2631
}
2732

2833
class CkContourMeasureIter extends ManagedSkiaObject<SkContourMeasureIter>
@@ -140,8 +145,7 @@ class CkContourMeasure extends ManagedSkiaObject<SkContourMeasure>
140145

141146
@override
142147
SkContourMeasure resurrect() {
143-
final CkContourMeasureIter iterator =
144-
_metrics.iterator as CkContourMeasureIter;
148+
final CkContourMeasureIter iterator = _metrics._iteratorForResurrection();
145149
final SkContourMeasureIter skIterator = iterator.skiaObject;
146150

147151
// When resurrecting we must advance the iterator to the last known

lib/web_ui/test/canvaskit/path_test.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ void testMain() {
4545
path.addOval(const ui.Rect.fromLTRB(10, 10, 100, 100));
4646
expect(path.computeMetrics().length, 2);
4747

48-
// Path metrics can be iterated over multiple times.
49-
final ui.PathMetrics metrics = path.computeMetrics();
50-
expect(metrics.toList().length, 2);
51-
expect(metrics.toList().length, 2);
52-
expect(metrics.toList().length, 2);
53-
5448
// Can simultaneously iterate over multiple metrics from the same path.
5549
final ui.PathMetrics metrics1 = path.computeMetrics();
5650
final ui.PathMetrics metrics2 = path.computeMetrics();
@@ -68,8 +62,7 @@ void testMain() {
6862
expect(iter2.moveNext(), isFalse);
6963
expect(() => iter1.current, throwsRangeError);
7064
expect(() => iter2.current, throwsRangeError);
71-
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/115327
72-
}, skip: true);
65+
});
7366

7467
test('CkPath.reset', () {
7568
final ui.Path path = ui.Path();
@@ -171,8 +164,7 @@ void testMain() {
171164
expect(measure0.extractPath(0, 15).getBounds(), const ui.Rect.fromLTRB(0, 0, 10, 5));
172165
expect(measure1.contourIndex, 1);
173166
expect(measure1.extractPath(0, 15).getBounds(), const ui.Rect.fromLTRB(20, 20, 30, 25));
174-
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/115327
175-
}, skip: true);
167+
});
176168

177169
test('Path.from', () {
178170
const ui.Rect rect1 = ui.Rect.fromLTRB(0, 0, 10, 10);

0 commit comments

Comments
 (0)