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_plus/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_plus/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.

Properties

config PatrolTesterConfig
Global configuration of this tester.
final
hashCode int
The hash code for this object.
no setterinherited
isAndroid bool
Whether the test is running on Android.
no setter
isIOS bool
Whether the test is running on iOS.
no setter
isMacOS bool
Whether the test is running on macOS.
no setter
isWeb bool
Whether the test is running on web.
no setter
patrolLog → PatrolLogWriter
Logs a message to the patrol log.
final
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, bool enablePatrolLog = true}) 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, Alignment alignment = Alignment.center, bool enablePatrolLog = true}) 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, Alignment alignment = Alignment.center, bool enablePatrolLog = true, bool hideKeyboard = true}) 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, Alignment alignment = Alignment.center, bool enablePatrolLog = true}) 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, bool enablePatrolLog = true}) 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, Alignment alignment = Alignment.center, bool enablePatrolLog = true}) Future<PatrolFinder>
Scrolls view in scrollDirection until this finders finds at least one existing widget.
tap(Finder finder, {SettlePolicy? settlePolicy, Duration? visibleTimeout, Duration? settleTimeout, Alignment alignment = Alignment.center, bool enablePatrolLog = true}) 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, bool enablePatrolLog = true}) Future<PatrolFinder>
Waits until this finder finds at least one widget.
waitUntilVisible(Finder finder, {Duration? timeout, Alignment alignment = Alignment.center, bool enablePatrolLog = true}) Future<PatrolFinder>
Waits until finder finds at least one visible widget.
wrapWithPatrolLog<T>({required String action, String? value, Finder? finder, required String color, required Future<T> function(), bool enablePatrolLog = true}) Future<T>
Wraps a function with a log entry for the start and end of the function.

Operators

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