testing library

Platform information, and mocking of that information for tests.

This library provides the Platform interface of the platform.dart library, and the BrowserPlatform and NativePlatform types that it may or may not expose an instance of.

On top of that, this library also exposes mock-versions of those platform specific classes: TestBrowserPlatform and TestNativePlatform, and a TestPlatform that can hold one of these.

These test-only classes can be used to specify a platform configuration that is not the actual current platform. Using the run methods of those test-classes will run the function in a zone-context where Platform.current is the test-configuration.

Warning

These test-classes should only be used for testing. Importing this library in a production program may cause more code to be retained than necessary.

Classes

BrowserPlatform
Information about the current browser.
NativePlatform
Properties of the native host platform and process.
Platform
Dart runtime platform information.
TestBrowserPlatform
A custom BrowserPlatform for testing.
TestNativePlatform
A custom NativePlatform for testing.
TestPlatform
Custom Dart runtime platform information for testing.

Extensions

PlatformIsOS on Platform
Shorthands for checking operating system on the native platform.