Commit 8a8b9d67 authored by Sara Kato's avatar Sara Kato Committed by Commit Bot

Handle toasts

Android toasts are sent with the event type
TYPE_NOTIFICATION_STATE_CHANGED. Ensure that this read out by ChromeVox.

ensure that toast is read as expected.

Test: Open test application containing a toast, enable ChromeVox and
Test: ArcAccessibilityHelperBridgeTest.Toast
Bug: b/145263558
Change-Id: Ic5dbf0330b3ac4b8ceecaab69cbd22c914ab10a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2056523
Commit-Queue: Sara Kato <sarakato@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741997}
parent 2aef179c
......@@ -770,11 +770,14 @@ void ArcAccessibilityHelperBridge::HandleFilterTypeFocusEvent(
void ArcAccessibilityHelperBridge::HandleFilterTypeAllEvent(
mojom::AccessibilityEventDataPtr event_data) {
if (event_data->event_type ==
arc::mojom::AccessibilityEventType::ANNOUNCEMENT) {
arc::mojom::AccessibilityEventType::ANNOUNCEMENT ||
event_data->event_type ==
arc::mojom::AccessibilityEventType::NOTIFICATION_STATE_CHANGED) {
if (!event_data->eventText.has_value())
return;
extensions::EventRouter* event_router = GetEventRouter();
// OnAnnounceForAccessibility is used to force speech output.
std::unique_ptr<base::ListValue> event_args(
extensions::api::accessibility_private::OnAnnounceForAccessibility::
Create(*(event_data->eventText)));
......
......@@ -400,6 +400,23 @@ TEST_F(ArcAccessibilityHelperBridgeTest, ToggleTalkBack) {
ASSERT_FALSE(helper_bridge->last_event->event_args->GetList()[0].GetBool());
}
TEST_F(ArcAccessibilityHelperBridgeTest, Toast) {
TestArcAccessibilityHelperBridge* helper_bridge =
accessibility_helper_bridge();
std::vector<std::string> text({"Toast text"});
auto event = arc::mojom::AccessibilityEventData::New();
event->event_type =
arc::mojom::AccessibilityEventType::NOTIFICATION_STATE_CHANGED;
event->eventText =
base::make_optional<std::vector<std::string>>(std::move(text));
helper_bridge->OnAccessibilityEvent(event.Clone());
ASSERT_EQ(1, helper_bridge->GetEventCount(
extensions::api::accessibility_private::
OnAnnounceForAccessibility::kEventName));
}
// Accessibility event and surface creation/removal are sent in different
// channels, mojo and wayland. Order of those events can be changed. This is the
// case where mojo events arrive earlier than surface creation/removal.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment