Add missing focusable testing info (#13013)

This adds a couple of instances of semantic node isFocusable info that were missing that the framework testing depends upon.
This commit is contained in:
Greg Spencer 2019-10-09 09:00:24 -07:00 committed by GitHub
parent 0e42a290d7
commit 77252d2371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -34,6 +34,9 @@ class SemanticsAction {
static const int _kDismissIndex = 1 << 18;
static const int _kMoveCursorForwardByWordIndex = 1 << 19;
static const int _kMoveCursorBackwardByWordIndex = 1 << 20;
// READ THIS: if you add an action here, you MUST update the
// numSemanticsActions value in testing/dart/semantics_test.dart, or tests
// will fail.
/// The numerical value for this action.
///
@ -292,6 +295,8 @@ class SemanticsFlag {
static const int _kIsReadOnlyIndex = 1 << 20;
static const int _kIsFocusableIndex = 1 << 21;
static const int _kIsLinkIndex = 1 << 22;
// READ THIS: if you add a flag here, you MUST update the numSemanticsFlags
// value in testing/dart/semantics_test.dart, or tests will fail.
const SemanticsFlag._(this.index);
@ -536,6 +541,7 @@ class SemanticsFlag {
_kHasImplicitScrollingIndex: hasImplicitScrolling,
_kIsMultilineIndex: isMultiline,
_kIsReadOnlyIndex: isReadOnly,
_kIsFocusableIndex: isFocusable,
_kIsLinkIndex: isLink,
};
@ -584,6 +590,8 @@ class SemanticsFlag {
return 'SemanticsFlag.isMultiline';
case _kIsReadOnlyIndex:
return 'SemanticsFlag.isReadOnly';
case _kIsFocusableIndex:
return 'SemanticsFlag.isFocusable';
case _kIsLinkIndex:
return 'SemanticsFlag.isLink';
}

View File

@ -0,0 +1,31 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
/// Verifies Semantics flags and actions.
void main() {
// This must match the number of flags in lib/ui/semantics.dart
const int numSemanticsFlags = 23;
test('SemanticsFlag.values refers to all flags.', () async {
expect(SemanticsFlag.values.length, equals(numSemanticsFlags));
for (int index = 0; index < numSemanticsFlags; ++index) {
final int flag = 1 << index;
expect(SemanticsFlag.values[flag], isNotNull);
expect(SemanticsFlag.values[flag].toString(), startsWith('SemanticsFlag.'));
}
});
// This must match the number of actions in lib/ui/semantics.dart
const int numSemanticsActions = 21;
test('SemanticsAction.values refers to all actions.', () async {
expect(SemanticsAction.values.length, equals(numSemanticsActions));
for (int index = 0; index < numSemanticsActions; ++index) {
final int flag = 1 << index;
expect(SemanticsAction.values[flag], isNotNull);
expect(SemanticsAction.values[flag].toString(), startsWith('SemanticsAction.'));
}
});
}