[a11y] add SemanticsValidationResult (#165935)
Add `SemanticsValidationResult` to semantics that maps onto `aria-invalid`. Fixes https://github.com/flutter/flutter/issues/162142
This commit is contained in:
@@ -685,6 +685,7 @@ Matcher matchesSemantics({
|
||||
int? platformViewId,
|
||||
int? maxValueLength,
|
||||
int? currentValueLength,
|
||||
SemanticsValidationResult validationResult = SemanticsValidationResult.none,
|
||||
// Flags //
|
||||
bool hasCheckedState = false,
|
||||
bool isChecked = false,
|
||||
@@ -768,6 +769,7 @@ Matcher matchesSemantics({
|
||||
customActions: customActions,
|
||||
maxValueLength: maxValueLength,
|
||||
currentValueLength: currentValueLength,
|
||||
validationResult: validationResult,
|
||||
// Flags
|
||||
hasCheckedState: hasCheckedState,
|
||||
isChecked: isChecked,
|
||||
@@ -879,6 +881,7 @@ Matcher containsSemantics({
|
||||
int? platformViewId,
|
||||
int? maxValueLength,
|
||||
int? currentValueLength,
|
||||
SemanticsValidationResult validationResult = SemanticsValidationResult.none,
|
||||
// Flags
|
||||
bool? hasCheckedState,
|
||||
bool? isChecked,
|
||||
@@ -962,6 +965,7 @@ Matcher containsSemantics({
|
||||
customActions: customActions,
|
||||
maxValueLength: maxValueLength,
|
||||
currentValueLength: currentValueLength,
|
||||
validationResult: validationResult,
|
||||
// Flags
|
||||
hasCheckedState: hasCheckedState,
|
||||
isChecked: isChecked,
|
||||
@@ -2398,6 +2402,7 @@ class _MatchesSemanticsData extends Matcher {
|
||||
required this.platformViewId,
|
||||
required this.maxValueLength,
|
||||
required this.currentValueLength,
|
||||
required this.validationResult,
|
||||
// Flags
|
||||
required bool? hasCheckedState,
|
||||
required bool? isChecked,
|
||||
@@ -2552,6 +2557,7 @@ class _MatchesSemanticsData extends Matcher {
|
||||
final int? maxValueLength;
|
||||
final int? currentValueLength;
|
||||
final List<Matcher>? children;
|
||||
final SemanticsValidationResult validationResult;
|
||||
|
||||
/// There are three possible states for these two maps:
|
||||
///
|
||||
@@ -2665,6 +2671,9 @@ class _MatchesSemanticsData extends Matcher {
|
||||
if (hintOverrides != null) {
|
||||
description.add(' with custom hints: $hintOverrides');
|
||||
}
|
||||
if (validationResult != SemanticsValidationResult.none) {
|
||||
description.add(' with validation result: $validationResult');
|
||||
}
|
||||
if (children != null) {
|
||||
description.add(' with children:\n ');
|
||||
final List<_MatchesSemanticsData> childMatches = children!.cast<_MatchesSemanticsData>();
|
||||
@@ -2801,6 +2810,9 @@ class _MatchesSemanticsData extends Matcher {
|
||||
if (maxValueLength != null && maxValueLength != data.maxValueLength) {
|
||||
return failWithDescription(matchState, 'maxValueLength was: ${data.maxValueLength}');
|
||||
}
|
||||
if (validationResult != data.validationResult) {
|
||||
return failWithDescription(matchState, 'validationResult was: ${data.validationResult}');
|
||||
}
|
||||
if (actions.isNotEmpty) {
|
||||
final List<SemanticsAction> unexpectedActions = <SemanticsAction>[];
|
||||
final List<SemanticsAction> missingActions = <SemanticsAction>[];
|
||||
|
||||
@@ -731,6 +731,7 @@ void main() {
|
||||
linkUrl: Uri(path: 'l'),
|
||||
role: ui.SemanticsRole.none,
|
||||
controlsNodes: null,
|
||||
validationResult: SemanticsValidationResult.none,
|
||||
);
|
||||
final _FakeSemanticsNode node = _FakeSemanticsNode(data);
|
||||
|
||||
@@ -1034,6 +1035,7 @@ void main() {
|
||||
linkUrl: Uri(path: 'l'),
|
||||
role: ui.SemanticsRole.none,
|
||||
controlsNodes: null,
|
||||
validationResult: SemanticsValidationResult.none,
|
||||
);
|
||||
final _FakeSemanticsNode node = _FakeSemanticsNode(data);
|
||||
|
||||
@@ -1133,6 +1135,7 @@ void main() {
|
||||
linkUrl: null,
|
||||
role: ui.SemanticsRole.none,
|
||||
controlsNodes: null,
|
||||
validationResult: SemanticsValidationResult.none,
|
||||
);
|
||||
final _FakeSemanticsNode node = _FakeSemanticsNode(data);
|
||||
|
||||
@@ -1239,6 +1242,7 @@ void main() {
|
||||
linkUrl: null,
|
||||
role: ui.SemanticsRole.none,
|
||||
controlsNodes: null,
|
||||
validationResult: SemanticsValidationResult.none,
|
||||
);
|
||||
final _FakeSemanticsNode emptyNode = _FakeSemanticsNode(emptyData);
|
||||
|
||||
@@ -1271,6 +1275,7 @@ void main() {
|
||||
linkUrl: Uri(path: 'l'),
|
||||
role: ui.SemanticsRole.none,
|
||||
controlsNodes: null,
|
||||
validationResult: SemanticsValidationResult.none,
|
||||
);
|
||||
final _FakeSemanticsNode fullNode = _FakeSemanticsNode(fullData);
|
||||
|
||||
@@ -1359,6 +1364,7 @@ void main() {
|
||||
linkUrl: null,
|
||||
role: ui.SemanticsRole.none,
|
||||
controlsNodes: null,
|
||||
validationResult: SemanticsValidationResult.none,
|
||||
);
|
||||
final _FakeSemanticsNode node = _FakeSemanticsNode(data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user