@@ -9,59 +9,65 @@ import 'package:ui/src/engine.dart';
99import 'package:ui/ui.dart' as ui;
1010
1111void main () {
12- setUpAll (() async {
13- await ui.webOnlyInitializePlatform ();
14- });
12+ group ('Path Metrics' , () {
13+ setUpAll (() async {
14+ await ui.webOnlyInitializePlatform ();
15+ });
1516
16- test ('Using CanvasKit' , () {
17- expect (experimentalUseSkia, true );
18- });
17+ test ('Using CanvasKit' , () {
18+ expect (experimentalUseSkia, true );
19+ });
1920
20- test (SkPathMetrics , () {
21- final ui.Path path = ui.Path ();
22- expect (path, isA <SkPath >());
23- expect (path.computeMetrics ().length, 0 );
21+ test (SkPathMetrics , () {
22+ final ui.Path path = ui.Path ();
23+ expect (path, isA <SkPath >());
24+ expect (path.computeMetrics ().length, 0 );
2425
25- path.addRect (ui.Rect .fromLTRB (0 , 0 , 10 , 10 ));
26- final ui.PathMetric metric = path.computeMetrics ().single;
27- expect (metric.contourIndex, 0 );
28- expect (metric.extractPath (0 , 0.5 ).computeMetrics ().length, 1 );
26+ path.addRect (ui.Rect .fromLTRB (0 , 0 , 10 , 10 ));
27+ final ui.PathMetric metric = path.computeMetrics ().single;
28+ expect (metric.contourIndex, 0 );
29+ expect (metric.extractPath (0 , 0.5 ).computeMetrics ().length, 1 );
2930
30- final ui.Tangent tangent1 = metric.getTangentForOffset (5 );
31- expect (tangent1.position, ui.Offset (5 , 0 ));
32- expect (tangent1.vector, ui.Offset (1 , 0 ));
31+ final ui.Tangent tangent1 = metric.getTangentForOffset (5 );
32+ expect (tangent1.position, ui.Offset (5 , 0 ));
33+ expect (tangent1.vector, ui.Offset (1 , 0 ));
3334
34- final ui.Tangent tangent2 = metric.getTangentForOffset (15 );
35- expect (tangent2.position, ui.Offset (10 , 5 ));
36- expect (tangent2.vector, ui.Offset (0 , 1 ));
35+ final ui.Tangent tangent2 = metric.getTangentForOffset (15 );
36+ expect (tangent2.position, ui.Offset (10 , 5 ));
37+ expect (tangent2.vector, ui.Offset (0 , 1 ));
3738
38- expect (metric.isClosed, true );
39+ expect (metric.isClosed, true );
3940
40- path.addOval (ui.Rect .fromLTRB (10 , 10 , 100 , 100 ));
41- expect (path.computeMetrics ().length, 2 );
41+ path.addOval (ui.Rect .fromLTRB (10 , 10 , 100 , 100 ));
42+ expect (path.computeMetrics ().length, 2 );
4243
43- // Path metrics can be iterated over multiple times.
44- final ui.PathMetrics metrics = path.computeMetrics ();
45- expect (metrics.toList ().length, 2 );
46- expect (metrics.toList ().length, 2 );
47- expect (metrics.toList ().length, 2 );
44+ // Path metrics can be iterated over multiple times.
45+ final ui.PathMetrics metrics = path.computeMetrics ();
46+ expect (metrics.toList ().length, 2 );
47+ expect (metrics.toList ().length, 2 );
48+ expect (metrics.toList ().length, 2 );
4849
49- // Can simultaneously iterate over multiple metrics from the same path.
50- final ui.PathMetrics metrics1 = path.computeMetrics ();
51- final ui.PathMetrics metrics2 = path.computeMetrics ();
52- final Iterator <ui.PathMetric > iter1 = metrics1.iterator;
53- final Iterator <ui.PathMetric > iter2 = metrics2.iterator;
54- expect (iter1.moveNext (), true );
55- expect (iter2.moveNext (), true );
56- expect (iter1.current, isNotNull);
57- expect (iter2.current, isNotNull);
58- expect (iter1.moveNext (), true );
59- expect (iter2.moveNext (), true );
60- expect (iter1.current, isNotNull);
61- expect (iter2.current, isNotNull);
62- expect (iter1.moveNext (), false );
63- expect (iter2.moveNext (), false );
64- expect (iter1.current, isNull);
65- expect (iter2.current, isNull);
66- });
50+ // Can simultaneously iterate over multiple metrics from the same path.
51+ final ui.PathMetrics metrics1 = path.computeMetrics ();
52+ final ui.PathMetrics metrics2 = path.computeMetrics ();
53+ final Iterator <ui.PathMetric > iter1 = metrics1.iterator;
54+ final Iterator <ui.PathMetric > iter2 = metrics2.iterator;
55+ expect (iter1.moveNext (), true );
56+ expect (iter2.moveNext (), true );
57+ expect (iter1.current, isNotNull);
58+ expect (iter2.current, isNotNull);
59+ expect (iter1.moveNext (), true );
60+ expect (iter2.moveNext (), true );
61+ expect (iter1.current, isNotNull);
62+ expect (iter2.current, isNotNull);
63+ expect (iter1.moveNext (), false );
64+ expect (iter2.moveNext (), false );
65+ expect (iter1.current, isNull);
66+ expect (iter2.current, isNull);
67+ });
68+ },
69+ // This test failed on iOS Safari.
70+ // TODO: https://github.com/flutter/flutter/issues/60040
71+ skip: (browserEngine == BrowserEngine .webkit &&
72+ operatingSystem == OperatingSystem .iOs));
6773}
0 commit comments