Rename SemanticsFlags to SemanticsFlag (#13994)

to align with `SemanticsAction` and other enum-like types.
This commit is contained in:
Michael Goderbauer 2018-01-09 10:31:23 -08:00 committed by GitHub
parent 4d37e03e1d
commit 24e3f70536
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 142 additions and 142 deletions

View file

@ -1 +1 @@
6a724f0d3e22d41246baf3447d7ba2c9ff886765
16e365e7224f3d295f065e85df11060f011a74c5

View file

@ -4,7 +4,7 @@
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'dart:ui' show Offset, Rect, SemanticsAction, SemanticsFlags,
import 'dart:ui' show Offset, Rect, SemanticsAction, SemanticsFlag,
TextDirection;
import 'package:flutter/foundation.dart';
@ -106,7 +106,7 @@ class SemanticsData extends Diagnosticable {
assert(increasedValue == '' || textDirection != null, 'A SemanticsData object with increasedValue "$increasedValue" had a null textDirection.'),
assert(rect != null);
/// A bit field of [SemanticsFlags] that apply to this node.
/// A bit field of [SemanticsFlag]s that apply to this node.
final int flags;
/// A bit field of [SemanticsAction]s that apply to this node.
@ -157,7 +157,7 @@ class SemanticsData extends Diagnosticable {
final Matrix4 transform;
/// Whether [flags] contains the given flag.
bool hasFlag(SemanticsFlags flag) => (flags & flag.index) != 0;
bool hasFlag(SemanticsFlag flag) => (flags & flag.index) != 0;
/// Whether [actions] contains the given action.
bool hasAction(SemanticsAction action) => (actions & action.index) != 0;
@ -178,7 +178,7 @@ class SemanticsData extends Diagnosticable {
properties.add(new IterableProperty<String>('actions', actionSummary, ifEmpty: null));
final List<String> flagSummary = <String>[];
for (SemanticsFlags flag in SemanticsFlags.values.values) {
for (SemanticsFlag flag in SemanticsFlag.values.values) {
if ((flags & flag.index) != 0)
flagSummary.add(describeEnum(flag));
}
@ -856,7 +856,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
int _flags = _kEmptyConfig._flags;
bool _hasFlag(SemanticsFlags flag) => _flags & flag.index != 0;
bool _hasFlag(SemanticsFlag flag) => _flags & flag.index != 0;
/// A textual description of this node.
///
@ -1089,14 +1089,14 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
}
final List<String> actions = _actions.keys.map((SemanticsAction action) => describeEnum(action)).toList()..sort();
properties.add(new IterableProperty<String>('actions', actions, ifEmpty: null));
if (_hasFlag(SemanticsFlags.hasEnabledState))
properties.add(new FlagProperty('isEnabled', value: _hasFlag(SemanticsFlags.isEnabled), ifFalse: 'disabled'));
if (_hasFlag(SemanticsFlags.hasCheckedState))
properties.add(new FlagProperty('isChecked', value: _hasFlag(SemanticsFlags.isChecked), ifTrue: 'checked', ifFalse: 'unchecked'));
properties.add(new FlagProperty('isSelected', value: _hasFlag(SemanticsFlags.isSelected), ifTrue: 'selected'));
properties.add(new FlagProperty('isFocused', value: _hasFlag(SemanticsFlags.isFocused), ifTrue: 'focused'));
properties.add(new FlagProperty('isButton', value: _hasFlag(SemanticsFlags.isButton), ifTrue: 'button'));
properties.add(new FlagProperty('isTextField', value: _hasFlag(SemanticsFlags.isTextField), ifTrue: 'textField'));
if (_hasFlag(SemanticsFlag.hasEnabledState))
properties.add(new FlagProperty('isEnabled', value: _hasFlag(SemanticsFlag.isEnabled), ifFalse: 'disabled'));
if (_hasFlag(SemanticsFlag.hasCheckedState))
properties.add(new FlagProperty('isChecked', value: _hasFlag(SemanticsFlag.isChecked), ifTrue: 'checked', ifFalse: 'unchecked'));
properties.add(new FlagProperty('isSelected', value: _hasFlag(SemanticsFlag.isSelected), ifTrue: 'selected'));
properties.add(new FlagProperty('isFocused', value: _hasFlag(SemanticsFlag.isFocused), ifTrue: 'focused'));
properties.add(new FlagProperty('isButton', value: _hasFlag(SemanticsFlag.isButton), ifTrue: 'button'));
properties.add(new FlagProperty('isTextField', value: _hasFlag(SemanticsFlag.isTextField), ifTrue: 'textField'));
properties.add(new StringProperty('label', _label, defaultValue: ''));
properties.add(new StringProperty('value', _value, defaultValue: ''));
properties.add(new StringProperty('increasedValue', _increasedValue, defaultValue: ''));
@ -1747,9 +1747,9 @@ class SemanticsConfiguration {
}
/// Whether the owning [RenderObject] is selected (true) or not (false).
bool get isSelected => _hasFlag(SemanticsFlags.isSelected);
bool get isSelected => _hasFlag(SemanticsFlag.isSelected);
set isSelected(bool value) {
_setFlag(SemanticsFlags.isSelected, value);
_setFlag(SemanticsFlag.isSelected, value);
}
/// Whether the owning [RenderObject] is currently enabled.
@ -1763,10 +1763,10 @@ class SemanticsConfiguration {
///
/// The getter will return null if the owning [RenderObject] doesn't support
/// the concept of being enabled/disabled.
bool get isEnabled => _hasFlag(SemanticsFlags.hasEnabledState) ? _hasFlag(SemanticsFlags.isEnabled) : null;
bool get isEnabled => _hasFlag(SemanticsFlag.hasEnabledState) ? _hasFlag(SemanticsFlag.isEnabled) : null;
set isEnabled(bool value) {
_setFlag(SemanticsFlags.hasEnabledState, true);
_setFlag(SemanticsFlags.isEnabled, value);
_setFlag(SemanticsFlag.hasEnabledState, true);
_setFlag(SemanticsFlag.isEnabled, value);
}
/// If this node has Boolean state that can be controlled by the user, whether
@ -1777,28 +1777,28 @@ class SemanticsConfiguration {
///
/// The getter returns null if the owning [RenderObject] does not have
/// checked/unchecked state.
bool get isChecked => _hasFlag(SemanticsFlags.hasCheckedState) ? _hasFlag(SemanticsFlags.isChecked) : null;
bool get isChecked => _hasFlag(SemanticsFlag.hasCheckedState) ? _hasFlag(SemanticsFlag.isChecked) : null;
set isChecked(bool value) {
_setFlag(SemanticsFlags.hasCheckedState, true);
_setFlag(SemanticsFlags.isChecked, value);
_setFlag(SemanticsFlag.hasCheckedState, true);
_setFlag(SemanticsFlag.isChecked, value);
}
/// Whether the owning [RenderObject] currently holds the user's focus.
bool get isFocused => _hasFlag(SemanticsFlags.isFocused);
bool get isFocused => _hasFlag(SemanticsFlag.isFocused);
set isFocused(bool value) {
_setFlag(SemanticsFlags.isFocused, value);
_setFlag(SemanticsFlag.isFocused, value);
}
/// Whether the owning [RenderObject] is a button (true) or not (false).
bool get isButton => _hasFlag(SemanticsFlags.isButton);
bool get isButton => _hasFlag(SemanticsFlag.isButton);
set isButton(bool value) {
_setFlag(SemanticsFlags.isButton, value);
_setFlag(SemanticsFlag.isButton, value);
}
/// Whether the owning [RenderObject] is a text field.
bool get isTextField => _hasFlag(SemanticsFlags.isTextField);
bool get isTextField => _hasFlag(SemanticsFlag.isTextField);
set isTextField(bool value) {
_setFlag(SemanticsFlags.isTextField, value);
_setFlag(SemanticsFlag.isTextField, value);
}
// TAGS
@ -1836,7 +1836,7 @@ class SemanticsConfiguration {
// INTERNAL FLAG MANAGEMENT
int _flags = 0;
void _setFlag(SemanticsFlags flag, bool value) {
void _setFlag(SemanticsFlag flag, bool value) {
if (value) {
_flags |= flag.index;
} else {
@ -1845,7 +1845,7 @@ class SemanticsConfiguration {
_hasBeenAnnotated = true;
}
bool _hasFlag(SemanticsFlags flag) => (_flags & flag.index) != 0;
bool _hasFlag(SemanticsFlag flag) => (_flags & flag.index) != 0;
// CONFIGURATION COMBINATION LOGIC

View file

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:math' as math;
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'dart:ui' as ui show window;
import 'package:flutter/foundation.dart';
@ -200,8 +200,8 @@ String _getMessage(SemanticsNode node) {
final List<String> annotations = <String>[];
bool wantsTap = false;
if (data.hasFlag(SemanticsFlags.hasCheckedState)) {
annotations.add(data.hasFlag(SemanticsFlags.isChecked) ? 'checked' : 'unchecked');
if (data.hasFlag(SemanticsFlag.hasCheckedState)) {
annotations.add(data.hasFlag(SemanticsFlag.isChecked) ? 'checked' : 'unchecked');
wantsTap = true;
}

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart';
import 'package:flutter/cupertino.dart';
@ -189,7 +189,7 @@ void main() {
new TestSemantics.rootChild(
actions: SemanticsAction.tap.index,
label: 'ABC',
flags: SemanticsFlags.isButton.index,
flags: SemanticsFlag.isButton.index,
)
],
),

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart';
@ -37,7 +37,7 @@ void main() {
label: 'ABC',
rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 36.0),
transform: new Matrix4.translationValues(356.0, 282.0, 0.0),
flags: SemanticsFlags.isButton.index,
flags: SemanticsFlag.isButton.index,
)
],
),
@ -71,7 +71,7 @@ void main() {
label: 'ABC',
rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 36.0),
transform: new Matrix4.translationValues(356.0, 282.0, 0.0),
flags: SemanticsFlags.isButton.index,
flags: SemanticsFlag.isButton.index,
)
]
),

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart';
@ -49,7 +49,7 @@ void main() {
label: 'Button',
textDirection: TextDirection.ltr,
actions: SemanticsAction.tap.index,
flags: SemanticsFlags.isButton.index,
flags: SemanticsFlag.isButton.index,
),
],
),

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
@ -101,11 +101,11 @@ void main() {
id: 1,
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: null,
flags: <SemanticsFlags>[
SemanticsFlags.hasCheckedState,
SemanticsFlags.isChecked,
SemanticsFlags.hasEnabledState,
SemanticsFlags.isEnabled
flags: <SemanticsFlag>[
SemanticsFlag.hasCheckedState,
SemanticsFlag.isChecked,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled
],
actions: SemanticsAction.tap.index,
label: 'aaa\nAAA',
@ -114,11 +114,11 @@ void main() {
id: 4,
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: new Matrix4.translationValues(0.0, 56.0, 0.0),
flags: <SemanticsFlags>[
SemanticsFlags.hasCheckedState,
SemanticsFlags.isChecked,
SemanticsFlags.hasEnabledState,
SemanticsFlags.isEnabled
flags: <SemanticsFlag>[
SemanticsFlag.hasCheckedState,
SemanticsFlag.isChecked,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled
],
actions: SemanticsAction.tap.index,
label: 'bbb\nBBB',
@ -127,10 +127,10 @@ void main() {
id: 7,
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: new Matrix4.translationValues(0.0, 112.0, 0.0),
flags: <SemanticsFlags>[
SemanticsFlags.hasCheckedState,
SemanticsFlags.hasEnabledState,
SemanticsFlags.isEnabled
flags: <SemanticsFlag>[
SemanticsFlag.hasCheckedState,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled
],
actions: SemanticsAction.tap.index,
label: 'CCC\nccc',

View file

@ -394,7 +394,7 @@ void _tests() {
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.isSelected],
flags: <SemanticsFlag>[SemanticsFlag.isSelected],
actions: <SemanticsAction>[SemanticsAction.tap],
label: r'Fri, Jan 15',
textDirection: TextDirection.ltr,
@ -479,7 +479,7 @@ void _tests() {
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.isSelected],
flags: <SemanticsFlag>[SemanticsFlag.isSelected],
actions: <SemanticsAction>[SemanticsAction.tap],
label: r'15, Friday, January 15, 2016',
textDirection: TextDirection.ltr,
@ -573,25 +573,25 @@ void _tests() {
],
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.isButton],
flags: <SemanticsFlag>[SemanticsFlag.isButton],
actions: <SemanticsAction>[SemanticsAction.tap],
label: r'Previous month December 2015',
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.isButton],
flags: <SemanticsFlag>[SemanticsFlag.isButton],
actions: <SemanticsAction>[SemanticsAction.tap],
label: r'Next month February 2016',
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.isButton],
flags: <SemanticsFlag>[SemanticsFlag.isButton],
actions: <SemanticsAction>[SemanticsAction.tap],
label: r'CANCEL',
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.isButton],
flags: <SemanticsFlag>[SemanticsFlag.isButton],
actions: <SemanticsAction>[SemanticsAction.tap],
label: r'OK',
textDirection: TextDirection.ltr,

View file

@ -292,7 +292,7 @@ void main() {
new TestSemantics.rootChild(
rect: new Rect.fromLTRB(0.0, 0.0, 48.0, 48.0),
actions: <SemanticsAction>[SemanticsAction.tap],
flags: <SemanticsFlags>[SemanticsFlags.isButton],
flags: <SemanticsFlag>[SemanticsFlag.isButton],
label: 'link',
)
]

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@ -361,23 +361,23 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
label: 'one',
flags: <SemanticsFlags>[
SemanticsFlags.hasEnabledState,
SemanticsFlags.isEnabled,
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
),
new TestSemantics.rootChild(
label: 'two',
flags: <SemanticsFlags>[
SemanticsFlags.isSelected,
SemanticsFlags.hasEnabledState,
SemanticsFlags.isEnabled,
flags: <SemanticsFlag>[
SemanticsFlag.isSelected,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
),
new TestSemantics.rootChild(
label: 'three',
flags: <SemanticsFlags>[
SemanticsFlags.hasEnabledState,
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
],
),
]

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags, SemanticsAction;
import 'dart:ui' show SemanticsFlag, SemanticsAction;
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
@ -1214,7 +1214,7 @@ void main() {
new TestSemantics(
id: 2,
actions: SemanticsAction.tap.index,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
label: 'TAB #0\nTab 1 of 2',
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight),
transform: new Matrix4.translationValues(0.0, 276.0, 0.0),
@ -1464,7 +1464,7 @@ void main() {
new TestSemantics(
id: 24,
actions: SemanticsAction.tap.index,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
label: 'Semantics override 0\nTab 1 of 2',
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight),
transform: new Matrix4.translationValues(0.0, 276.0, 0.0),

View file

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@ -1666,7 +1666,7 @@ void main() {
),
);
expect(semantics, includesNodeWith(flags: <SemanticsFlags>[SemanticsFlags.isTextField]));
expect(semantics, includesNodeWith(flags: <SemanticsFlag>[SemanticsFlag.isTextField]));
});
testWidgets('Caret works when maxLines is null', (WidgetTester tester) async {

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@ -69,7 +69,7 @@ Future<Null> pumpTestWidget(WidgetTester tester, {
void main() {
testWidgets('UserAccountsDrawerHeader test', (WidgetTester tester) async {
await pumpTestWidget(tester);
expect(find.text('A'), findsOneWidget);
expect(find.text('B'), findsOneWidget);
expect(find.text('C'), findsOneWidget);
@ -351,7 +351,7 @@ void main() {
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.isButton],
flags: <SemanticsFlag>[SemanticsFlag.isButton],
actions: <SemanticsAction>[SemanticsAction.tap],
label: r'Show accounts',
textDirection: TextDirection.ltr,

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
@ -277,13 +277,13 @@ void main() {
),
);
expect(semantics, includesNodeWith(flags: <SemanticsFlags>[SemanticsFlags.isTextField]));
expect(semantics, includesNodeWith(flags: <SemanticsFlag>[SemanticsFlag.isTextField]));
await tester.tap(find.byType(EditableText));
await tester.idle();
await tester.pump();
expect(semantics, includesNodeWith(flags: <SemanticsFlags>[SemanticsFlags.isTextField, SemanticsFlags.isFocused]));
expect(semantics, includesNodeWith(flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isFocused]));
});
testWidgets('EditableText includes text as value in semantics', (WidgetTester tester) async {
@ -309,7 +309,7 @@ void main() {
);
expect(semantics, includesNodeWith(
flags: <SemanticsFlags>[SemanticsFlags.isTextField],
flags: <SemanticsFlag>[SemanticsFlag.isTextField],
value: value1,
));
@ -319,7 +319,7 @@ void main() {
await tester.pump();
expect(semantics, includesNodeWith(
flags: <SemanticsFlags>[SemanticsFlags.isTextField],
flags: <SemanticsFlag>[SemanticsFlag.isTextField],
value: value2,
));
});

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@ -233,17 +233,17 @@ void main() {
children: <TestSemantics>[
new TestSemantics(
id: 6,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
label: 'node 1',
),
new TestSemantics(
id: 7,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
label: 'node 2',
),
new TestSemantics(
id: 8,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
label: 'node 3',
),
],

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@ -36,7 +36,7 @@ void main() {
id: 1,
label: 'test1',
rect: TestSemantics.fullScreen,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
)
]
)));
@ -78,7 +78,7 @@ void main() {
id: 1,
label: 'child1',
rect: TestSemantics.fullScreen,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
)
],
)));
@ -124,13 +124,13 @@ void main() {
id: 2,
label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
new TestSemantics(
id: 3,
label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
],
),
@ -174,7 +174,7 @@ void main() {
id: 1,
label: 'child1',
rect: TestSemantics.fullScreen,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
)
],
)));
@ -220,13 +220,13 @@ void main() {
id: 4,
label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
new TestSemantics(
id: 3,
label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
],
),

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@ -60,13 +60,13 @@ void main() {
id: 2,
label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
new TestSemantics(
id: 3,
label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
],
),
@ -110,7 +110,7 @@ void main() {
id: 1,
label: 'child1',
rect: TestSemantics.fullScreen,
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
)
],
)));
@ -156,13 +156,13 @@ void main() {
id: 4,
label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
new TestSemantics(
id: 3,
label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlags.isSelected.index,
flags: SemanticsFlag.isSelected.index,
),
],
),

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@ -37,7 +37,7 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: 'test',
rect: TestSemantics.fullScreen,
)
@ -62,7 +62,7 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
rect: TestSemantics.fullScreen,
),
]
@ -116,7 +116,7 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: 'test',
rect: TestSemantics.fullScreen,
)

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@ -64,12 +64,12 @@ void main() {
children: <TestSemantics>[
new TestSemantics(
id: 3,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
rect: TestSemantics.fullScreen,
),
new TestSemantics(
id: 4,
flags: SemanticsFlags.hasCheckedState.index,
flags: SemanticsFlag.hasCheckedState.index,
rect: TestSemantics.fullScreen,
),
]
@ -120,7 +120,7 @@ void main() {
new TestSemantics.rootChild(
id: 2,
label: 'L2',
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
rect: TestSemantics.fullScreen,
),
],
@ -160,7 +160,7 @@ void main() {
new TestSemantics.rootChild(
id: 2,
label: 'L2',
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
rect: TestSemantics.fullScreen,
),
],

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@ -56,14 +56,14 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label,
rect: TestSemantics.fullScreen,
),
// IDs 2 and 3 are used up by the nodes that get merged in
new TestSemantics.rootChild(
id: 4,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label,
rect: TestSemantics.fullScreen,
),
@ -112,14 +112,14 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label,
rect: TestSemantics.fullScreen,
),
// IDs 2 and 3 are used up by the nodes that get merged in
new TestSemantics.rootChild(
id: 4,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label,
rect: TestSemantics.fullScreen,
),

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
@ -42,7 +42,7 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: 'label',
textDirection: TextDirection.ltr,
rect: TestSemantics.fullScreen,
@ -80,7 +80,7 @@ void main() {
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
flags: SemanticsFlags.hasCheckedState.index | SemanticsFlags.isChecked.index,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: 'label',
textDirection: TextDirection.ltr,
rect: TestSemantics.fullScreen,

View file

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
@ -46,7 +46,7 @@ class TestSemantics {
this.transform,
this.children: const <TestSemantics>[],
Iterable<SemanticsTag> tags,
}) : assert(flags is int || flags is List<SemanticsFlags>),
}) : assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
assert(value != null),
@ -71,7 +71,7 @@ class TestSemantics {
this.children: const <TestSemantics>[],
Iterable<SemanticsTag> tags,
}) : id = 0,
assert(flags is int || flags is List<SemanticsFlags>),
assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
assert(increasedValue != null),
@ -105,7 +105,7 @@ class TestSemantics {
Matrix4 transform,
this.children: const <TestSemantics>[],
Iterable<SemanticsTag> tags,
}) : assert(flags is int || flags is List<SemanticsFlags>),
}) : assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
assert(value != null),
@ -122,12 +122,12 @@ class TestSemantics {
/// they are created.
final int id;
/// The [SemanticsFlags] set on this node.
/// The [SemanticsFlag]s set on this node.
///
/// There are two ways to specify this property: as an `int` that encodes the
/// flags as a bit field, or as a `List<SemanticsFlags>` that are _on_.
/// flags as a bit field, or as a `List<SemanticsFlag>` that are _on_.
///
/// Using `List<SemanticsFlags>` is recommended due to better readability.
/// Using `List<SemanticsFlag>` is recommended due to better readability.
final dynamic flags;
/// The [SemanticsAction]s set on this node.
@ -223,7 +223,7 @@ class TestSemantics {
final int flagsBitmask = flags is int
? flags
: flags.fold<int>(0, (int bitmask, SemanticsFlags flag) => bitmask | flag.index);
: flags.fold<int>(0, (int bitmask, SemanticsFlag flag) => bitmask | flag.index);
if (flagsBitmask != nodeData.flags)
return fail('expected node id $id to have flags $flags but found flags ${nodeData.flags}.');
@ -277,8 +277,8 @@ class TestSemantics {
buf.writeln('${indent}new $runtimeType(');
if (id != null)
buf.writeln('$indent id: $id,');
if (flags is int && flags != 0 || flags is List<SemanticsFlags> && flags.isNotEmpty)
buf.writeln('$indent flags: ${SemanticsTester._flagsToSemanticsFlagsExpression(flags)},');
if (flags is int && flags != 0 || flags is List<SemanticsFlag> && flags.isNotEmpty)
buf.writeln('$indent flags: ${SemanticsTester._flagsToSemanticsFlagExpression(flags)},');
if (actions is int && actions != 0 || actions is List<SemanticsAction> && actions.isNotEmpty)
buf.writeln('$indent actions: ${SemanticsTester._actionsToSemanticsActionExpression(actions)},');
if (label != null && label != '')
@ -347,7 +347,7 @@ class SemanticsTester {
String value,
TextDirection textDirection,
List<SemanticsAction> actions,
List<SemanticsFlags> flags,
List<SemanticsFlag> flags,
SemanticsNode ancestor,
}) {
bool checkNode(SemanticsNode node) {
@ -364,7 +364,7 @@ class SemanticsTester {
return false;
}
if (flags != null) {
final int expectedFlags = flags.fold(0, (int value, SemanticsFlags flag) => value | flag.index);
final int expectedFlags = flags.fold(0, (int value, SemanticsFlag flag) => value | flag.index);
final int actualFlags = node.getSemanticsData().flags;
if (expectedFlags != actualFlags)
return false;
@ -440,15 +440,15 @@ class SemanticsTester {
return _generateSemanticsTestForNode(node, 0);
}
static String _flagsToSemanticsFlagsExpression(dynamic flags) {
Iterable<SemanticsFlags> list;
static String _flagsToSemanticsFlagExpression(dynamic flags) {
Iterable<SemanticsFlag> list;
if (flags is int) {
list = SemanticsFlags.values.values
.where((SemanticsFlags flag) => (flag.index & flags) != 0);
list = SemanticsFlag.values.values
.where((SemanticsFlag flag) => (flag.index & flags) != 0);
} else {
list = flags;
}
return '<SemanticsFlags>[${list.join(', ')}]';
return '<SemanticsFlag>[${list.join(', ')}]';
}
static String _actionsToSemanticsActionExpression(dynamic actions) {
@ -470,7 +470,7 @@ class SemanticsTester {
final SemanticsData nodeData = node.getSemanticsData();
buf.writeln('new TestSemantics(');
if (nodeData.flags != 0)
buf.writeln(' flags: ${_flagsToSemanticsFlagsExpression(nodeData.flags)},');
buf.writeln(' flags: ${_flagsToSemanticsFlagExpression(nodeData.flags)},');
if (nodeData.actions != 0)
buf.writeln(' actions: ${_actionsToSemanticsActionExpression(nodeData.actions)},');
if (node.label != null && node.label.isNotEmpty)
@ -555,7 +555,7 @@ class _IncludesNodeWith extends Matcher {
final String value;
final TextDirection textDirection;
final List<SemanticsAction> actions;
final List<SemanticsFlags> flags;
final List<SemanticsFlag> flags;
@override
bool matches(covariant SemanticsTester item, Map<dynamic, dynamic> matchState) {
@ -603,7 +603,7 @@ Matcher includesNodeWith({
String value,
TextDirection textDirection,
List<SemanticsAction> actions,
List<SemanticsFlags> flags,
List<SemanticsFlag> flags,
}) {
return new _IncludesNodeWith(
label: label,

View file

@ -4,7 +4,7 @@
import 'dart:async';
import 'dart:io';
import 'dart:ui' show SemanticsFlags;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
@ -113,7 +113,7 @@ void _tests() {
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlags>[SemanticsFlags.hasCheckedState, SemanticsFlags.isChecked, SemanticsFlags.isSelected],
flags: <SemanticsFlag>[SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.decrease],
label: r'Interactive text',
value: r'test-value',