@@ -10,6 +10,7 @@ import 'package:analyzer/source/file_source.dart';
10
10
import 'package:analyzer/source/source.dart' ;
11
11
import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
12
12
import 'package:analyzer/src/generated/utilities_dart.dart' ;
13
+ import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart' ;
13
14
import 'package:path/path.dart' as path;
14
15
import 'package:test/test.dart' ;
15
16
import 'package:test_reflective_loader/test_reflective_loader.dart' ;
@@ -59,6 +60,9 @@ abstract class BaseTest extends FileSystemTestSupport {
59
60
@override
60
61
MemoryResourceProvider get provider => _provider ?? = createProvider ();
61
62
63
+ String convertPath (String filePath) =>
64
+ ResourceProviderExtensions (provider).convertPath (filePath);
65
+
62
66
/// Create the resource provider to be used by the tests. Subclasses can
63
67
/// override this method to change the class of resource provider that is
64
68
/// used.
@@ -69,7 +73,7 @@ abstract class BaseTest extends FileSystemTestSupport {
69
73
if (filePath == null ) {
70
74
filePath = defaultFilePath;
71
75
} else {
72
- filePath = provider. convertPath (filePath);
76
+ filePath = convertPath (filePath);
73
77
}
74
78
if (exists) {
75
79
provider.newFile (filePath, content ?? defaultFileContent);
@@ -82,7 +86,7 @@ abstract class BaseTest extends FileSystemTestSupport {
82
86
if (folderPath == null ) {
83
87
folderPath = defaultFolderPath;
84
88
} else {
85
- folderPath = provider. convertPath (folderPath);
89
+ folderPath = convertPath (folderPath);
86
90
}
87
91
if (exists) {
88
92
provider.newFolder (folderPath);
@@ -92,17 +96,17 @@ abstract class BaseTest extends FileSystemTestSupport {
92
96
93
97
@override
94
98
Link getLink ({required String linkPath, String ? target}) {
95
- linkPath = provider. convertPath (linkPath);
99
+ linkPath = convertPath (linkPath);
96
100
if (target != null ) {
97
- target = provider. convertPath (target);
101
+ target = convertPath (target);
98
102
99
103
provider.newLink (linkPath, target);
100
104
}
101
105
return provider.getLink (linkPath);
102
106
}
103
107
104
108
setUp () {
105
- tempPath = provider. convertPath ('/temp' );
109
+ tempPath = convertPath ('/temp' );
106
110
defaultFolderPath = join (tempPath, 'bar' );
107
111
defaultFilePath = join (tempPath, 'bar' , 'test.dart' );
108
112
}
@@ -184,16 +188,14 @@ class MemoryFileSourceExistingTest extends BaseTest {
184
188
);
185
189
expect (
186
190
relative,
187
- provider.pathContext.toUri (
188
- provider.convertPath ('/temp/bar/bar/baz.dart' ),
189
- ),
191
+ provider.pathContext.toUri (convertPath ('/temp/bar/bar/baz.dart' )),
190
192
);
191
193
}
192
194
193
195
test_resolveRelative_dart () {
194
196
File file = getFile (
195
197
exists: false ,
196
- filePath: provider. convertPath ('/sdk/lib/core/core.dart' ),
198
+ filePath: convertPath ('/sdk/lib/core/core.dart' ),
197
199
);
198
200
Source source = FileSource (file, Uri .parse ('dart:core' ));
199
201
@@ -238,9 +240,7 @@ class MemoryFileSourceNotExistingTest extends BaseTest {
238
240
);
239
241
expect (
240
242
relative,
241
- provider.pathContext.toUri (
242
- provider.convertPath ('/temp/bar/bar/baz.dart' ),
243
- ),
243
+ provider.pathContext.toUri (convertPath ('/temp/bar/bar/baz.dart' )),
244
244
);
245
245
}
246
246
@@ -296,12 +296,12 @@ class MemoryFileTest extends BaseTest with FileTestMixin {
296
296
@reflectiveTest
297
297
class MemoryFolderTest extends BaseTest with FolderTestMixin {
298
298
test_isRoot_false () {
299
- var path = provider. convertPath ('/foo' );
299
+ var path = convertPath ('/foo' );
300
300
expect (provider.getFolder (path).isRoot, isFalse);
301
301
}
302
302
303
303
test_isRoot_true () {
304
- var path = provider. convertPath ('/' );
304
+ var path = convertPath ('/' );
305
305
expect (provider.getFolder (path).isRoot, isTrue);
306
306
}
307
307
}
@@ -404,16 +404,13 @@ class MemoryResourceProviderTest extends BaseTest
404
404
}
405
405
406
406
test_newLink_folder () {
407
- provider.newLink (
408
- provider.convertPath ('/test/lib/foo' ),
409
- provider.convertPath ('/test/lib' ),
410
- );
407
+ provider.newLink (convertPath ('/test/lib/foo' ), convertPath ('/test/lib' ));
411
408
412
- provider.newFile (provider. convertPath ('/test/lib/a.dart' ), 'aaa' );
409
+ provider.newFile (convertPath ('/test/lib/a.dart' ), 'aaa' );
413
410
414
411
{
415
412
var path = '/test/lib/foo/a.dart' ;
416
- var convertedPath = provider. convertPath (path);
413
+ var convertedPath = convertPath (path);
417
414
var file = provider.getFile (convertedPath);
418
415
expect (file.exists, true );
419
416
expect (file.modificationStamp, isNonNegative);
@@ -422,7 +419,7 @@ class MemoryResourceProviderTest extends BaseTest
422
419
423
420
{
424
421
var path = '/test/lib/foo/foo/a.dart' ;
425
- var convertedPath = provider. convertPath (path);
422
+ var convertedPath = convertPath (path);
426
423
var file = provider.getFile (convertedPath);
427
424
expect (file.exists, true );
428
425
expect (file.modificationStamp, isNonNegative);
@@ -444,7 +441,7 @@ class MemoryResourceProviderTest extends BaseTest
444
441
}
445
442
446
443
test_watch_createFile () {
447
- String rootPath = provider. convertPath ('/my/path' );
444
+ String rootPath = convertPath ('/my/path' );
448
445
provider.newFolder (rootPath);
449
446
return _watchingFolder (rootPath, (changesReceived) {
450
447
expect (changesReceived, hasLength (0 ));
@@ -460,7 +457,7 @@ class MemoryResourceProviderTest extends BaseTest
460
457
}
461
458
462
459
test_watch_deleteFile () {
463
- String rootPath = provider. convertPath ('/my/path' );
460
+ String rootPath = convertPath ('/my/path' );
464
461
provider.newFolder (rootPath);
465
462
String path = provider.pathContext.join (rootPath, 'foo' );
466
463
provider.newFile (path, 'contents 1' );
@@ -477,7 +474,7 @@ class MemoryResourceProviderTest extends BaseTest
477
474
}
478
475
479
476
test_watch_modifyFile () {
480
- String rootPath = provider. convertPath ('/my/path' );
477
+ String rootPath = convertPath ('/my/path' );
481
478
provider.newFolder (rootPath);
482
479
String path = provider.pathContext.join (rootPath, 'foo' );
483
480
provider.newFile (path, 'contents 1' );
@@ -494,7 +491,7 @@ class MemoryResourceProviderTest extends BaseTest
494
491
}
495
492
496
493
test_watch_modifyFile_inSubDir () {
497
- String rootPath = provider. convertPath ('/my/path' );
494
+ String rootPath = convertPath ('/my/path' );
498
495
provider.newFolder (rootPath);
499
496
String subdirPath = provider.pathContext.join (rootPath, 'foo' );
500
497
provider.newFolder (subdirPath);
0 commit comments