Unverified Commit 073126fd authored by Jia Hao's avatar Jia Hao Committed by GitHub

Allow waitUntilFirstFrameRasterized without a root widget (#56430)

parent e88ef6d5
...@@ -31,6 +31,9 @@ class WaitForCondition extends Command { ...@@ -31,6 +31,9 @@ class WaitForCondition extends Command {
@override @override
String get kind => 'waitForCondition'; String get kind => 'waitForCondition';
@override
bool get requiresRootWidgetAttached => condition.requiresRootWidgetAttached;
} }
/// A Flutter Driver command that waits until there are no more transient callbacks in the queue. /// A Flutter Driver command that waits until there are no more transient callbacks in the queue.
...@@ -148,6 +151,20 @@ abstract class SerializableWaitCondition { ...@@ -148,6 +151,20 @@ abstract class SerializableWaitCondition {
'conditionName': conditionName 'conditionName': conditionName
}; };
} }
/// Whether this command requires the widget tree to be initialized before
/// the command may be run.
///
/// This defaults to true to force the application under test to call [runApp]
/// before attempting to remotely drive the application. Subclasses may
/// override this to return false if they allow invocation before the
/// application has started.
///
/// See also:
///
/// * [WidgetsBinding.isRootWidgetAttached], which indicates whether the
/// widget tree has been initialized.
bool get requiresRootWidgetAttached => true;
} }
/// A condition that waits until no transient callbacks are scheduled. /// A condition that waits until no transient callbacks are scheduled.
...@@ -208,6 +225,9 @@ class FirstFrameRasterized extends SerializableWaitCondition { ...@@ -208,6 +225,9 @@ class FirstFrameRasterized extends SerializableWaitCondition {
@override @override
String get conditionName => 'FirstFrameRasterizedCondition'; String get conditionName => 'FirstFrameRasterizedCondition';
@override
bool get requiresRootWidgetAttached => false;
} }
/// A condition that waits until there are no pending platform messages. /// A condition that waits until there are no pending platform messages.
......
...@@ -41,6 +41,17 @@ void main() { ...@@ -41,6 +41,17 @@ void main() {
expect(waitForCondition.condition, equals(const NoTransientCallbacks())); expect(waitForCondition.condition, equals(const NoTransientCallbacks()));
expect(waitForCondition.timeout, equals(const Duration(milliseconds: 10))); expect(waitForCondition.timeout, equals(const Duration(milliseconds: 10)));
}); });
test('WaitForCondition requiresRootWidget', () {
expect(
const WaitForCondition(NoTransientCallbacks())
.requiresRootWidgetAttached,
isTrue);
expect(
const WaitForCondition(FirstFrameRasterized())
.requiresRootWidgetAttached,
isFalse);
});
}); });
group('NoTransientCallbacksCondition', () { group('NoTransientCallbacksCondition', () {
...@@ -113,6 +124,10 @@ void main() { ...@@ -113,6 +124,10 @@ void main() {
throwsA(predicate<SerializationException>((SerializationException e) => throwsA(predicate<SerializationException>((SerializationException e) =>
e.message == 'Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: {conditionName: Unknown}'))); e.message == 'Error occurred during deserializing the FirstFrameRasterizedCondition JSON string: {conditionName: Unknown}')));
}); });
test('FirstFrameRasterizedCondition requiresRootWidget', () {
expect(const FirstFrameRasterized().requiresRootWidgetAttached, isFalse);
});
}); });
group('CombinedCondition', () { group('CombinedCondition', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment