PatrolTester class

PatrolTester wraps a WidgetTester. It provides support for Patrol custom finder, a.k.a $.

If you want to do something that WidgetTester supports, but PatrolTester does not, you can access the underlying WidgetTester via tester field of PatrolTester.

import 'package:patrol/patrol.dart';

void main() {
  patrolWidgetTest('Counter increments smoke test', (patrolTester) async {
    await patrolTester.pumpWidgetAndSettle(const MyApp());
    await patrolTester(#startAppButton).tap();
  });
}

To make test code more concise, patrolTester variable is usually called $, like this:

import 'package:patrol/patrol.dart';
void main() {
  patrolWidgetTest('Counter increments smoke test', ($) async {
    await $.pumpWidgetAndSettle(const MyApp());
    await $(#startAppButton).tap();
  });
}

You can call PatrolTester just like a normal method, because it is a callable class.

Constructors

PatrolTester({required WidgetTester tester, required PatrolTesterConfig config})
Creates a new PatrolTester which wraps tester.
const

Properties

config PatrolTesterConfig
Global configuration of this tester.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tester WidgetTester
Flutter's widget tester that this PatrolTester wraps.
final

Methods

call(dynamic matching) PatrolFinder
Returns a PatrolFinder that matches matching.
dragUntilExists({required Finder finder, required Finder view, required Offset moveStep, int maxIteration = defaultScrollMaxIteration, Duration? settleBetweenScrollsTimeout, Duration? dragDuration, SettlePolicy? settlePolicy}) Future<PatrolFinder>
Repeatedly drags view by moveStep until finder finds at least one existing widget.
dragUntilVisible({required Finder finder, required Finder view, required Offset moveStep, int maxIteration = defaultScrollMaxIteration, Duration? settleBetweenScrollsTimeout, Duration? dragDuration, SettlePolicy? settlePolicy}) Future<PatrolFinder>
Repeatedly drags view by moveStep until finder finds at least one visible widget.
enterText(Finder finder, String text, {SettlePolicy? settlePolicy, Duration? visibleTimeout, Duration? settleTimeout}) Future<void>
Waits until finder finds at least 1 visible widget and then enters text into it.
longPress(Finder finder, {SettlePolicy? settlePolicy, Duration? visibleTimeout, Duration? settleTimeout}) Future<void>
Waits until this finder finds at least 1 visible widget and then makes long press gesture on it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pump([Duration? duration, EnginePhase phase = EnginePhase.sendSemanticsUpdate]) Future<void>
See WidgetTester.pump.
pumpAndSettle({Duration duration = const Duration(milliseconds: 100), EnginePhase phase = EnginePhase.sendSemanticsUpdate, Duration? timeout}) Future<void>
See WidgetTester.pumpAndSettle.
pumpAndTrySettle({Duration duration = const Duration(milliseconds: 100), EnginePhase phase = EnginePhase.sendSemanticsUpdate, Duration? timeout}) Future<void>
Calls WidgetTester.pumpAndSettle but doesn't throw if it times out. It prevents the test from failing when there's e.g. an infinite animation.
pumpWidget(Widget widget, [Duration? duration, EnginePhase phase = EnginePhase.sendSemanticsUpdate]) Future<void>
See WidgetTester.pumpWidget.
pumpWidgetAndSettle(Widget widget, {Duration? duration, EnginePhase phase = EnginePhase.sendSemanticsUpdate, Duration? timeout}) Future<void>
Pumps widget and then calls WidgetTester.pumpAndSettle.
scrollUntilExists({required Finder finder, Finder? view, double delta = defaultScrollDelta, AxisDirection? scrollDirection, int maxScrolls = defaultScrollMaxIteration, Duration? settleBetweenScrollsTimeout, Duration? dragDuration, SettlePolicy? settlePolicy}) Future<PatrolFinder>
Scrolls view in its scrolling direction until this finders finds at least one existing widget.
scrollUntilVisible({required Finder finder, Finder? view, double delta = defaultScrollDelta, AxisDirection? scrollDirection, int maxScrolls = defaultScrollMaxIteration, Duration? settleBetweenScrollsTimeout, Duration? dragDuration, SettlePolicy? settlePolicy}) Future<PatrolFinder>
Scrolls view in scrollDirection until this finders finds at least one existing widget.
tap(Finder finder, {SettlePolicy? settlePolicy, Duration? visibleTimeout, Duration? settleTimeout}) Future<void>
Waits until this finder finds at least 1 visible widget and then taps on it.
toString() String
A string representation of this object.
inherited
waitUntilExists(PatrolFinder finder, {Duration? timeout}) Future<PatrolFinder>
Waits until this finder finds at least one widget.
waitUntilVisible(Finder finder, {Duration? timeout}) Future<PatrolFinder>
Waits until finder finds at least one visible widget.

Operators

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