LiveTestWidgetsFlutterBindingFramePolicy enum
Available policies for how a LiveTestWidgetsFlutterBinding should paint frames.
These values are set on the binding's LiveTestWidgetsFlutterBinding.framePolicy property.
The default is LiveTestWidgetsFlutterBindingFramePolicy.fadePointers. Setting this to anything other than LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps results in pumping extra frames, which might involve calling builders more, or calling paint callbacks more, etc, and might interfere with the test. If you know that your test won't be affected by this, you can set the policy to LiveTestWidgetsFlutterBindingFramePolicy.fullyLive or LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive in that particular file.
To set a value while still allowing the test file to work as a normal test,
add the following code to your test file at the top of your
void main() { }
function, before calls to testWidgets:
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
if (binding is LiveTestWidgetsFlutterBinding) {
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps;
}
Values
- onlyPumps → const LiveTestWidgetsFlutterBindingFramePolicy
-
Strictly show only frames that are explicitly pumped.
This most closely matches the AutomatedTestWidgetsFlutterBinding (the default binding for
flutter test
) behavior. - fadePointers → const LiveTestWidgetsFlutterBindingFramePolicy
-
Show pumped frames, and additionally schedule and run frames to fade out the pointer crosshairs and other debugging information shown by the binding.
This will schedule frames when pumped or when there has been some activity with TestPointers.
This can result in additional frames being pumped beyond those that the test itself requests, which can cause differences in behavior.
- fullyLive → const LiveTestWidgetsFlutterBindingFramePolicy
-
Show every frame that the framework requests, even if the frames are not explicitly pumped.
The major difference between fullyLive and benchmarkLive is the latter ignores frame requests by WidgetTester.pump.
This can help with orienting the developer when looking at heavily-animated situations, and will almost certainly result in additional frames being pumped beyond those that the test itself requests, which can cause differences in behavior.
- benchmark → const LiveTestWidgetsFlutterBindingFramePolicy
-
Ignore any request to schedule a frame.
This is intended to be used by benchmarks (hence the name) that drive the pipeline directly. It tells the binding to entirely ignore requests for a frame to be scheduled, while still allowing frames that are pumped directly to run (either by using WidgetTester.pumpBenchmark or invoking PlatformDispatcher.onBeginFrame and PlatformDispatcher.onDrawFrame).
This allows all frame requests from the engine to be serviced, and allows all frame requests that are artificially triggered to be serviced, but ignores SchedulerBinding.scheduleFrame requests from the framework. Therefore animation won't run for this mode because the framework generates an animation by requesting new frames.
The SchedulerBinding.hasScheduledFrame property will never be true in this mode. This can cause unexpected effects. For instance, WidgetTester.pumpAndSettle does not function in this mode, as it relies on the SchedulerBinding.hasScheduledFrame property to determine when the application has "settled".
- benchmarkLive → const LiveTestWidgetsFlutterBindingFramePolicy
-
Ignore any request from pump but respect other requests to schedule a frame.
This is used for running the test on a device, where scheduling of new frames respects what the engine and the device needed.
Compared to fullyLive this policy ignores the frame requests from WidgetTester.pump so that frame scheduling mimics that of the real environment, and avoids waiting for an artificially pumped frame. (For example, when driving the test in methods like WidgetTester.handlePointerEventRecord or WidgetTester.fling.)
This policy differs from benchmark in that it can be used for capturing animation frames requested by the framework.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
LiveTestWidgetsFlutterBindingFramePolicy> - A constant List of the values in this enum, in order of their declaration.