import 'dart:ui'; import 'package:flutter_test/flutter_test.dart'; import 'package:badnote/editor/engine/stroke_predictor.dart'; void main() { test('StrokePredictor projects ahead when velocity is high', () { final p = StrokePredictor(lookaheadMs: 16); final t0 = DateTime.utc(2026, 1, 1, 0, 0, 0, 0); expect(p.observe(const Offset(0, 0), 0.5, at: t0), isNull); final tip = p.observe( const Offset(10, 0), 0.5, at: t0.add(const Duration(milliseconds: 8)), ); // 10px / 8ms ≈ 1250 px/s → 16ms lookahead ≈ 20px ahead expect(tip, isNotNull); expect(tip!.offset.dx, greaterThan(10)); }); test('StrokePredictor resets cleanly', () { final p = StrokePredictor(); p.observe(const Offset(0, 0), 0.4); p.reset(); expect(p.observe(const Offset(1, 1), 0.4), isNull); }); }