import 'dart:math' as math; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/graph/domain/graph_definition.dart'; import '../domain/graph_fixtures.dart'; import 'routing_fixtures.dart'; void main() { for (final width in [52.0, 100.0, 160.0]) { test( 'measured self-loop labels do not sit across route wires ($width)', () { final graph = selfLoopGraph(); final result = routeFor( graph, labels: fixedLabels(graphEdges(graph), width: width, height: 32), ); for (final label in result.labels) { for (final route in result.routes) { for (var i = 1; i < route.points.length; i++) { final a = route.points[i - 1], b = route.points[i]; final vertical = a.x == b.x && a.x > label.x && a.x < label.right && math.max(a.y, b.y) > label.y && math.min(a.y, b.y) < label.bottom; final horizontal = a.y == b.y && a.y > label.y && a.y < label.bottom && math.max(a.x, b.x) > label.x && math.min(a.x, b.x) < label.right; expect( vertical || horizontal, isFalse, reason: 'edge ${route.id} crosses label ${label.edgeId}', ); } } } }, ); } }