simulateFrameTimings method

  1. @visibleForTesting
void simulateFrameTimings(
  1. List<FrameTiming> timings
)

Injects synthetic FrameTiming data directly into the phase handlers, bypassing the SchedulerBinding listener registration.

For testing only. Allows unit tests to exercise Phase 2 and Phase 3 logic without a real GPU raster loop or a widget binding.

If the adapter is still in the AdaptivePhase.probe phase (i.e. start was never called), this automatically advances to AdaptivePhase.warmup before processing the timings.

final adapter = GlassQualityAdapter(...);
adapter.simulateFrameTimings(_frames(180, 15000)); // 15 ms → standard
expect(adapter.currentQuality, GlassQuality.standard);

Implementation

@visibleForTesting
void simulateFrameTimings(List<FrameTiming> timings) {
  // Auto-advance out of probe so tests don't need to call start().
  if (_phase == AdaptivePhase.probe) {
    _phase = AdaptivePhase.warmup;
  }
  for (final timing in timings) {
    final rasterUs = timing.rasterDuration.inMicroseconds;
    if (_phase == AdaptivePhase.warmup) {
      _processWarmupFrame(rasterUs);
    } else if (_phase == AdaptivePhase.runtime) {
      _processRuntimeFrame(rasterUs);
    }
  }
}