44
55// @dart = 2.6
66import 'package:ui/src/engine.dart' ;
7- import 'package:ui/ui.dart' ;
7+ import 'package:ui/ui.dart' hide window ;
88
99import 'package:test/test.dart' ;
1010
1111void testEachMeasurement (String description, VoidCallback body, {bool skip}) {
1212 test ('$description (dom measurement)' , () async {
1313 try {
1414 TextMeasurementService .initialize (rulerCacheCapacity: 2 );
15+ WebExperiments .instance.useCanvasText = false ;
1516 return body ();
1617 } finally {
18+ WebExperiments .instance.useCanvasText = null ;
1719 TextMeasurementService .clearCache ();
1820 }
1921 }, skip: skip);
2022 test ('$description (canvas measurement)' , () async {
2123 try {
2224 TextMeasurementService .initialize (rulerCacheCapacity: 2 );
23- TextMeasurementService .enableExperimentalCanvasImplementation = true ;
25+ WebExperiments .instance.useCanvasText = true ;
2426 return body ();
2527 } finally {
26- TextMeasurementService .enableExperimentalCanvasImplementation = false ;
28+ WebExperiments .instance.useCanvasText = null ;
2729 TextMeasurementService .clearCache ();
2830 }
2931 }, skip: skip);
@@ -184,7 +186,7 @@ void main() async {
184186 test ('getPositionForOffset multi-line' , () {
185187 // [Paragraph.getPositionForOffset] for multi-line text doesn't work well
186188 // with dom-based measurement.
187- TextMeasurementService .enableExperimentalCanvasImplementation = true ;
189+ WebExperiments .instance.useCanvasText = true ;
188190 TextMeasurementService .initialize (rulerCacheCapacity: 2 );
189191
190192 final ParagraphBuilder builder = ParagraphBuilder (ParagraphStyle (
@@ -280,11 +282,11 @@ void main() async {
280282 );
281283
282284 TextMeasurementService .clearCache ();
283- TextMeasurementService .enableExperimentalCanvasImplementation = false ;
285+ WebExperiments .instance.useCanvasText = null ;
284286 });
285287
286288 test ('getPositionForOffset multi-line centered' , () {
287- TextMeasurementService .enableExperimentalCanvasImplementation = true ;
289+ WebExperiments .instance.useCanvasText = true ;
288290 TextMeasurementService .initialize (rulerCacheCapacity: 2 );
289291
290292 final ParagraphBuilder builder = ParagraphBuilder (ParagraphStyle (
@@ -387,7 +389,7 @@ void main() async {
387389 );
388390
389391 TextMeasurementService .clearCache ();
390- TextMeasurementService .enableExperimentalCanvasImplementation = false ;
392+ WebExperiments .instance.useCanvasText = null ;
391393 });
392394
393395 testEachMeasurement ('getBoxesForRange returns a box' , () {
@@ -782,7 +784,7 @@ void main() async {
782784
783785 test ('longestLine' , () {
784786 // [Paragraph.longestLine] is only supported by canvas-based measurement.
785- TextMeasurementService .enableExperimentalCanvasImplementation = true ;
787+ WebExperiments .instance.useCanvasText = true ;
786788 TextMeasurementService .initialize (rulerCacheCapacity: 2 );
787789
788790 final ParagraphBuilder builder = ParagraphBuilder (ParagraphStyle (
@@ -797,7 +799,7 @@ void main() async {
797799 expect (paragraph.longestLine, 50.0 );
798800
799801 TextMeasurementService .clearCache ();
800- TextMeasurementService .enableExperimentalCanvasImplementation = false ;
802+ WebExperiments .instance.useCanvasText = null ;
801803 });
802804
803805 testEachMeasurement ('getLineBoundary (single-line)' , () {
@@ -824,7 +826,7 @@ void main() async {
824826 test ('getLineBoundary (multi-line)' , () {
825827 // [Paragraph.getLineBoundary] for multi-line paragraphs is only supported
826828 // by canvas-based measurement.
827- TextMeasurementService .enableExperimentalCanvasImplementation = true ;
829+ WebExperiments .instance.useCanvasText = true ;
828830 TextMeasurementService .initialize (rulerCacheCapacity: 2 );
829831
830832 final ParagraphBuilder builder = ParagraphBuilder (ParagraphStyle (
@@ -867,7 +869,7 @@ void main() async {
867869 }
868870
869871 TextMeasurementService .clearCache ();
870- TextMeasurementService .enableExperimentalCanvasImplementation = false ;
872+ WebExperiments .instance.useCanvasText = null ;
871873 });
872874
873875 testEachMeasurement ('width should be a whole integer' , () {
0 commit comments