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
81 lines
2.4 KiB
Dart
81 lines
2.4 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";
|
|
|
|
// ChromeBar's height was a hardcoded 30 that didnt move with the tier. At
|
|
// normal that left a 27px control 1.5px of margin, and at product the bar came
|
|
// out SHORTER than the 33px buttons meant to sit in it - a header its own
|
|
// contents didnt fit. It takes the density's token now.
|
|
|
|
Future<double> _barHeight(WidgetTester tester, Density density) async {
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: GarageTheme(
|
|
data: ThemeData(colorScheme: testScheme, density: density),
|
|
child: const Align(
|
|
alignment: Alignment.topCenter,
|
|
child: ChromeBar(child: SizedBox.shrink()),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
return tester.getSize(find.byType(ChromeBar)).height;
|
|
}
|
|
|
|
void main() {
|
|
for (final density in const [
|
|
Density(),
|
|
Density.normal(),
|
|
Density.product(),
|
|
]) {
|
|
final label = "${density.controlHeight.toInt()}px controls";
|
|
|
|
test("a chrome bar clears its own controls ($label)", () {
|
|
// one controlGap above and one below - the same air a button gets from
|
|
// the button beside it
|
|
expect(
|
|
density.chromeBarHeight,
|
|
density.controlHeight + density.controlGap * 2,
|
|
);
|
|
|
|
// the thing that was actually broken: the bar has to be able to hold
|
|
// the control, not merely be near its size
|
|
expect(
|
|
density.chromeBarHeight,
|
|
greaterThan(density.controlHeight),
|
|
reason: "a control wouldnt fit inside its own chrome",
|
|
);
|
|
});
|
|
|
|
testWidgets("ChromeBar takes that height with none given ($label)", (
|
|
tester,
|
|
) async {
|
|
expect(await _barHeight(tester, density), density.chromeBarHeight);
|
|
});
|
|
}
|
|
|
|
testWidgets("an explicit height still wins", (tester) async {
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: GarageTheme(
|
|
data: ThemeData(
|
|
colorScheme: testScheme,
|
|
density: const Density.product(),
|
|
),
|
|
child: const Align(
|
|
alignment: Alignment.topCenter,
|
|
child: ChromeBar(height: 52, child: SizedBox.shrink()),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
expect(tester.getSize(find.byType(ChromeBar)).height, 52);
|
|
});
|
|
}
|