ResourceProviderMixin mixin

A mixin for test classes that adds a memory-backed ResourceProvider and utility methods for manipulating the file system.

The resource provider will use paths in the same style as the current platform unless the TEST_ANALYZER_WINDOWS_PATHS environment variable is set to true, in which case it will use Windows-style paths.

The utility methods all take a posix style path and convert it as appropriate for the actual platform.

Mixin applications

Properties

hashCode int
The hash code for this object.
no setterinherited
pathContext → Context
The path context of resourceProvider.
no setter
resourceProvider → ResourceProvider
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

convertPath(String filePath) String
Converts the given posix filePath to conform to resourceProvider's path context.
deleteFile(String path) → void
Deletes the file at path.
deleteFolder(String path) → void
Deletes the folder at path.
fromUri(Uri uri) String
Returns uri as a String.
getFile(String path) → File
Gets the File at path.
getFolder(String path) → Folder
Gets the Folder at path.
join(String part1, [String? part2, String? part3, String? part4, String? part5, String? part6, String? part7, String? part8]) String
Joins the part paths as per path.Context.join.
modifyFile2(File file, String content) → void
Writes content to file.
newAnalysisOptionsYamlFile(String directoryPath, String content) → File
Writes a new analysis_options.yaml file at directoryPath with content.
newBazelBuildFile(String directoryPath, String content) → File
Creates a new Bazel BUILD file at directoryPath with content.
newBuildGnFile(String directoryPath, String content) → File
Creates a new BUILD.gn file at directoryPath with content.
newFile(String path, String content) → File
Writes content to the file at path.
newFolder(String path) → Folder
Creates and returns a new Folder at path.
Creates and returns a new Link at path to target.
newPackageConfigJsonFile(String directoryPath, String content) → File
Writes a .dart_tool/package_config.json file at directoryPath with content.
newPackageConfigJsonFileFromBuilder(String directoryPath, PackageConfigFileBuilder builder) → File
Writes a .dart_tool/package_config.json file at directoryPath.
newPubspecYamlFile(String directoryPath, String content) → File
Writes a pubspec.yaml file at directoryPath with content.
newSinglePackageConfigJsonFile({required String packagePath, required String name}) → void
Writes a new .dart_tool/package_config.json file for a package rooted at packagePath, named name.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
toUri(String path) Uri
Converts path to a URI.
toUriStr(String path) String
Converts path to a URI and returns the normalized String representation of the URI.

Operators

operator ==(Object other) bool
The equality operator.
inherited