@@ -93,15 +93,15 @@ void main() {
93
93
});
94
94
95
95
@isTest
96
- void runTestbed (
96
+ void runInTestbed (
97
97
String description,
98
98
FutureOr <void > Function () body, {
99
99
Map <Type , Generator >? overrides,
100
100
}) {
101
101
test (description, () => testbed.run (body, overrides: overrides));
102
102
}
103
103
104
- runTestbed ('.log() reports warnings' , () {
104
+ runInTestbed ('.log() reports warnings' , () {
105
105
const String unresolvedUriMessage = 'Unresolved uri:' ;
106
106
const String otherMessage = 'Something bad happened' ;
107
107
@@ -115,7 +115,7 @@ void main() {
115
115
expect (logger.warningText, contains (otherMessage));
116
116
});
117
117
118
- runTestbed ('Handles against malformed manifest' , () async {
118
+ runInTestbed ('Handles against malformed manifest' , () async {
119
119
final File source = globals.fs.file ('source' )
120
120
..writeAsStringSync ('main() {}' );
121
121
final File sourcemap = globals.fs.file ('sourcemap' )
@@ -151,7 +151,7 @@ void main() {
151
151
);
152
152
});
153
153
154
- runTestbed ('serves JavaScript files from memory cache' , () async {
154
+ runInTestbed ('serves JavaScript files from memory cache' , () async {
155
155
final File source = globals.fs.file ('source' )
156
156
..writeAsStringSync ('main() {}' );
157
157
final File sourcemap = globals.fs.file ('sourcemap' )
@@ -180,7 +180,7 @@ void main() {
180
180
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
181
181
}, overrides: < Type , Generator > {Platform : () => linux});
182
182
183
- runTestbed ('serves metadata files from memory cache' , () async {
183
+ runInTestbed ('serves metadata files from memory cache' , () async {
184
184
const String metadataContents = '{"name":"foo"}' ;
185
185
final File source = globals.fs.file ('source' )
186
186
..writeAsStringSync ('main() {}' );
@@ -206,7 +206,7 @@ void main() {
206
206
}, overrides: < Type , Generator > {Platform : () => linux});
207
207
208
208
// Ensures that no requests are made outside of served directory.
209
- runTestbed ('Removes leading slashes for valid requests' , () async {
209
+ runInTestbed ('Removes leading slashes for valid requests' , () async {
210
210
globals.fs.file ('foo.png' ).createSync ();
211
211
globals.fs.currentDirectory = globals.fs.directory ('project_directory' )
212
212
..createSync ();
@@ -227,7 +227,7 @@ void main() {
227
227
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
228
228
});
229
229
230
- runTestbed ('takes base path into account when serving' , () async {
230
+ runInTestbed ('takes base path into account when serving' , () async {
231
231
webAssetServer.basePath = 'base/path' ;
232
232
233
233
globals.fs.file ('foo.png' ).createSync ();
@@ -250,7 +250,7 @@ void main() {
250
250
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
251
251
});
252
252
253
- runTestbed ('serves index.html at the base path' , () async {
253
+ runInTestbed ('serves index.html at the base path' , () async {
254
254
webAssetServer.basePath = 'base/path' ;
255
255
256
256
const String htmlContent = '<html><head></head><body id="test"></body></html>' ;
@@ -274,7 +274,7 @@ void main() {
274
274
expect (await response.readAsString (), htmlContent);
275
275
});
276
276
277
- runTestbed ('serves index.html at / if href attribute is $kBaseHrefPlaceholder ' , () async {
277
+ runInTestbed ('serves index.html at / if href attribute is $kBaseHrefPlaceholder ' , () async {
278
278
const String htmlContent = '<html><head><base href ="$kBaseHrefPlaceholder "></head><body id="test"></body></html>' ;
279
279
final Directory webDir = globals.fs.currentDirectory.childDirectory ('web' )..createSync ();
280
280
webDir.childFile ('index.html' ).writeAsStringSync (htmlContent);
@@ -295,7 +295,7 @@ void main() {
295
295
expect (await response.readAsString (), htmlContent.replaceAll (kBaseHrefPlaceholder, '/' ));
296
296
});
297
297
298
- runTestbed ('does not serve outside the base path' , () async {
298
+ runInTestbed ('does not serve outside the base path' , () async {
299
299
webAssetServer.basePath = 'base/path' ;
300
300
301
301
const String htmlContent = '<html><head></head><body id="test"></body></html>' ;
@@ -309,7 +309,7 @@ void main() {
309
309
expect (response.statusCode, HttpStatus .notFound);
310
310
});
311
311
312
- runTestbed ('parses base path from index.html' , () async {
312
+ runInTestbed ('parses base path from index.html' , () async {
313
313
const String htmlContent = '<html><head><base href="/foo/bar/"></head><body id="test"></body></html>' ;
314
314
final Directory webDir = globals.fs.currentDirectory.childDirectory ('web' )..createSync ();
315
315
webDir.childFile ('index.html' ).writeAsStringSync (htmlContent);
@@ -329,7 +329,7 @@ void main() {
329
329
expect (webAssetServer.basePath, 'foo/bar' );
330
330
});
331
331
332
- runTestbed ('handles lack of base path in index.html' , () async {
332
+ runInTestbed ('handles lack of base path in index.html' , () async {
333
333
const String htmlContent = '<html><head></head><body id="test"></body></html>' ;
334
334
final Directory webDir = globals.fs.currentDirectory.childDirectory ('web' )..createSync ();
335
335
webDir.childFile ('index.html' ).writeAsStringSync (htmlContent);
@@ -350,7 +350,7 @@ void main() {
350
350
expect (webAssetServer.basePath, '' );
351
351
});
352
352
353
- runTestbed ('throws if base path is relative' , () async {
353
+ runInTestbed ('throws if base path is relative' , () async {
354
354
const String htmlContent = '<html><head><base href="foo/bar/"></head><body id="test"></body></html>' ;
355
355
final Directory webDir = globals.fs.currentDirectory.childDirectory ('web' )..createSync ();
356
356
webDir.childFile ('index.html' ).writeAsStringSync (htmlContent);
@@ -371,7 +371,7 @@ void main() {
371
371
);
372
372
});
373
373
374
- runTestbed ('throws if base path does not end with slash' , () async {
374
+ runInTestbed ('throws if base path does not end with slash' , () async {
375
375
const String htmlContent = '<html><head><base href="/foo/bar"></head><body id="test"></body></html>' ;
376
376
final Directory webDir = globals.fs.currentDirectory.childDirectory ('web' )..createSync ();
377
377
webDir.childFile ('index.html' ).writeAsStringSync (htmlContent);
@@ -392,7 +392,7 @@ void main() {
392
392
);
393
393
});
394
394
395
- runTestbed ('serves JavaScript files from memory cache not from manifest' , () async {
395
+ runInTestbed ('serves JavaScript files from memory cache not from manifest' , () async {
396
396
webAssetServer.writeFile ('foo.js' , 'main() {}' );
397
397
398
398
final Response response = await webAssetServer.handleRequest (
@@ -408,7 +408,7 @@ void main() {
408
408
expect ((await response.read ().toList ()).first, utf8.encode ('main() {}' ));
409
409
});
410
410
411
- runTestbed ('Returns notModified when the ifNoneMatch header matches the etag' , () async {
411
+ runInTestbed ('Returns notModified when the ifNoneMatch header matches the etag' , () async {
412
412
webAssetServer.writeFile ('foo.js' , 'main() {}' );
413
413
414
414
final Response response = await webAssetServer.handleRequest (
@@ -425,7 +425,7 @@ void main() {
425
425
expect (await cachedResponse.read ().toList (), isEmpty);
426
426
});
427
427
428
- runTestbed ('serves index.html when path is unknown' , () async {
428
+ runInTestbed ('serves index.html when path is unknown' , () async {
429
429
const String htmlContent = '<html><head></head><body id="test"></body></html>' ;
430
430
final Directory webDir = globals.fs.currentDirectory.childDirectory ('web' )..createSync ();
431
431
webDir.childFile ('index.html' ).writeAsStringSync (htmlContent);
@@ -445,7 +445,7 @@ void main() {
445
445
expect (await response.readAsString (), htmlContent);
446
446
});
447
447
448
- runTestbed ('does not serve outside the base path' , () async {
448
+ runInTestbed ('does not serve outside the base path' , () async {
449
449
webAssetServer.basePath = 'base/path' ;
450
450
451
451
const String htmlContent = '<html><head></head><body id="test"></body></html>' ;
@@ -459,7 +459,7 @@ void main() {
459
459
expect (response.statusCode, HttpStatus .notFound);
460
460
});
461
461
462
- runTestbed ('does not serve index.html when path is inside assets or packages' , () async {
462
+ runInTestbed ('does not serve index.html when path is inside assets or packages' , () async {
463
463
const String htmlContent = '<html><head></head><body id="test"></body></html>' ;
464
464
final Directory webDir = globals.fs.currentDirectory.childDirectory ('web' )..createSync ();
465
465
webDir.childFile ('index.html' ).writeAsStringSync (htmlContent);
@@ -487,7 +487,7 @@ void main() {
487
487
expect (response.statusCode, HttpStatus .notFound);
488
488
});
489
489
490
- runTestbed ('serves default index.html' , () async {
490
+ runInTestbed ('serves default index.html' , () async {
491
491
final String flutterJsPath = globals.fs.path.join (
492
492
globals.artifacts! .getHostArtifact (HostArtifact .flutterJsDirectory).path,
493
493
'flutter.js' ,
@@ -507,7 +507,7 @@ void main() {
507
507
);
508
508
});
509
509
510
- runTestbed ('handles web server paths without .lib extension' , () async {
510
+ runInTestbed ('handles web server paths without .lib extension' , () async {
511
511
final File source = globals.fs.file ('source' )
512
512
..writeAsStringSync ('main() {}' );
513
513
final File sourcemap = globals.fs.file ('sourcemap' )
@@ -531,7 +531,7 @@ void main() {
531
531
expect (response.statusCode, HttpStatus .ok);
532
532
});
533
533
534
- runTestbed ('serves JavaScript files from memory cache on Windows' , () async {
534
+ runInTestbed ('serves JavaScript files from memory cache on Windows' , () async {
535
535
final File source = globals.fs.file ('source' )
536
536
..writeAsStringSync ('main() {}' );
537
537
final File sourcemap = globals.fs.file ('sourcemap' )
@@ -560,7 +560,7 @@ void main() {
560
560
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
561
561
}, overrides: < Type , Generator > {Platform : () => windows});
562
562
563
- runTestbed ('serves asset files from filesystem with url-encoded paths' , () async {
563
+ runInTestbed ('serves asset files from filesystem with url-encoded paths' , () async {
564
564
final String path = globals.fs.path.join (
565
565
'build' ,
566
566
'flutter_assets' ,
@@ -582,7 +582,7 @@ void main() {
582
582
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
583
583
});
584
584
585
- runTestbed ('serves files from web directory' , () async {
585
+ runInTestbed ('serves files from web directory' , () async {
586
586
final File source = globals.fs.file (globals.fs.path.join ('web' , 'foo.png' ))
587
587
..createSync (recursive: true )
588
588
..writeAsBytesSync (kTransparentImage);
@@ -599,7 +599,7 @@ void main() {
599
599
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
600
600
});
601
601
602
- runTestbed ('serves asset files from filesystem with known mime type on Windows' , () async {
602
+ runInTestbed ('serves asset files from filesystem with known mime type on Windows' , () async {
603
603
final String path = globals.fs.path.join ('build' , 'flutter_assets' , 'foo.png' );
604
604
final File source = globals.fs.file (path)
605
605
..createSync (recursive: true )
@@ -617,7 +617,7 @@ void main() {
617
617
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
618
618
}, overrides: < Type , Generator > {Platform : () => windows});
619
619
620
- runTestbed ('serves Dart files from filesystem on Linux/macOS' , () async {
620
+ runInTestbed ('serves Dart files from filesystem on Linux/macOS' , () async {
621
621
final File source = globals.fs.file ('foo.dart' ).absolute
622
622
..createSync (recursive: true )
623
623
..writeAsStringSync ('void main() {}' );
@@ -633,7 +633,7 @@ void main() {
633
633
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
634
634
}, overrides: < Type , Generator > {Platform : () => linux});
635
635
636
- runTestbed ('serves asset files from filesystem with known mime type' , () async {
636
+ runInTestbed ('serves asset files from filesystem with known mime type' , () async {
637
637
final String path = globals.fs.path.join ('build' , 'flutter_assets' , 'foo.png' );
638
638
final File source = globals.fs.file (path)
639
639
..createSync (recursive: true )
@@ -650,7 +650,7 @@ void main() {
650
650
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
651
651
});
652
652
653
- runTestbed ('serves asset files from filesystem with known mime type and empty content' , () async {
653
+ runInTestbed ('serves asset files from filesystem with known mime type and empty content' , () async {
654
654
final String path = globals.fs.path.join ('web' , 'foo.js' );
655
655
final File source = globals.fs.file (path)
656
656
..createSync (recursive: true );
@@ -666,7 +666,7 @@ void main() {
666
666
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
667
667
});
668
668
669
- runTestbed ('serves asset files from filesystem with unknown mime type' , () async {
669
+ runInTestbed ('serves asset files from filesystem with unknown mime type' , () async {
670
670
final String path = globals.fs.path.join ('build' , 'flutter_assets' , 'foo' );
671
671
final File source = globals.fs.file (path)
672
672
..createSync (recursive: true )
@@ -683,7 +683,7 @@ void main() {
683
683
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
684
684
});
685
685
686
- runTestbed ('serves valid etag header for asset files with non-ascii characters' , () async {
686
+ runInTestbed ('serves valid etag header for asset files with non-ascii characters' , () async {
687
687
final String path = globals.fs.path.join ('build' , 'flutter_assets' , 'fooπ' );
688
688
globals.fs.file (path)
689
689
..createSync (recursive: true )
@@ -697,7 +697,7 @@ void main() {
697
697
expect (etag.runes, everyElement (predicate ((int char) => char < 255 )));
698
698
});
699
699
700
- runTestbed ('serves /packages/<package>/<path> files as if they were package:<package>/<path> uris' , () async {
700
+ runInTestbed ('serves /packages/<package>/<path> files as if they were package:<package>/<path> uris' , () async {
701
701
final String path = globals.fs.path.fromUri (
702
702
packages.resolve (Uri .parse ('package:flutter_tools/foo.dart' )),
703
703
);
@@ -716,12 +716,12 @@ void main() {
716
716
expect ((await response.read ().toList ()).first, source.readAsBytesSync ());
717
717
});
718
718
719
- runTestbed ('calling dispose closes the HTTP server' , () async {
719
+ runInTestbed ('calling dispose closes the HTTP server' , () async {
720
720
await webAssetServer.dispose ();
721
721
expect (httpServer.closed, true );
722
722
});
723
723
724
- runTestbed ('Can start web server with specified DDC module system assets' , () async {
724
+ runInTestbed ('Can start web server with specified DDC module system assets' , () async {
725
725
final String path = globals.fs.path.join ('lib' , 'main.dart' );
726
726
final File outputFile = globals.fs.file (path)
727
727
..createSync (recursive: true );
@@ -845,7 +845,7 @@ void main() {
845
845
await webDevFS.destroy ();
846
846
}, overrides: < Type , Generator > {Artifacts : Artifacts .test});
847
847
848
- runTestbed ('Can start web server with specified assets in sound null safety mode' , () async {
848
+ runInTestbed ('Can start web server with specified assets in sound null safety mode' , () async {
849
849
final String path = globals.fs.path.join ('lib' , 'main.dart' );
850
850
final File outputFile = globals.fs.file (path)
851
851
..createSync (recursive: true );
@@ -967,7 +967,7 @@ void main() {
967
967
await webDevFS.destroy ();
968
968
}, overrides: < Type , Generator > {Artifacts : Artifacts .test});
969
969
970
- runTestbed ('.connect() will never call vmServiceFactory twice' , () async {
970
+ runInTestbed ('.connect() will never call vmServiceFactory twice' , () async {
971
971
await FakeAsync ().run <Future <void >>((FakeAsync time) {
972
972
final String path = globals.fs.path.join ('lib' , 'main.dart' );
973
973
final File outputFile = globals.fs.file (path)
@@ -1047,7 +1047,7 @@ void main() {
1047
1047
});
1048
1048
}, overrides: < Type , Generator > {Artifacts : Artifacts .test});
1049
1049
1050
- runTestbed ('Can start web server with hostname any' , () async {
1050
+ runInTestbed ('Can start web server with hostname any' , () async {
1051
1051
final String path = globals.fs.path.join ('lib' , 'main.dart' );
1052
1052
final File outputFile = globals.fs.file (path)
1053
1053
..createSync (recursive: true );
@@ -1091,7 +1091,7 @@ void main() {
1091
1091
await webDevFS.destroy ();
1092
1092
});
1093
1093
1094
- runTestbed ('Can start web server with canvaskit enabled' , () async {
1094
+ runInTestbed ('Can start web server with canvaskit enabled' , () async {
1095
1095
final String path = globals.fs.path.join ('lib' , 'main.dart' );
1096
1096
final File outputFile = globals.fs.file (path)
1097
1097
..createSync (recursive: true );
@@ -1141,7 +1141,7 @@ void main() {
1141
1141
await webDevFS.destroy ();
1142
1142
});
1143
1143
1144
- runTestbed ('Can start web server with auto detect enabled' , () async {
1144
+ runInTestbed ('Can start web server with auto detect enabled' , () async {
1145
1145
final String path = globals.fs.path.join ('lib' , 'main.dart' );
1146
1146
final File outputFile = globals.fs.file (path)
1147
1147
..createSync (recursive: true );
@@ -1191,7 +1191,7 @@ void main() {
1191
1191
await webDevFS.destroy ();
1192
1192
});
1193
1193
1194
- runTestbed ('Can start web server with tls connection' , () async {
1194
+ runInTestbed ('Can start web server with tls connection' , () async {
1195
1195
final String dataPath = globals.fs.path.join (
1196
1196
getFlutterRoot (),
1197
1197
'packages' ,
@@ -1316,21 +1316,21 @@ void main() {
1316
1316
await webAssetServer.dispose ();
1317
1317
});
1318
1318
1319
- runTestbed ('WebAssetServer responds to POST requests with 404 not found' , () async {
1319
+ runInTestbed ('WebAssetServer responds to POST requests with 404 not found' , () async {
1320
1320
final Response response = await webAssetServer.handleRequest (
1321
1321
Request ('POST' , Uri .parse ('http://foobar/something' )),
1322
1322
);
1323
1323
expect (response.statusCode, 404 );
1324
1324
});
1325
1325
1326
- runTestbed ('ReleaseAssetServer responds to POST requests with 404 not found' , () async {
1326
+ runInTestbed ('ReleaseAssetServer responds to POST requests with 404 not found' , () async {
1327
1327
final Response response = await releaseAssetServer.handle (
1328
1328
Request ('POST' , Uri .parse ('http://foobar/something' )),
1329
1329
);
1330
1330
expect (response.statusCode, 404 );
1331
1331
});
1332
1332
1333
- runTestbed ('WebAssetServer strips leading base href off of asset requests' , () async {
1333
+ runInTestbed ('WebAssetServer strips leading base href off of asset requests' , () async {
1334
1334
const String htmlContent = '<html><head><base href="/foo/"></head><body id="test"></body></html>' ;
1335
1335
globals.fs.currentDirectory.childDirectory ('web' ).childFile ('index.html' )
1336
1336
..createSync (recursive: true )
@@ -1358,7 +1358,7 @@ void main() {
1358
1358
);
1359
1359
});
1360
1360
1361
- runTestbed ('DevFS URI includes any specified base path.' , () async {
1361
+ runInTestbed ('DevFS URI includes any specified base path.' , () async {
1362
1362
final String path = globals.fs.path.join ('lib' , 'main.dart' );
1363
1363
final File outputFile = globals.fs.file (path)
1364
1364
..createSync (recursive: true );
0 commit comments