garage_auth, garage_entitlements, garage_iap and garage_ui, moved out of Garage-Services and Metro-Map-Maker into one public repo. MIT, one readme, docs under docs/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013F4NWNvYcdeSgqbWMT1VQ7
64 lines
2.3 KiB
Dart
64 lines
2.3 KiB
Dart
import "package:flutter/widgets.dart";
|
|
import "package:flutter_test/flutter_test.dart";
|
|
import "package:garage_ui/garage_ui.dart";
|
|
|
|
import "support/test_scheme.dart";
|
|
|
|
Widget _host(Density density, Widget child) => Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: GarageTheme(
|
|
data: ThemeData(colorScheme: testScheme, density: density),
|
|
child: Column(children: [child]),
|
|
),
|
|
);
|
|
|
|
void main() {
|
|
for (final density in const [Density(), Density.normal()]) {
|
|
testWidgets("${density.control.name}: Gap.md takes its extent from the theme",
|
|
(tester) async {
|
|
await tester.pumpWidget(_host(density, const Gap.md()));
|
|
expect(tester.getSize(find.byType(Gap)).height, density.gapMd);
|
|
});
|
|
}
|
|
|
|
testWidgets("a literal Gap still wins over the scale", (tester) async {
|
|
await tester.pumpWidget(_host(const Density(), const Gap(17)));
|
|
expect(tester.getSize(find.byType(Gap)).height, 17.0);
|
|
});
|
|
|
|
_outsideFlex();
|
|
|
|
testWidgets("the same Gap.md moves when the density does", (tester) async {
|
|
await tester.pumpWidget(_host(const Density(), const Gap.md()));
|
|
final compact = tester.getSize(find.byType(Gap)).height;
|
|
await tester.pumpWidget(_host(const Density.normal(), const Gap.md()));
|
|
final normal = tester.getSize(find.byType(Gap)).height;
|
|
expect(normal, greaterThan(compact));
|
|
});
|
|
}
|
|
|
|
// Regression: a Gap with no Flex parent used to throw at layout time and take
|
|
// the enclosing subtree with it. One inside an AnimatedSize destroyed a login
|
|
// card in the Garage hub, on a build that analyzed clean.
|
|
void _outsideFlex() {
|
|
testWidgets("a Gap outside a Flex lays out instead of throwing",
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: GarageTheme(
|
|
data: ThemeData(colorScheme: testScheme, density: const Density()),
|
|
child: const Center(child: SizedBox(width: 100, child: Gap.md())),
|
|
),
|
|
),
|
|
);
|
|
// it lays out - that is the whole point, it used to take the subtree down
|
|
expect(tester.getSize(find.byType(Gap)).height, const Density().gapMd);
|
|
|
|
// and it says so loudly in debug rather than failing silently
|
|
final reported = tester.takeException();
|
|
expect(reported, isA<FlutterError>());
|
|
expect("$reported", contains("no axis to size along"));
|
|
});
|
|
}
|