Commit 142922de authored by Adam Barth's avatar Adam Barth Committed by GitHub

Add WidgetTester.hasRunningAnimation (#8886)

Fixes #4017
parent 9c876336
......@@ -222,10 +222,15 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
do {
await binding.pump(duration, phase);
count += 1;
} while (binding.transientCallbackCount > 0);
} while (hasRunningAnimations);
}).then<int>((Null _) => count);
}
/// Whether ther are any any transient callbacks scheduled.
///
/// This essentially checks whether all animations have completed.
bool get hasRunningAnimations => binding.transientCallbackCount > 0;
@override
HitTestResult hitTestOnBinding(Point location) {
location = binding.localToGlobal(location);
......
......@@ -185,4 +185,20 @@ void main() {
);
});
});
testWidgets('hasRunningAnimations control test', (WidgetTester tester) async {
final AnimationController controller = new AnimationController(
duration: const Duration(seconds: 1),
vsync: const TestVSync()
);
expect(tester.hasRunningAnimations, isFalse);
controller.forward();
expect(tester.hasRunningAnimations, isTrue);
controller.stop();
expect(tester.hasRunningAnimations, isFalse);
controller.forward();
expect(tester.hasRunningAnimations, isTrue);
await tester.pumpAndSettle();
expect(tester.hasRunningAnimations, isFalse);
});
}
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