TestNativePlatform class final
A custom NativePlatform for testing.
The individual properties can be left unset by the constructors. Accessing such properties will throw, but a test which doesn't use those properties doesn't have to provide values for them.
This class should not be used in production, since it reduces the compiler's ability to predict the values of the NativePlatform.operatingSystem or, for example, NativePlatform.isLinux checks, which can lead to larger compiled programs.
- Implemented types
- Annotations
-
- @visibleForTesting
Constructors
-
TestNativePlatform({Map<
String, String> ? environment, String? executable, List<String> ? executableArguments, String? lineTerminator, String? localeName, String? localHostname, int? numberOfProcessors, String? operatingSystem, String? operatingSystemVersion, String? packageConfig, String? pathSeparator, String? resolvedExecutable, Uri? script, bool? stdinSupportsAnsi, bool? stdoutSupportsAnsi, String? version}) - Creates a new TestNativePlatform with the specified properties.
- TestNativePlatform.from(NativePlatform platform)
-
Creates a new TestNativePlatform with the properties of
platform.factory - TestNativePlatform.fromJson(String jsonText)
-
Creates a new TestNativePlatform with properties from a JSON string.
factory
Properties
-
environment
→ Map<
String, String> -
The environment for this process.
no setteroverride
- executable → String
-
The file path of the executable used to run the script in this isolate.
no setteroverride
-
executableArguments
→ List<
String> -
The flags passed to the executable used to run the script of this program.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAndroid → bool
-
Whether the operating system is Android.
no setteroverride
- isFuchsia → bool
-
Whether the operating system is Fuchsia.
no setteroverride
- isIOS → bool
-
Whether the operating system is iOS.
no setteroverride
- isLinux → bool
-
Whether the operating system is Linux.
no setteroverride
- isMacOS → bool
-
Whether the operating system is OS X.
no setteroverride
- isWindows → bool
-
Whether the operating system is Windows.
no setteroverride
- lineTerminator → String
-
The default line terminator on the current platform.
no setteroverride
- localeName → String
-
Get the name of the current locale.
no setteroverride
- localHostname → String
-
Get the local hostname for the system.
no setteroverride
- numberOfProcessors → int
-
The number of processors of the machine.
no setteroverride
- operatingSystem → String
-
A string representing the operating system.
no setteroverride
- operatingSystemVersion → String
-
A string representing the version of the operating system or platform.
no setteroverride
- packageConfig → String?
-
The value of the
--packagesflag passed to the executable used to run the script in this isolate. This is the configuration which specifies how Dart packages are looked up.final - pathSeparator → String
-
The path separator used by the operating system to separate
components in file paths.
no setteroverride
- resolvedExecutable → String
-
The path of the executable used to run the script in this
isolate after it has been resolved by the OS.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- script → Uri
-
The absolute URI of the script file of the program currently running.
no setteroverride
- stdinSupportsAnsi → bool
-
When stdin is connected to a terminal, whether ANSI codes are supported.
no setteroverride
- stdoutSupportsAnsi → bool
-
When stdout is connected to a terminal, whether ANSI codes are supported.
no setteroverride
- version → String
-
The version of the current Dart runtime.
no setteroverride
Methods
-
bind<
R> (R withOverride()) → R Function() -
Wraps
withOverrideto run it with this native platform as current. -
copyPlatformWith(
{int? numberOfProcessors, String? pathSeparator, String? operatingSystem, String? operatingSystemVersion, String? localHostname, Map< String, String> ? environment, String? executable, String? resolvedExecutable, Uri? script, List<String> ? executableArguments, String? packageConfig, String? version, bool? stdinSupportsAnsi, bool? stdoutSupportsAnsi, String? localeName}) → TestPlatform -
Migration helper for legacy
FakePlatform.copyWith. -
copyWith(
{Map< String, String> ? environment, String? executable, List<String> ? executableArguments, String? lineTerminator, String? localeName, String? localHostname, int? numberOfProcessors, String? operatingSystem, String? operatingSystemVersion, String? packageConfig, String? pathSeparator, String? resolvedExecutable, Uri? script, bool? stdinSupportsAnsi, bool? stdoutSupportsAnsi, String? version}) → TestNativePlatform - Creates a new TestNativePlatform from this one.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run<
R> (R testCode()) → R -
Runs
testCodewith this native platform as current native platform. -
toJson(
) → String -
A JSON-encoded representation of this native platform test-configuration.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited