Unverified Commit 29e0e8b2 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

update Tristate checkbox semantics to consider indeterminate as "unchecked" (#18297)

parent bcaf026c
...@@ -339,7 +339,7 @@ abstract class RenderToggleable extends RenderConstrainedBox { ...@@ -339,7 +339,7 @@ abstract class RenderToggleable extends RenderConstrainedBox {
config.isEnabled = isInteractive; config.isEnabled = isInteractive;
if (isInteractive) if (isInteractive)
config.onTap = _handleTap; config.onTap = _handleTap;
config.isChecked = _value != false; config.isChecked = _value == true;
} }
@override @override
......
...@@ -202,6 +202,69 @@ void main() { ...@@ -202,6 +202,69 @@ void main() {
expect(checkBoxValue, null); expect(checkBoxValue, null);
}); });
testWidgets('has semantics for tristate', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(
new Material(
child: new Checkbox(
tristate: true,
value: null,
onChanged: (bool newValue) {},
),
),
);
expect(semantics.nodesWith(
flags: <SemanticsFlag>[
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled
],
actions: <SemanticsAction>[SemanticsAction.tap],
), hasLength(1));
await tester.pumpWidget(
new Material(
child: new Checkbox(
tristate: true,
value: true,
onChanged: (bool newValue) {},
),
),
);
expect(semantics.nodesWith(
flags: <SemanticsFlag>[
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isChecked,
],
actions: <SemanticsAction>[SemanticsAction.tap],
), hasLength(1));
await tester.pumpWidget(
new Material(
child: new Checkbox(
tristate: true,
value: false,
onChanged: (bool newValue) {},
),
),
);
expect(semantics.nodesWith(
flags: <SemanticsFlag>[
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
actions: <SemanticsAction>[SemanticsAction.tap],
), hasLength(1));
semantics.dispose();
});
testWidgets('has semantic events', (WidgetTester tester) async { testWidgets('has semantic events', (WidgetTester tester) async {
dynamic semanticEvent; dynamic semanticEvent;
bool checkboxValue = false; bool checkboxValue = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment