Skip to content

Commit

Permalink
re-enable CanvasKit path ops test (flutter#21520)
Browse files Browse the repository at this point in the history
* re-enable CanvasKit path ops test

* also test Path.combine
  • Loading branch information
yjbanov authored Sep 30, 2020
1 parent 572c343 commit 93735c9
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions lib/web_ui/test/canvaskit/canvaskit_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,41 @@ void _fillTypeTests() {
}

void _pathOpTests() {
// TODO(yjbanov): https://github.com/flutter/flutter/issues/61403
// test('path op mapping is correct', () {
// expect(canvasKit.PathOp.Difference.value, ui.PathOperation.difference.index);
// expect(canvasKit.PathOp.Intersect.value, ui.PathOperation.intersect.index);
// expect(canvasKit.PathOp.Union.value, ui.PathOperation.union.index);
// expect(canvasKit.PathOp.XOR.value, ui.PathOperation.xor.index);
// expect(canvasKit.PathOp.ReverseDifference, ui.PathOperation.reverseDifference.index);
// });

// test('ui.PathOperation converts to SkPathOp', () {
// for (ui.PathOperation op in ui.PathOperation.values) {
// expect(toSkPathOp(op).value, op.index);
// }
// });
test('path op mapping is correct', () {
expect(canvasKit.PathOp.Difference.value, ui.PathOperation.difference.index);
expect(canvasKit.PathOp.Intersect.value, ui.PathOperation.intersect.index);
expect(canvasKit.PathOp.Union.value, ui.PathOperation.union.index);
expect(canvasKit.PathOp.XOR.value, ui.PathOperation.xor.index);
expect(canvasKit.PathOp.ReverseDifference.value, ui.PathOperation.reverseDifference.index);
});

test('ui.PathOperation converts to SkPathOp', () {
for (ui.PathOperation op in ui.PathOperation.values) {
expect(toSkPathOp(op).value, op.index);
}
});

test('Path.combine test', () {
final ui.Path path1 = ui.Path();
expect(path1, isA<CkPath>());
path1.addRect(ui.Rect.fromLTRB(0, 0, 10, 10));
path1.addOval(ui.Rect.fromLTRB(10, 10, 100, 100));

final ui.Path path2 = ui.Path();
expect(path2, isA<CkPath>());
path2.addRect(ui.Rect.fromLTRB(5, 5, 15, 15));
path2.addOval(ui.Rect.fromLTRB(15, 15, 105, 105));

final ui.Path union = ui.Path.combine(ui.PathOperation.union, path1, path2);
expect(union, isA<CkPath>());
expect(union.getBounds(), const ui.Rect.fromLTRB(0, 0, 105, 105));

// Smoke-test other operations.
for (final ui.PathOperation operation in ui.PathOperation.values) {
final ui.Path combined = ui.Path.combine(operation, path1, path2);
expect(combined, isA<CkPath>());
}
});
}

void _clipOpTests() {
Expand Down

0 comments on commit 93735c9

Please sign in to comment.