From 81b8c4ac677f4ce447f036785e90de3d84db31ba Mon Sep 17 00:00:00 2001 From: Yegor Date: Wed, 30 Sep 2020 14:30:01 -0700 Subject: [PATCH] re-enable CanvasKit path ops test (flutter/engine#21520) * re-enable CanvasKit path ops test * also test Path.combine --- .../test/canvaskit/canvaskit_api_test.dart | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/engine/src/flutter/lib/web_ui/test/canvaskit/canvaskit_api_test.dart b/engine/src/flutter/lib/web_ui/test/canvaskit/canvaskit_api_test.dart index 8770120ac7..b03f3526db 100644 --- a/engine/src/flutter/lib/web_ui/test/canvaskit/canvaskit_api_test.dart +++ b/engine/src/flutter/lib/web_ui/test/canvaskit/canvaskit_api_test.dart @@ -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('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('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()); + 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()); + 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()); + 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()); + } + }); } void _clipOpTests() {