Revert "Adds semantics tooltip support (#27893)" (flutter/engine#28207)

This reverts commit 366e66802a35abf55bcb649b9bf58921b174b59a.
This commit is contained in:
Zachary Anderson 2021-08-19 14:40:34 -07:00 committed by GitHub
parent 655aa2701b
commit c4fb8a6051
19 changed files with 49 additions and 303 deletions

View File

@ -800,9 +800,6 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
/// and `decreasedValue` respectively. Their contents must not be changed during
/// the semantics update.
///
/// The `tooltip` is a string that describe additional information when user
/// hover or long press on the backing widget of this semantics node.
///
/// The fields `textSelectionBase` and `textSelectionExtent` describe the
/// currently selected text within `value`. A value of -1 indicates no
/// current text selection base or extent.
@ -860,16 +857,15 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
required double thickness,
required Rect rect,
required String label,
required List<StringAttribute> labelAttributes,
List<StringAttribute>? labelAttributes,
required String value,
required List<StringAttribute> valueAttributes,
List<StringAttribute>? valueAttributes,
required String increasedValue,
required List<StringAttribute> increasedValueAttributes,
List<StringAttribute>? increasedValueAttributes,
required String decreasedValue,
required List<StringAttribute> decreasedValueAttributes,
List<StringAttribute>? decreasedValueAttributes,
required String hint,
required List<StringAttribute> hintAttributes,
String? tooltip,
List<StringAttribute>? hintAttributes,
TextDirection? textDirection,
required Float64List transform,
required Int32List childrenInTraversalOrder,
@ -911,7 +907,6 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
decreasedValueAttributes,
hint,
hintAttributes,
tooltip,
textDirection != null ? textDirection.index + 1 : 0,
transform,
childrenInTraversalOrder,
@ -940,16 +935,15 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
double elevation,
double thickness,
String label,
List<StringAttribute> labelAttributes,
List<StringAttribute>? labelAttributes,
String value,
List<StringAttribute> valueAttributes,
List<StringAttribute>? valueAttributes,
String increasedValue,
List<StringAttribute> increasedValueAttributes,
List<StringAttribute>? increasedValueAttributes,
String decreasedValue,
List<StringAttribute> decreasedValueAttributes,
List<StringAttribute>? decreasedValueAttributes,
String hint,
List<StringAttribute> hintAttributes,
String? tooltip,
List<StringAttribute>? hintAttributes,
int textDirection,
Float64List transform,
Int32List childrenInTraversalOrder,

View File

@ -131,7 +131,6 @@ struct SemanticsNode {
StringAttributes increasedValueAttributes;
std::string decreasedValue;
StringAttributes decreasedValueAttributes;
std::string tooltip;
int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr
SkRect rect = SkRect::MakeEmpty(); // Local space, relative to parent.

View File

@ -76,7 +76,6 @@ void SemanticsUpdateBuilder::updateNode(
std::vector<NativeStringAttribute*> decreasedValueAttributes,
std::string hint,
std::vector<NativeStringAttribute*> hintAttributes,
std::string tooltip,
int textDirection,
const tonic::Float64List& transform,
const tonic::Int32List& childrenInTraversalOrder,
@ -115,7 +114,6 @@ void SemanticsUpdateBuilder::updateNode(
pushStringAttributes(node.decreasedValueAttributes, decreasedValueAttributes);
node.hint = hint;
pushStringAttributes(node.hintAttributes, hintAttributes);
node.tooltip = tooltip;
node.textDirection = textDirection;
SkScalar scalarTransform[16];
for (int i = 0; i < 16; ++i) {

View File

@ -55,7 +55,6 @@ class SemanticsUpdateBuilder
std::vector<NativeStringAttribute*> decreasedValueAttributes,
std::string hint,
std::vector<NativeStringAttribute*> hintAttributes,
std::string tooltip,
int textDirection,
const tonic::Float64List& transform,
const tonic::Int32List& childrenInTraversalOrder,

View File

@ -78,16 +78,15 @@ class SemanticsNodeUpdate {
required this.scrollExtentMin,
required this.rect,
required this.label,
required this.labelAttributes,
this.labelAttributes,
required this.hint,
required this.hintAttributes,
this.hintAttributes,
required this.value,
required this.valueAttributes,
this.valueAttributes,
required this.increasedValue,
required this.increasedValueAttributes,
this.increasedValueAttributes,
required this.decreasedValue,
required this.decreasedValueAttributes,
this.tooltip,
this.decreasedValueAttributes,
this.textDirection,
required this.transform,
required this.elevation,
@ -143,34 +142,31 @@ class SemanticsNodeUpdate {
final String label;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final List<ui.StringAttribute> labelAttributes;
final List<ui.StringAttribute>? labelAttributes;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final String hint;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final List<ui.StringAttribute> hintAttributes;
final List<ui.StringAttribute>? hintAttributes;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final String value;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final List<ui.StringAttribute> valueAttributes;
final List<ui.StringAttribute>? valueAttributes;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final String increasedValue;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final List<ui.StringAttribute> increasedValueAttributes;
final List<ui.StringAttribute>? increasedValueAttributes;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final String decreasedValue;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final List<ui.StringAttribute> decreasedValueAttributes;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final String? tooltip;
final List<ui.StringAttribute>? decreasedValueAttributes;
/// See [ui.SemanticsUpdateBuilder.updateNode].
final ui.TextDirection? textDirection;

View File

@ -349,16 +349,15 @@ class SemanticsUpdateBuilder {
required double thickness,
required Rect rect,
required String label,
required List<StringAttribute> labelAttributes,
List<StringAttribute>? labelAttributes,
required String value,
required List<StringAttribute> valueAttributes,
List<StringAttribute>? valueAttributes,
required String increasedValue,
required List<StringAttribute> increasedValueAttributes,
List<StringAttribute>? increasedValueAttributes,
required String decreasedValue,
required List<StringAttribute> decreasedValueAttributes,
List<StringAttribute>? decreasedValueAttributes,
required String hint,
required List<StringAttribute> hintAttributes,
String? tooltip,
List<StringAttribute>? hintAttributes,
TextDirection? textDirection,
required Float64List transform,
required Int32List childrenInTraversalOrder,
@ -391,7 +390,6 @@ class SemanticsUpdateBuilder {
decreasedValueAttributes: decreasedValueAttributes,
hint: hint,
hintAttributes: hintAttributes,
tooltip: tooltip,
textDirection: textDirection,
transform: engine.toMatrix32(transform),
elevation: elevation,

View File

@ -1488,16 +1488,10 @@ void updateNode(
double thickness = 0.0,
ui.Rect rect = ui.Rect.zero,
String label = '',
List<ui.StringAttribute> labelAttributes = const <ui.StringAttribute>[],
String hint = '',
List<ui.StringAttribute> hintAttributes = const <ui.StringAttribute>[],
String value = '',
List<ui.StringAttribute> valueAttributes = const <ui.StringAttribute>[],
String increasedValue = '',
List<ui.StringAttribute> increasedValueAttributes = const <ui.StringAttribute>[],
String decreasedValue = '',
List<ui.StringAttribute> decreasedValueAttributes = const <ui.StringAttribute>[],
String tooltip = '',
ui.TextDirection textDirection = ui.TextDirection.ltr,
Float64List? transform,
Int32List? childrenInTraversalOrder,
@ -1526,16 +1520,10 @@ void updateNode(
thickness: thickness,
rect: rect,
label: label,
labelAttributes: labelAttributes,
hint: hint,
hintAttributes: hintAttributes,
value: value,
valueAttributes: valueAttributes,
increasedValue: increasedValue,
increasedValueAttributes: increasedValueAttributes,
decreasedValue: decreasedValue,
decreasedValueAttributes: decreasedValueAttributes,
tooltip: tooltip,
textDirection: textDirection,
transform: transform,
childrenInTraversalOrder: childrenInTraversalOrder,

View File

@ -115,16 +115,10 @@ class SemanticsTester {
double? thickness,
ui.Rect? rect,
String? label,
List<ui.StringAttribute>? labelAttributes,
String? hint,
List<ui.StringAttribute>? hintAttributes,
String? value,
List<ui.StringAttribute>? valueAttributes,
String? increasedValue,
List<ui.StringAttribute>? increasedValueAttributes,
String? decreasedValue,
List<ui.StringAttribute>? decreasedValueAttributes,
String? tooltip,
ui.TextDirection? textDirection,
Float64List? transform,
Int32List? additionalActions,
@ -312,16 +306,10 @@ class SemanticsTester {
scrollExtentMin: scrollExtentMin ?? 0,
rect: effectiveRect,
label: label ?? '',
labelAttributes: labelAttributes ?? const <ui.StringAttribute>[],
hint: hint ?? '',
hintAttributes: hintAttributes ?? const <ui.StringAttribute>[],
value: value ?? '',
valueAttributes: valueAttributes ?? const <ui.StringAttribute>[],
increasedValue: increasedValue ?? '',
increasedValueAttributes: increasedValueAttributes ?? const <ui.StringAttribute>[],
decreasedValue: decreasedValue ?? '',
decreasedValueAttributes: decreasedValueAttributes ?? const <ui.StringAttribute>[],
tooltip: tooltip ?? '',
transform: transform != null ? toMatrix32(transform) : Matrix4.identity().storage,
elevation: elevation ?? 0,
thickness: thickness ?? 0,

View File

@ -266,15 +266,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
/** The user has opened a tooltip. */
@Override
public void onTooltip(@NonNull String message) {
// Native Android tooltip is no longer announced when it pops up after API 28 and is
// handled by
// AccessibilityNodeInfo.setTooltipText instead.
//
// To reproduce native behavior, see
// https://developer.android.com/guide/topics/ui/tooltips.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return;
}
AccessibilityEvent e =
obtainAccessibilityEvent(ROOT_NODE_ID, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
e.getText().add(message);
@ -829,31 +820,15 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
result.setLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
}
// Scopes routes are not focusable, only need to set the content
// for non-scopes-routes semantics nodes.
if (semanticsNode.hasFlag(Flag.IS_TEXT_FIELD)) {
result.setText(semanticsNode.getValueLabelHint());
} else if (!semanticsNode.hasFlag(Flag.SCOPES_ROUTE)) {
CharSequence content = semanticsNode.getValueLabelHint();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
if (semanticsNode.tooltip != null) {
// For backward compatibility with Flutter SDK before Android API
// level 28, the tooltip is appended at the end of content description.
content = content != null ? content : "";
content = content + "\n" + semanticsNode.tooltip;
}
}
if (content != null) {
result.setContentDescription(content);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (semanticsNode.tooltip != null) {
result.setTooltipText(semanticsNode.tooltip);
}
}
boolean hasCheckedState = semanticsNode.hasFlag(Flag.HAS_CHECKED_STATE);
boolean hasToggledState = semanticsNode.hasFlag(Flag.HAS_TOGGLED_STATE);
if (BuildConfig.DEBUG && (hasCheckedState && hasToggledState)) {
@ -2213,12 +2188,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
private String hint;
private List<StringAttribute> hintAttributes;
// The textual description of the backing widget's tooltip.
//
// The tooltip is attached through AccessibilityNodInfo.setTooltipText if
// API level >= 28; otherwise, this is attached to the end of content description.
@Nullable private String tooltip;
// The id of the sibling node that is before this node in traversal
// order.
//
@ -2421,9 +2390,6 @@ public class AccessibilityBridge extends AccessibilityNodeProvider {
hintAttributes = getStringAttributesFromBuffer(buffer, stringAttributeArgs);
stringIndex = buffer.getInt();
tooltip = stringIndex == -1 ? null : strings[stringIndex];
textDirection = TextDirection.fromInt(buffer.getInt());
left = buffer.getFloat();

View File

@ -42,7 +42,7 @@ PlatformViewAndroidDelegate::PlatformViewAndroidDelegate(
void PlatformViewAndroidDelegate::UpdateSemantics(
flutter::SemanticsNodeUpdates update,
flutter::CustomAccessibilityActionUpdates actions) {
constexpr size_t kBytesPerNode = 47 * sizeof(int32_t);
constexpr size_t kBytesPerNode = 46 * sizeof(int32_t);
constexpr size_t kBytesPerChild = sizeof(int32_t);
constexpr size_t kBytesPerCustomAction = sizeof(int32_t);
constexpr size_t kBytesPerAction = 4 * sizeof(int32_t);
@ -148,13 +148,6 @@ void PlatformViewAndroidDelegate::UpdateSemantics(
putStringAttributesIntoBuffer(node.hintAttributes, buffer_int32, position,
string_attribute_args);
if (node.tooltip.empty()) {
buffer_int32[position++] = -1;
} else {
buffer_int32[position++] = strings.size();
strings.push_back(node.tooltip);
}
buffer_int32[position++] = node.textDirection;
buffer_float32[position++] = node.rect.left();
buffer_float32[position++] = node.rect.top();

View File

@ -19,10 +19,9 @@ TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) {
flutter::SemanticsNode node0;
node0.id = 0;
node0.label = "label";
node0.tooltip = "tooltip";
update.insert(std::make_pair(0, std::move(node0)));
std::vector<uint8_t> expected_buffer(188);
std::vector<uint8_t> expected_buffer(184);
std::vector<std::vector<uint8_t>> expected_string_attribute_args(0);
size_t position = 0;
int32_t* buffer_int32 = reinterpret_cast<int32_t*>(&expected_buffer[0]);
@ -52,8 +51,6 @@ TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) {
buffer_int32[position++] = -1; // node0.decreasedValueAttributes
buffer_int32[position++] = -1; // node0.hint
buffer_int32[position++] = -1; // node0.hintAttributes
buffer_int32[position++] = expected_strings.size(); // node0.tooltip
expected_strings.push_back(node0.tooltip);
buffer_int32[position++] = node0.textDirection;
buffer_float32[position++] = node0.rect.left();
buffer_float32[position++] = node0.rect.top();
@ -96,7 +93,7 @@ TEST(PlatformViewShell,
node0.hintAttributes.push_back(locale_attribute);
update.insert(std::make_pair(0, std::move(node0)));
std::vector<uint8_t> expected_buffer(220);
std::vector<uint8_t> expected_buffer(216);
std::vector<std::vector<uint8_t>> expected_string_attribute_args;
size_t position = 0;
int32_t* buffer_int32 = reinterpret_cast<int32_t*>(&expected_buffer[0]);
@ -135,10 +132,9 @@ TEST(PlatformViewShell,
buffer_int32[position++] = 3; // node0.hintAttributes[0].end
buffer_int32[position++] = 1; // node0.hintAttributes[0].type
buffer_int32[position++] =
expected_string_attribute_args.size(); // node0.hintAttributes[0].args
expected_string_attribute_args.size(); // node0.labelAttributes[0].args
expected_string_attribute_args.push_back(
{locale_attribute->locale.begin(), locale_attribute->locale.end()});
buffer_int32[position++] = -1; // node0.tooltip
buffer_int32[position++] = node0.textDirection;
buffer_float32[position++] = node0.rect.left();
buffer_float32[position++] = node0.rect.top();

View File

@ -719,43 +719,6 @@ public class AccessibilityBridgeTest {
assertEquals(actual.getSpanEnd(spellOutSpan), 9);
}
@TargetApi(28)
@Test
public void itSetsTooltipCorrectly() {
AccessibilityChannel mockChannel = mock(AccessibilityChannel.class);
AccessibilityViewEmbedder mockViewEmbedder = mock(AccessibilityViewEmbedder.class);
AccessibilityManager mockManager = mock(AccessibilityManager.class);
View mockRootView = mock(View.class);
Context context = mock(Context.class);
when(mockRootView.getContext()).thenReturn(context);
when(context.getPackageName()).thenReturn("test");
AccessibilityBridge accessibilityBridge =
setUpBridge(
/*rootAccessibilityView=*/ mockRootView,
/*accessibilityChannel=*/ mockChannel,
/*accessibilityManager=*/ mockManager,
/*contentResolver=*/ null,
/*accessibilityViewEmbedder=*/ mockViewEmbedder,
/*platformViewsAccessibilityDelegate=*/ null);
ViewParent mockParent = mock(ViewParent.class);
when(mockRootView.getParent()).thenReturn(mockParent);
when(mockManager.isEnabled()).thenReturn(true);
// Create a node with tooltip.
TestSemanticsNode root = new TestSemanticsNode();
root.id = 0;
root.tooltip = "tooltip";
TestSemanticsUpdate testSemanticsUpdate = root.toUpdate();
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
// Test the generated AccessibilityNodeInfo for the node we created
// and verify it has correct tooltip text.
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
CharSequence actual = nodeInfo.getTooltipText();
assertEquals(actual.toString(), root.tooltip);
}
@TargetApi(21)
@Test
public void itCanCreateAccessibilityNodeInfoWithSetText() {
@ -1589,7 +1552,6 @@ public class AccessibilityBridgeTest {
List<TestStringAttribute> decreasedValueAttributes;
String hint = null;
List<TestStringAttribute> hintAttributes;
String tooltip = null;
int textDirection = 0;
float left = 0.0f;
float top = 0.0f;
@ -1641,12 +1603,6 @@ public class AccessibilityBridgeTest {
updateString(increasedValue, increasedValueAttributes, bytes, strings, stringAttributeArgs);
updateString(decreasedValue, decreasedValueAttributes, bytes, strings, stringAttributeArgs);
updateString(hint, hintAttributes, bytes, strings, stringAttributeArgs);
if (tooltip == null) {
bytes.putInt(-1);
} else {
strings.add(tooltip);
bytes.putInt(strings.size() - 1);
}
bytes.putInt(textDirection);
bytes.putFloat(left);
bytes.putFloat(top);

View File

@ -610,16 +610,10 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) {
- (NSString*)accessibilityLabel {
if (![self isAccessibilityBridgeAlive])
return nil;
NSString* label;
if (![self node].label.empty()) {
label = @([self node].label.data());
}
if (![self node].tooltip.empty()) {
label = [NSString stringWithFormat:@"%@%@",
label ? [NSString stringWithFormat:@"%@\n", label] : @"",
@([self node].tooltip.data())];
}
return label;
if ([self node].label.empty())
return nil;
return @([self node].label.data());
}
- (NSAttributedString*)accessibilityAttributedLabel {

View File

@ -468,22 +468,6 @@ class MockAccessibilityBridgeNoWindow : public AccessibilityBridgeIos {
XCTAssertTrue([scrollable_object.accessibilityHint isEqualToString:@"hint"]);
}
- (void)testFlutterSemanticsObjectMergeTooltipToLabel {
flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge();
mock->isVoiceOverRunningValue = true;
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
flutter::SemanticsNode node;
node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
node.label = "label";
node.tooltip = "tooltip";
FlutterSemanticsObject* object = [[FlutterSemanticsObject alloc] initWithBridge:bridge uid:0];
[object setSemanticsNode:&node];
XCTAssertTrue(object.isAccessibilityElement);
XCTAssertTrue([object.accessibilityLabel isEqualToString:@"label\ntooltip"]);
}
- (void)testFlutterScrollableSemanticsObjectReturnsParentContainerIfNoChildren {
flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge();
mock->isVoiceOverRunningValue = true;

View File

@ -120,7 +120,6 @@ void a11y_main() async {
..updateNode(
id: 42,
label: 'A: root',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0),
transform: kTestTransform,
childrenInTraversalOrder: Int32List.fromList(<int>[84, 96]),
@ -139,21 +138,15 @@ void a11y_main() async {
scrollExtentMin: 0.0,
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
hint: "",
value: "",
increasedValue: "",
decreasedValue: "",
additionalActions: Int32List(0),
)
..updateNode(
id: 84,
label: 'B: leaf',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
transform: kTestTransform,
actions: 0,
@ -170,15 +163,10 @@ void a11y_main() async {
scrollExtentMin: 0.0,
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
hint: "",
value: "",
increasedValue: "",
decreasedValue: "",
additionalActions: Int32List(0),
childrenInHitTestOrder: Int32List(0),
childrenInTraversalOrder: Int32List(0),
@ -186,7 +174,6 @@ void a11y_main() async {
..updateNode(
id: 96,
label: 'C: branch',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
transform: kTestTransform,
childrenInTraversalOrder: Int32List.fromList(<int>[128]),
@ -205,21 +192,15 @@ void a11y_main() async {
scrollExtentMin: 0.0,
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
hint: "",
value: "",
increasedValue: "",
decreasedValue: "",
additionalActions: Int32List(0),
)
..updateNode(
id: 128,
label: 'D: leaf',
labelAttributes: <StringAttribute>[],
rect: Rect.fromLTRB(40.0, 40.0, 80.0, 80.0),
transform: kTestTransform,
additionalActions: Int32List.fromList(<int>[21]),
@ -237,15 +218,10 @@ void a11y_main() async {
scrollExtentMin: 0.0,
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
hint: "",
value: "",
increasedValue: "",
decreasedValue: "",
childrenInHitTestOrder: Int32List(0),
childrenInTraversalOrder: Int32List(0),
)

View File

@ -331,15 +331,6 @@ AccessibilityBridge::GetNodeAttributes(const flutter::SemanticsNode& node,
*added_size += node.label.size();
}
if (node.tooltip.size() > fuchsia::accessibility::semantics::MAX_LABEL_SIZE) {
attributes.set_secondary_label(node.tooltip.substr(
0, fuchsia::accessibility::semantics::MAX_LABEL_SIZE));
*added_size += fuchsia::accessibility::semantics::MAX_LABEL_SIZE;
} else {
attributes.set_secondary_label(node.tooltip);
*added_size += node.tooltip.size();
}
if (node.HasFlag(flutter::SemanticsFlags::kIsKeyboardKey)) {
attributes.set_is_keyboard_key(true);
}

View File

@ -585,52 +585,6 @@ TEST_F(AccessibilityBridgeTest, TruncatesLargeLabel) {
EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
}
TEST_F(AccessibilityBridgeTest, TruncatesLargeToolTip) {
// Test that tooltips which are too long are truncated.
flutter::SemanticsNode node0;
node0.id = 0;
flutter::SemanticsNode node1;
node1.id = 1;
flutter::SemanticsNode bad_node;
bad_node.id = 2;
bad_node.tooltip =
std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE + 1, '2');
node0.childrenInTraversalOrder = {1, 2};
node0.childrenInHitTestOrder = {1, 2};
accessibility_bridge_->AddSemanticsNodeUpdate(
{
{0, node0},
{1, node1},
{2, bad_node},
},
1.f);
RunLoopUntilIdle();
// Nothing to delete, but we should have broken
EXPECT_EQ(0, semantics_manager_.DeleteCount());
EXPECT_EQ(1, semantics_manager_.UpdateCount());
EXPECT_EQ(1, semantics_manager_.CommitCount());
EXPECT_EQ(3U, semantics_manager_.LastUpdatedNodes().size());
auto trimmed_node =
std::find_if(semantics_manager_.LastUpdatedNodes().begin(),
semantics_manager_.LastUpdatedNodes().end(),
[id = static_cast<uint32_t>(bad_node.id)](
fuchsia::accessibility::semantics::Node const& node) {
return node.node_id() == id;
});
ASSERT_NE(trimmed_node, semantics_manager_.LastUpdatedNodes().end());
ASSERT_TRUE(trimmed_node->has_attributes());
EXPECT_EQ(
trimmed_node->attributes().secondary_label(),
std::string(fuchsia::accessibility::semantics::MAX_LABEL_SIZE, '2'));
EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
}
TEST_F(AccessibilityBridgeTest, TruncatesLargeValue) {
// Test that values which are too long are truncated.
flutter::SemanticsNode node0;

View File

@ -52,7 +52,6 @@ class LocaleInitialization extends Scenario {
actions: 1,
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
label: window.locales.toString(),
labelAttributes: <StringAttribute>[],
textDirection: TextDirection.ltr,
textSelectionBase: -1,
textSelectionExtent: -1,
@ -68,14 +67,9 @@ class LocaleInitialization extends Scenario {
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),
@ -107,7 +101,6 @@ class LocaleInitialization extends Scenario {
actions: 1,
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
label: label,
labelAttributes: <StringAttribute>[],
textDirection: TextDirection.ltr,
textSelectionBase: 0,
textSelectionExtent: 0,
@ -123,14 +116,9 @@ class LocaleInitialization extends Scenario {
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),

View File

@ -47,7 +47,6 @@ class SendTextFocusSemantics extends Scenario {
actions: 1,
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
label: 'flutter textfield',
labelAttributes: <StringAttribute>[],
textDirection: TextDirection.ltr,
textSelectionBase: -1,
textSelectionExtent: -1,
@ -63,14 +62,9 @@ class SendTextFocusSemantics extends Scenario {
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),
@ -110,7 +104,6 @@ class SendTextFocusSemantics extends Scenario {
actions: 18433,
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
label: 'focused flutter textfield',
labelAttributes: <StringAttribute>[],
textDirection: TextDirection.ltr,
textSelectionBase: 0,
textSelectionExtent: 0,
@ -126,14 +119,9 @@ class SendTextFocusSemantics extends Scenario {
elevation: 0.0,
thickness: 0.0,
hint: '',
hintAttributes: <StringAttribute>[],
value: '',
valueAttributes: <StringAttribute>[],
increasedValue: '',
increasedValueAttributes: <StringAttribute>[],
decreasedValue: '',
decreasedValueAttributes: <StringAttribute>[],
tooltip: '',
childrenInTraversalOrder: Int32List(0),
childrenInHitTestOrder: Int32List(0),
additionalActions: Int32List(0),