golden_toolkit library
Copyright 2019-2020 eBay Inc.
Use of this source code is governed by a BSD-style license that can be found in the LICENSE file or at https://opensource.org/licenses/BSD-3-Clause
Classes
- Device
- This Device is a configuration for golden test. Can be provided for multiScreenGolden
- DeviceBuilder
- DeviceBuilder builds Device size driven layout for its children
- DeviceScenario
- Class containing whats required to create a Scenario
- DeviceScenarioWidget
- GoldenBuilder
- GoldenBuilder builds column/grid layout for it's children
- GoldenToolkit
- Manages global state & behavior for the Golden Toolkit This is a singleton so that it can be easily configured in one place and shared across tests
- GoldenToolkitConfiguration
- Represents configuration options for the GoldenToolkit. These are akin to environmental flags.
Extensions
- TestingToolsExtension on WidgetTester
- Extensions for a WidgetTester
- TestWindowExtensions on TestWindow
- Convenience extensions for configuring elements of the TestWindow
- WidgetFlutterBindingExtensions on TestWidgetsFlutterBinding
- Convenience extensions for more easily configuring WidgetTester for pre-set configurations
- WidgetTesterImageLoadingExtensions on WidgetTester
- Convenience extensions on WidgetTester
Constants
- textScaleFactorMaxSupported → const double
- as of iOS 13.2.3 the max textScaleFactor a user can set is ~3.1176
Functions
-
defaultDeviceFileNameFactory(
String name, Device device) → String -
This is the default file name factory which is used by multiScreenGolden to determine the
actual file name for a golden test. The given
name
is the name passed into multiScreenGolden. -
defaultFileNameFactory(
String name) → String -
This is the default file name factory which is used by screenMatchesGolden to determine the
actual file name for a golden test. The given
name
is the name passed into screenMatchesGolden. -
defaultPrimeAssets(
WidgetTester tester) → Future< void> - A function that waits for all Image widgets found in the widget tree to finish decoding.
-
legacyPrimeAssets(
WidgetTester tester) → Future< void> - A function that primes all assets by just wasting time and hoping that it is enough for all assets to finish loading. Doing so is not recommended and very flaky. Consider switching to defaultPrimeAssets or a custom implementation.
-
loadAppFonts(
) → Future< void> - By default, flutter test only uses a single "test" font called Ahem.
-
materialAppWrapper(
{TargetPlatform platform = TargetPlatform.android, Iterable< LocalizationsDelegate> ? localizations, Iterable<Locale> ? localeOverrides, ThemeData? theme}) → WidgetWrapper - This materialAppWrapper is a convenience function to wrap your widget in MaterialApp Wraps your widget in MaterialApp, inject custom theme, localizations, override surfaceSize and platform
-
multiScreenGolden(
WidgetTester tester, String name, {Finder? finder, bool? autoHeight, double? overrideGoldenHeight, CustomPump? customPump, DeviceSetup? deviceSetup, List< Device> ? devices, bool? skip}) → Future<void> -
This multiScreenGolden will run
scenarios
for givendevices
list -
noWrap(
) → WidgetWrapper - This noWrap is a convenience function if you don't want to wrap widgets in default materialAppWrapper
-
screenMatchesGolden(
WidgetTester tester, String name, {bool? autoHeight, Finder? finder, CustomPump? customPump, bool? skip}) → Future< void> -
A function that wraps matchesGoldenFile with some extra functionality. The function finds the first widget
in the tree if
finder
is not specified. Furthermore afileNameFactory
can be used in combination with aname
to specify a custom path and name for the golden file. In addition to that the function makes sure all images are available before -
testGoldens(
String description, Future< void> test(WidgetTester), {bool? skip, Object? tags = _defaultTagObject}) → void - This testGoldens method exists as a way to enforce the proper naming of tests that contain golden diffs so that we can reliably run all goldens
Typedefs
-
CustomPump
= Future<
void> Function(WidgetTester) - CustomPump is a function that lets you do custom pumping before golden evaluation. Sometimes, you want to do a golden test for different stages of animations, so its crucial to have a precise control over pumps and durations
- DeviceFileNameFactory = String Function(String name, Device device)
- A factory to determine a file name/path from a name and a device.
-
DeviceSetup
= Future<
void> Function(Device device, WidgetTester tester) - Function definition for allowing for device or test setup to occur for each device configuration under test
- FileNameFactory = String Function(String name)
- A factory to determine an actual file name/path from a given name.
-
OnScenarioCreate
= Future<
void> Function(Key scenarioWidgetKey) - Hook for running arbitrary behavior for a particular scenario
-
PrimeAssets
= Future<
void> Function(WidgetTester tester) -
A function that primes all needed assets for the given
tester
. - SkipGoldenAssertion = bool Function()
- A func that will be evaluated at runtime to determine if the golden assertion should be skipped
- WidgetWrapper = Widget Function(Widget)
- Typedef for wrapping a widget with one or more other widgets