The Garage SDKs, in the open
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
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import "package:flutter/widgets.dart";
|
||||
import "package:flutter_test/flutter_test.dart";
|
||||
import "package:garage_ui/garage_ui.dart";
|
||||
|
||||
import "support/test_scheme.dart";
|
||||
|
||||
// Every control's label is control type: density.fontSize at typography.medium.
|
||||
// They sit next to each other in a popup or a form, so a menu row rendering a
|
||||
// pixel larger and a weight lighter than the button beside it is a bug you can
|
||||
// see. This pins them together.
|
||||
void main() {
|
||||
final theme = ThemeData(colorScheme: testScheme, density: const Density());
|
||||
|
||||
Future<TextStyle> resolve(WidgetTester t, Widget w) async {
|
||||
await t.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: GarageTheme(
|
||||
data: theme,
|
||||
child: Center(child: SizedBox(width: 320, child: w)),
|
||||
),
|
||||
));
|
||||
await t.pump();
|
||||
final f = find.text("Label").first;
|
||||
final widget = t.widget<Text>(f);
|
||||
final inherited = DefaultTextStyle.of(t.element(f)).style;
|
||||
return widget.style == null ? inherited : inherited.merge(widget.style);
|
||||
}
|
||||
|
||||
final controls = <String, Widget>{
|
||||
"Button": Button(
|
||||
style: const ButtonStyle.ghost(),
|
||||
onPressed: () {},
|
||||
child: const Text("Label")),
|
||||
"TextField": const TextField(placeholder: Text("Label")),
|
||||
"Select": Select<String>(
|
||||
value: "Label",
|
||||
itemBuilder: (c, v) => Text(v),
|
||||
popup: (c) => const SizedBox.shrink(),
|
||||
onChanged: (_) {}),
|
||||
"MenuButton": MenuPopup(
|
||||
children: [MenuButton(onPressed: (_) {}, child: const Text("Label"))]),
|
||||
};
|
||||
|
||||
for (final e in controls.entries) {
|
||||
testWidgets("${e.key} label is control type", (t) async {
|
||||
final s = await resolve(t, e.value);
|
||||
expect(s.fontSize, theme.density.fontSize,
|
||||
reason: "${e.key} should render at the control font");
|
||||
expect(s.fontWeight, theme.typography.medium.fontWeight,
|
||||
reason: "${e.key} should render at the control weight");
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets("a menu row matches the button beside it exactly", (t) async {
|
||||
final button = await resolve(t, controls["Button"]!);
|
||||
final menu = await resolve(t, controls["MenuButton"]!);
|
||||
expect(menu.fontSize, button.fontSize);
|
||||
expect(menu.fontWeight, button.fontWeight);
|
||||
expect(menu.color, button.color,
|
||||
reason: "menu items read foreground, same slot as every other control");
|
||||
});
|
||||
|
||||
testWidgets("a section label is heavier but the same size", (t) async {
|
||||
final label = await resolve(
|
||||
t, MenuPopup(children: const [MenuLabel(child: Text("Label"))]));
|
||||
expect(label.fontSize, theme.density.fontSize);
|
||||
expect(label.fontWeight, theme.typography.semiBold.fontWeight);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user