TestPlatform class final

Custom Dart runtime platform information for testing.

Implements Platform, but allows a TestBrowserPlatform or TestNativePlatform to be the non-null platform object.

Implemented types
Available extensions
Annotations
  • @visibleForTesting

Constructors

TestPlatform.browserFromJson(String browserPlatformJson)
Creates a TestPlatform with a TestBrowserPlatform created from JSON.
TestPlatform.fromBrowser(BrowserPlatform browserPlatform)
Creates a TestPlatform with a copy of a given BrowserPlatform.
TestPlatform.fromNative(NativePlatform nativePlatform)
Creates a TestPlatform with a copy of a given NativePlatform.
TestPlatform.fromPlatform(Platform platform)
Creates a TestPlatform with the same properties as platform.
factory
TestPlatform.native({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 TestPlatform with a new TestNativePlatform.
TestPlatform.nativeFromJson(String nativePlatformJson)
Creates a TestPlatform with a TestNativePlatform created from JSON.
TestPlatform.unknown()
A platform with neither the native or the browser platform available.
const

Properties

browserPlatform → TestBrowserPlatform?
The current browser platform, if running on a browser platform.
final
environment → Map<String, String>
The environment for this process.
no setterinherited
executable → String
The file path of the executable used to run the script in this isolate.
no setterinherited
executableArguments → List<String>
The flags passed to the executable used to run the script of this program.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
isAndroid → bool
Whether a Platform.nativePlatform with NativePlatform.isAndroid.
no setterinherited
isAndroid → bool

Available on Platform, provided by the PlatformIsOS extension

Whether this is a nativePlatform with NativePlatform.isAndroid.
no setter
isBrowser → bool
Whether currently running in a browser.
no setteroverride
isFuchsia → bool
Whether a Platform.nativePlatform with NativePlatform.isFuchsia.
no setterinherited
isFuchsia → bool

Available on Platform, provided by the PlatformIsOS extension

Whether this is a nativePlatform with NativePlatform.isFuchsia.
no setter
isIOS → bool
Whether a Platform.nativePlatform with NativePlatform.isIOS.
no setterinherited
isIOS → bool

Available on Platform, provided by the PlatformIsOS extension

Whether this is a nativePlatform with NativePlatform.isIOS.
no setter
isLinux → bool
Whether a Platform.nativePlatform with NativePlatform.isLinux.
no setterinherited
isLinux → bool

Available on Platform, provided by the PlatformIsOS extension

Whether this is a nativePlatform with NativePlatform.isLinux.
no setter
isMacOS → bool
Whether a Platform.nativePlatform with NativePlatform.isMacOS.
no setterinherited
isMacOS → bool

Available on Platform, provided by the PlatformIsOS extension

Whether this is a nativePlatform with NativePlatform.isMacOS.
no setter
isNative → bool
Whether currently running on a native platform.
no setteroverride
isWindows → bool
Whether a Platform.nativePlatform with NativePlatform.isWindows.
no setterinherited
isWindows → bool

Available on Platform, provided by the PlatformIsOS extension

Whether this is a nativePlatform with NativePlatform.isWindows.
no setter
localeName → String
Get the name of the current locale.
no setterinherited
localHostname → String
Get the local hostname for the system.
no setterinherited
nativePlatform → TestNativePlatform?
The current native platform, if running on a native platform.
final
numberOfProcessors → int
The number of processors of the machine.
no setterinherited
operatingSystem → String
A string representing the operating system.
no setterinherited
operatingSystemVersion → String
A string representing the version of the operating system or platform.
no setterinherited
packageConfig → String?
The value of the --packages flag passed to the executable used to run the script in this isolate. This is the configuration which specifies how Dart packages are looked up.
no setterinherited
pathSeparator → String
The path separator used by the operating system to separate components in file paths.
no setterinherited
resolvedExecutable → String
The path of the executable used to run the script in this isolate after it has been resolved by the OS.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
script → Uri
The absolute URI of the script being run in this isolate.
no setterinherited
stdinSupportsAnsi → bool
When stdin is connected to a terminal, whether ANSI codes are supported.
no setterinherited
stdoutSupportsAnsi → bool
When stdout is connected to a terminal, whether ANSI codes are supported.
no setterinherited
version → String
The version of the current Dart runtime.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run<R>(R testCode()) → R
Runs testCode with this platform as the current platform.
toJson() → String
A JSON-encoded representation of platform information.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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