UI fixes and league
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:sd_kovinar/utils/target_scoring.dart';
|
||||
import 'package:sd_kovinar/widgets/target_face.dart';
|
||||
|
||||
void main() {
|
||||
test('previews zoom in on the shots, keeping every one and ring 6 in view', () {
|
||||
expect(TargetFace.zoomFor(const []), 1); // nothing to zoom on
|
||||
|
||||
// All in the black: as far in as ring 6 allows
|
||||
final tight = [for (final a in [0.0, 2.0, 4.0]) TargetScoring.positionFor(9, a)];
|
||||
final z = TargetFace.zoomFor(tight);
|
||||
expect(z, greaterThan(2));
|
||||
expect(TargetScoring.size / 2 / z, greaterThanOrEqualTo(236.5)); // ring 6's outer edge still shows
|
||||
|
||||
// Every shot stays inside the zoomed view
|
||||
final spread = [for (int s = 4; s <= 10; s++) TargetScoring.positionFor(s, s.toDouble())];
|
||||
final zs = TargetFace.zoomFor(spread);
|
||||
for (final h in spread) {
|
||||
final d = (h - TargetScoring.center).distance + TargetScoring.bulletDiameter / 2;
|
||||
expect(d, lessThanOrEqualTo(TargetScoring.size / 2 / zs));
|
||||
}
|
||||
|
||||
// A miss in a corner: no zoom
|
||||
expect(TargetFace.zoomFor([TargetScoring.positionFor(0, pi / 4)]), 1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user