import "package:flutter_test/flutter_test.dart"; import "package:garage_ui/theme/theme_data.dart"; // The gap scale is derived from controlGap, and the claim that makes that the // right base is that two tokens which were authored by hand long before the // scale existed land exactly on steps of it. If someone retunes controlGap, // containerGap or containerPadding and that stops being true, the base unit // has drifted and the scale is lying about where it comes from. void main() { for (final density in const [Density(), Density.normal()]) { final name = density.control.name; test("$name: gapMd is containerGap, gapXl is containerPadding", () { expect(density.gapMd, density.containerGap); expect(density.gapXl, density.containerPadding); }); test("$name: the scale climbs and stays on whole pixels", () { final steps = [ density.gapXxs, density.gapXs, density.gapSm, density.gapMd, density.gapLg, density.gapXl, density.gapXxl, ]; for (var i = 1; i < steps.length; i++) { expect(steps[i], greaterThan(steps[i - 1]), reason: "step $i should be bigger than the one before it"); } for (final s in steps) { expect(s, s.roundToDouble(), reason: "$s is not a whole pixel"); } }); } test("compact lands on the sizes the style guide observed in real use", () { const d = Density(); expect([d.gapXxs, d.gapXs, d.gapSm, d.gapMd, d.gapLg, d.gapXl, d.gapXxl], [2.0, 4.0, 6.0, 8.0, 12.0, 16.0, 24.0]); }); }