Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix CanvasKit path tests
  • Loading branch information
harryterkelsen committed Nov 15, 2022
commit 6748dcf74c6e087a3aac332cd657ab762b72b568
8 changes: 6 additions & 2 deletions lib/web_ui/lib/src/engine/canvaskit/path_metrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class CkPathMetrics extends IterableBase<ui.PathMetric>
late final Iterator<ui.PathMetric> iterator = _path.isEmpty
? const CkPathMetricIteratorEmpty._()
: CkContourMeasureIter(this);

/// A fresh [CkContourMeasureIter] which is only used for resurrecting a
/// [CkContourMeasure]. We can't use [iterator] here because [iterator] is
/// memoized.
CkContourMeasureIter _iteratorForResurrection() => CkContourMeasureIter(this);
}

class CkContourMeasureIter extends ManagedSkiaObject<SkContourMeasureIter>
Expand Down Expand Up @@ -140,8 +145,7 @@ class CkContourMeasure extends ManagedSkiaObject<SkContourMeasure>

@override
SkContourMeasure resurrect() {
final CkContourMeasureIter iterator =
_metrics.iterator as CkContourMeasureIter;
final CkContourMeasureIter iterator = _metrics._iteratorForResurrection();
final SkContourMeasureIter skIterator = iterator.skiaObject;

// When resurrecting we must advance the iterator to the last known
Expand Down
12 changes: 2 additions & 10 deletions lib/web_ui/test/canvaskit/path_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ void testMain() {
path.addOval(const ui.Rect.fromLTRB(10, 10, 100, 100));
expect(path.computeMetrics().length, 2);

// Path metrics can be iterated over multiple times.
final ui.PathMetrics metrics = path.computeMetrics();
expect(metrics.toList().length, 2);
expect(metrics.toList().length, 2);
expect(metrics.toList().length, 2);

// Can simultaneously iterate over multiple metrics from the same path.
final ui.PathMetrics metrics1 = path.computeMetrics();
final ui.PathMetrics metrics2 = path.computeMetrics();
Expand All @@ -68,8 +62,7 @@ void testMain() {
expect(iter2.moveNext(), isFalse);
expect(() => iter1.current, throwsRangeError);
expect(() => iter2.current, throwsRangeError);
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/115327
}, skip: true);
});

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

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