A11y enabled state (flutter/engine#48653)

Sets enabled state in Fuchsia a11y via the accessibility bridge.

This was added in Fuchsia API v15, which Flutter is updated to use after
#48233.

b/261482081

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
This commit is contained in:
Jonny Wang
2023-12-05 10:17:28 -08:00
committed by GitHub
parent 9518a0f00a
commit 8a83072ebc
2 changed files with 38 additions and 0 deletions

View File

@@ -340,6 +340,14 @@ fuchsia::accessibility::semantics::States AccessibilityBridge::GetNodeStates(
: fuchsia::accessibility::semantics::CheckedState::UNCHECKED);
}
// Set enabled state.
if (node.HasFlag(flutter::SemanticsFlags::kHasEnabledState)) {
states.set_enabled_state(
node.HasFlag(flutter::SemanticsFlags::kIsEnabled)
? fuchsia::accessibility::semantics::EnabledState::ENABLED
: fuchsia::accessibility::semantics::EnabledState::DISABLED);
}
// Set selected state.
states.set_selected(node.HasFlag(flutter::SemanticsFlags::kIsSelected));

View File

@@ -483,6 +483,36 @@ TEST_F(AccessibilityBridgeTest, PopulatesToggledState) {
EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
}
TEST_F(AccessibilityBridgeTest, PopulatesEnabledState) {
flutter::SemanticsNode node0;
node0.id = 0;
// HasEnabledState = true
// IsEnabled = true
node0.flags |= static_cast<int>(flutter::SemanticsFlags::kHasEnabledState);
node0.flags |= static_cast<int>(flutter::SemanticsFlags::kIsEnabled);
node0.value = "value";
accessibility_bridge_->AddSemanticsNodeUpdate({{0, node0}}, 1.f);
RunLoopUntilIdle();
EXPECT_EQ(0, semantics_manager_.DeleteCount());
EXPECT_EQ(1, semantics_manager_.UpdateCount());
EXPECT_EQ(1, semantics_manager_.CommitCount());
EXPECT_EQ(1U, semantics_manager_.LastUpdatedNodes().size());
const auto& fuchsia_node = semantics_manager_.LastUpdatedNodes().at(0u);
EXPECT_EQ(fuchsia_node.node_id(), static_cast<unsigned int>(node0.id));
EXPECT_TRUE(fuchsia_node.has_states());
const auto& states = fuchsia_node.states();
EXPECT_TRUE(states.has_enabled_state());
EXPECT_EQ(states.enabled_state(),
fuchsia::accessibility::semantics::EnabledState::ENABLED);
EXPECT_TRUE(states.has_value());
EXPECT_EQ(states.value(), node0.value);
EXPECT_FALSE(semantics_manager_.DeleteOverflowed());
EXPECT_FALSE(semantics_manager_.UpdateOverflowed());
}
TEST_F(AccessibilityBridgeTest, ApplyViewPixelRatioToRoot) {
flutter::SemanticsNode node0;
node0.id = 0;