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,56 @@
|
||||
import "package:flutter/semantics.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";
|
||||
|
||||
// with the semantics tree on, flutter web focuses a field by asking through
|
||||
// semantics rather than by a tap on the field. It used to go unanswered.
|
||||
|
||||
Widget _host(Widget child) => Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: GarageTheme(
|
||||
data: ThemeData(colorScheme: testScheme),
|
||||
child: Overlay(
|
||||
initialEntries: [
|
||||
OverlayEntry(
|
||||
builder: (_) => Center(child: SizedBox(width: 300, child: child)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
void main() {
|
||||
for (final action in [SemanticsAction.tap, SemanticsAction.focus]) {
|
||||
testWidgets("$action from semantics focuses the field", (tester) async {
|
||||
final handle = tester.ensureSemantics();
|
||||
final focus = FocusNode();
|
||||
addTearDown(focus.dispose);
|
||||
|
||||
await tester.pumpWidget(_host(TextField(focusNode: focus)));
|
||||
expect(focus.hasFocus, isFalse);
|
||||
|
||||
final node = tester.getSemantics(find.byType(EditableText));
|
||||
node.owner!.performAction(node.id, action);
|
||||
await tester.pump();
|
||||
|
||||
expect(focus.hasFocus, isTrue);
|
||||
handle.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets("a disabled field doesnt offer to be focused", (tester) async {
|
||||
final handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(_host(const TextField(enabled: false)));
|
||||
final node = tester.getSemantics(find.byType(EditableText));
|
||||
final data = node.getSemanticsData();
|
||||
expect(data.hasAction(SemanticsAction.tap), isFalse);
|
||||
expect(data.hasAction(SemanticsAction.focus), isFalse);
|
||||
handle.dispose();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user