[flutter_driver] Add waitForTappable to flutter_driver (#79581)
This commit is contained in:
@@ -56,6 +56,7 @@ mixin DeserializeCommandFactory {
|
||||
case 'tap': return Tap.deserialize(params, finderFactory);
|
||||
case 'waitFor': return WaitFor.deserialize(params, finderFactory);
|
||||
case 'waitForAbsent': return WaitForAbsent.deserialize(params, finderFactory);
|
||||
case 'waitForTappable': return WaitForTappable.deserialize(params, finderFactory);
|
||||
case 'waitForCondition': return WaitForCondition.deserialize(params);
|
||||
case 'waitUntilNoTransientCallbacks': return WaitForCondition.deserialize(params);
|
||||
case 'waitUntilNoPendingFrame': return WaitForCondition.deserialize(params);
|
||||
|
||||
@@ -80,6 +80,24 @@ class WaitForAbsent extends CommandWithTarget {
|
||||
String get kind => 'waitForAbsent';
|
||||
}
|
||||
|
||||
/// A Flutter Driver command that waits until [finder] can be tapped.
|
||||
class WaitForTappable extends CommandWithTarget {
|
||||
/// Creates a command that waits for the widget identified by [finder] to
|
||||
/// be tappable within the [timeout] amiount of time.
|
||||
///
|
||||
/// If [timeout] is not specified, the command defuts to no timeout.
|
||||
WaitForTappable(SerializableFinder finder, {Duration? timeout})
|
||||
: super(finder, timeout: timeout);
|
||||
|
||||
/// Deserialized this command from the value generated by [serialize].
|
||||
WaitForTappable.deserialize(
|
||||
Map<String, String> json, DeserializeFinderFactory finderFactory)
|
||||
: super.deserialize(json, finderFactory);
|
||||
|
||||
@override
|
||||
String get kind => 'waitForTappable';
|
||||
}
|
||||
|
||||
/// Base class for Flutter Driver finders, objects that describe how the driver
|
||||
/// should search for elements.
|
||||
abstract class SerializableFinder {
|
||||
|
||||
@@ -169,6 +169,7 @@ mixin CommandHandlerFactory {
|
||||
case 'tap': return _tap(command, prober, finderFactory);
|
||||
case 'waitFor': return _waitFor(command, finderFactory);
|
||||
case 'waitForAbsent': return _waitForAbsent(command, finderFactory);
|
||||
case 'waitForTappable': return _waitForTappable(command, finderFactory);
|
||||
case 'waitForCondition': return _waitForCondition(command);
|
||||
case 'waitUntilNoTransientCallbacks': return _waitUntilNoTransientCallbacks(command);
|
||||
case 'waitUntilNoPendingFrame': return _waitUntilNoPendingFrame(command);
|
||||
@@ -236,6 +237,14 @@ mixin CommandHandlerFactory {
|
||||
return Result.empty;
|
||||
}
|
||||
|
||||
Future<Result> _waitForTappable(Command command, CreateFinderFactory finderFactory) async {
|
||||
final WaitForTappable waitForTappableCommand = command as WaitForTappable;
|
||||
await waitForElement(
|
||||
finderFactory.createFinder(waitForTappableCommand.finder).hitTestable(),
|
||||
);
|
||||
return Result.empty;
|
||||
}
|
||||
|
||||
Future<Result> _waitForCondition(Command command) async {
|
||||
assert(command != null);
|
||||
final WaitForCondition waitForConditionCommand = command as WaitForCondition;
|
||||
|
||||
@@ -220,6 +220,11 @@ abstract class FlutterDriver {
|
||||
await sendCommand(WaitForAbsent(finder, timeout: timeout));
|
||||
}
|
||||
|
||||
/// Waits until [finder] is tappable.
|
||||
Future<void> waitForTappable(SerializableFinder finder, { Duration? timeout }) async {
|
||||
await sendCommand(WaitForTappable(finder, timeout: timeout));
|
||||
}
|
||||
|
||||
/// Waits until the given [waitCondition] is satisfied.
|
||||
Future<void> waitForCondition(SerializableWaitCondition waitCondition, {Duration? timeout}) async {
|
||||
await sendCommand(WaitForCondition(waitCondition, timeout: timeout));
|
||||
|
||||
Reference in New Issue
Block a user