Reland VelocityTracker update (again) (#138843)

This updates the implementation to use the stopwatch from the Clock object and piping it through to the TestWidgetsFlutterBinding so it will be kept in sync with FakeAsync.

Relands https://github.com/flutter/flutter/pull/137381 which attempted to reland #132291
Fixes https://github.com/flutter/flutter/issues/97761

The original change was reverted due to flakiness it introduced in tests that use fling gestures.
* https://github.com/flutter/flutter/issues/135728

It was reverted again due to a change in the leak tracking tests that broke it.
This commit is contained in:
Kate Lovett
2023-11-21 16:21:22 -06:00
committed by GitHub
parent 50c9a377c7
commit 3e4e280914
7 changed files with 141 additions and 43 deletions

View File

@@ -425,6 +425,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// actual current wall-clock time.
Clock get clock;
@override
SamplingClock? get debugSamplingClock => _TestSamplingClock(clock);
/// Triggers a frame sequence (build/layout/paint/etc),
/// then flushes microtasks.
///
@@ -2149,6 +2152,18 @@ class TestViewConfiguration extends ViewConfiguration {
String toString() => 'TestViewConfiguration';
}
class _TestSamplingClock implements SamplingClock {
_TestSamplingClock(this._clock);
@override
DateTime now() => _clock.now();
@override
Stopwatch stopwatch() => _clock.stopwatch();
final Clock _clock;
}
const int _kPointerDecay = -2;
class _LiveTestPointerRecord {