Skip to content

Commit e25b764

Browse files
hannah-hyjchunhtai
andauthored
[android][a11y] set "android.widget.ProgressBar" according to semantics role (#183897)
when testing #182491 I found out the ProgressBar class is not set on android, setting the class name will make the talkback announce "progress bar". ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com>
1 parent 94c7ecb commit e25b764

5 files changed

Lines changed: 254 additions & 1 deletion

File tree

engine/src/flutter/shell/platform/android/io/flutter/view/AccessibilityBridge.java

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,49 @@ public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) {
851851
// TODO(jonahwilliams): Figure out a way conform to the expected id from TalkBack's
852852
// CustomLabelManager. talkback/src/main/java/labeling/CustomLabelManager.java#L525
853853
}
854+
Role role = Role.values()[semanticsNode.role];
855+
switch (role) {
856+
case PROGRESS_BAR:
857+
result.setClassName("android.widget.ProgressBar");
858+
if (semanticsNode.value != null) {
859+
float min = Float.NEGATIVE_INFINITY;
860+
float max = Float.POSITIVE_INFINITY;
861+
if (semanticsNode.minValue != null) {
862+
try {
863+
min = Float.parseFloat(semanticsNode.minValue);
864+
} catch (NumberFormatException e) {
865+
// Fallback to default min.
866+
}
867+
}
868+
if (semanticsNode.maxValue != null) {
869+
try {
870+
max = Float.parseFloat(semanticsNode.maxValue);
871+
} catch (NumberFormatException e) {
872+
// Fallback to default max.
873+
}
874+
}
875+
try {
876+
float parsedValue = Float.parseFloat(semanticsNode.value);
877+
result.setRangeInfo(
878+
AccessibilityNodeInfo.RangeInfo.obtain(
879+
AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_FLOAT, min, max, parsedValue));
880+
} catch (NumberFormatException e) {
881+
if (Build.VERSION.SDK_INT >= API_LEVELS.API_36) {
882+
result.setRangeInfo(
883+
AccessibilityNodeInfo.RangeInfo.obtain(
884+
AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_INDETERMINATE, 0.0f, 0.0f, 0.0f));
885+
} else {
886+
// Fallback to RANGE_TYPE_FLOAT with 0.0.
887+
result.setRangeInfo(
888+
AccessibilityNodeInfo.RangeInfo.obtain(
889+
AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_FLOAT, 0.0f, 0.0f, 0.0f));
890+
}
891+
}
892+
}
893+
break;
894+
default:
895+
break;
896+
}
854897
if (semanticsNode.hasAction(Action.DISMISS)) {
855898
result.setDismissable(true);
856899
result.addAction(AccessibilityNodeInfo.ACTION_DISMISS);
@@ -2331,6 +2374,50 @@ public enum Action {
23312374
}
23322375
}
23332376

2377+
// Must match SemanticsRole in semantics.dart
2378+
// https://github.com/flutter/flutter/blob/main/engine/src/flutter/lib/ui/semantics.dart
2379+
enum Role {
2380+
NONE(0),
2381+
TAB(1),
2382+
TAB_BAR(2),
2383+
TAB_PANEL(3),
2384+
DIALOG(4),
2385+
ALERT_DIALOG(5),
2386+
TABLE(6),
2387+
CELL(7),
2388+
ROW(8),
2389+
COLUMN_HEADER(9),
2390+
DRAG_HANDLE(10),
2391+
SPIN_BUTTON(11),
2392+
COMBO_BOX(12),
2393+
MENU_BAR(13),
2394+
MENU(14),
2395+
MENU_ITEM(15),
2396+
MENU_ITEM_CHECKBOX(16),
2397+
MENU_ITEM_RADIO(17),
2398+
LIST(18),
2399+
LIST_ITEM(19),
2400+
FORM(20),
2401+
TOOLTIP(21),
2402+
LOADING_SPINNER(22),
2403+
PROGRESS_BAR(23),
2404+
HOTKEY(24),
2405+
RADIO_GROUP(25),
2406+
STATUS(26),
2407+
ALERT(27),
2408+
COMPLEMENTARY(28),
2409+
CONTENT_INFO(29),
2410+
MAIN(30),
2411+
NAVIGATION(31),
2412+
REGION(32);
2413+
2414+
final int value;
2415+
2416+
Role(int value) {
2417+
this.value = value;
2418+
}
2419+
}
2420+
23342421
// Actions that are triggered by Android OS, as opposed to user-triggered actions.
23352422
//
23362423
// This int is intended to be use in a bitwise comparison.
@@ -2522,6 +2609,12 @@ private static boolean nullableHasAncestor(
25222609
// The locale of the content of this node.
25232610
@Nullable private String locale;
25242611

2612+
@Nullable private String minValue;
2613+
@Nullable private String maxValue;
2614+
2615+
// The role of this node.
2616+
private int role;
2617+
25252618
// The heading level for this node (0 means not a heading).
25262619
private int headingLevel;
25272620

@@ -2730,6 +2823,7 @@ private void updateWith(
27302823
scrollPosition = buffer.getFloat();
27312824
scrollExtentMax = buffer.getFloat();
27322825
scrollExtentMin = buffer.getFloat();
2826+
role = buffer.getInt();
27332827

27342828
identifier = getStringFromBuffer(buffer, strings);
27352829

@@ -2751,6 +2845,8 @@ private void updateWith(
27512845
tooltip = getStringFromBuffer(buffer, strings);
27522846
linkUrl = getStringFromBuffer(buffer, strings);
27532847
locale = getStringFromBuffer(buffer, strings);
2848+
minValue = getStringFromBuffer(buffer, strings);
2849+
maxValue = getStringFromBuffer(buffer, strings);
27542850

27552851
headingLevel = buffer.getInt();
27562852
textDirection = TextDirection.fromInt(buffer.getInt());

engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ void PlatformViewAndroidDelegate::UpdateSemantics(
214214
buffer_float32[position++] = static_cast<float>(node.scrollPosition);
215215
buffer_float32[position++] = static_cast<float>(node.scrollExtentMax);
216216
buffer_float32[position++] = static_cast<float>(node.scrollExtentMin);
217+
buffer_int32[position++] = static_cast<int32_t>(node.role);
217218

218219
putStringIntoBuffer(node.identifier, buffer_int32, &position, strings);
219220

@@ -242,6 +243,8 @@ void PlatformViewAndroidDelegate::UpdateSemantics(
242243
putStringIntoBuffer(node.tooltip, buffer_int32, &position, strings);
243244
putStringIntoBuffer(node.linkUrl, buffer_int32, &position, strings);
244245
putStringIntoBuffer(node.locale, buffer_int32, &position, strings);
246+
putStringIntoBuffer(node.minValue, buffer_int32, &position, strings);
247+
putStringIntoBuffer(node.maxValue, buffer_int32, &position, strings);
245248

246249
buffer_int32[position++] = node.headingLevel;
247250
buffer_int32[position++] = node.textDirection;

engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace flutter {
1717
class PlatformViewAndroidDelegate {
1818
public:
1919
static constexpr size_t kBytesPerNode =
20-
70 * sizeof(int32_t); // The # fields in SemanticsNode
20+
73 * sizeof(int32_t); // The # fields in SemanticsNode
2121
static constexpr size_t kBytesPerChild = sizeof(int32_t);
2222
static constexpr size_t kBytesPerCustomAction = sizeof(int32_t);
2323
static constexpr size_t kBytesPerAction = 4 * sizeof(int32_t);

engine/src/flutter/shell/platform/android/platform_view_android_delegate/platform_view_android_delegate_unittests.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) {
4545
buffer_float32[position++] = static_cast<float>(node0.scrollPosition);
4646
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMax);
4747
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMin);
48+
buffer_int32[position++] = static_cast<int32_t>(node0.role);
4849
buffer_int32[position++] = expected_strings.size(); // node0.identifier
4950
expected_strings.push_back(node0.identifier);
5051
buffer_int32[position++] = expected_strings.size(); // node0.label
@@ -62,6 +63,8 @@ TEST(PlatformViewShell, UpdateSemanticsDoesFlutterViewUpdateSemantics) {
6263
expected_strings.push_back(node0.tooltip);
6364
buffer_int32[position++] = -1; // node0.linkUrl
6465
buffer_int32[position++] = -1; // node0.locale
66+
buffer_int32[position++] = -1; // node0.minValue
67+
buffer_int32[position++] = -1; // node0.maxValue
6568
buffer_int32[position++] = node0.headingLevel;
6669
buffer_int32[position++] = node0.textDirection;
6770
buffer_float32[position++] = node0.rect.left();
@@ -116,6 +119,7 @@ TEST(PlatformViewShell, UpdateSemanticsDoesUpdateLinkUrl) {
116119
buffer_float32[position++] = static_cast<float>(node0.scrollPosition);
117120
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMax);
118121
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMin);
122+
buffer_int32[position++] = static_cast<int32_t>(node0.role);
119123
buffer_int32[position++] = expected_strings.size(); // node0.identifier
120124
expected_strings.push_back(node0.identifier);
121125
buffer_int32[position++] = expected_strings.size(); // node0.label
@@ -133,6 +137,8 @@ TEST(PlatformViewShell, UpdateSemanticsDoesUpdateLinkUrl) {
133137
buffer_int32[position++] = expected_strings.size(); // node0.linkUrl
134138
expected_strings.push_back(node0.linkUrl);
135139
buffer_int32[position++] = -1; // node0.locale
140+
buffer_int32[position++] = -1; // node0.minValue
141+
buffer_int32[position++] = -1; // node0.maxValue
136142
buffer_int32[position++] = node0.headingLevel;
137143
buffer_int32[position++] = node0.textDirection;
138144
buffer_float32[position++] = node0.rect.left();
@@ -188,6 +194,7 @@ TEST(PlatformViewShell, UpdateSemanticsDoesUpdateLocale) {
188194
buffer_float32[position++] = static_cast<float>(node0.scrollPosition);
189195
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMax);
190196
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMin);
197+
buffer_int32[position++] = static_cast<int32_t>(node0.role);
191198
buffer_int32[position++] = expected_strings.size(); // node0.identifier
192199
expected_strings.push_back(node0.identifier);
193200
buffer_int32[position++] = expected_strings.size(); // node0.label
@@ -205,6 +212,8 @@ TEST(PlatformViewShell, UpdateSemanticsDoesUpdateLocale) {
205212
buffer_int32[position++] = -1; // node0.linkUrl
206213
buffer_int32[position++] = expected_strings.size();
207214
expected_strings.push_back(node0.locale); // node0.locale
215+
buffer_int32[position++] = -1; // node0.minValue
216+
buffer_int32[position++] = -1; // node0.maxValue
208217
buffer_int32[position++] = node0.headingLevel;
209218
buffer_int32[position++] = node0.textDirection;
210219
buffer_float32[position++] = node0.rect.left();
@@ -275,6 +284,7 @@ TEST(PlatformViewShell,
275284
buffer_float32[position++] = static_cast<float>(node0.scrollPosition);
276285
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMax);
277286
buffer_float32[position++] = static_cast<float>(node0.scrollExtentMin);
287+
buffer_int32[position++] = static_cast<int32_t>(node0.role);
278288
buffer_int32[position++] = expected_strings.size(); // node0.identifier
279289
expected_strings.push_back(node0.identifier);
280290
buffer_int32[position++] = expected_strings.size(); // node0.label
@@ -303,6 +313,8 @@ TEST(PlatformViewShell,
303313
buffer_int32[position++] = -1; // node0.tooltip
304314
buffer_int32[position++] = -1; // node0.linkUrl
305315
buffer_int32[position++] = -1; // node0.locale
316+
buffer_int32[position++] = -1; // node0.minValue
317+
buffer_int32[position++] = -1; // node0.maxValue
306318
buffer_int32[position++] = node0.headingLevel;
307319
buffer_int32[position++] = node0.textDirection;
308320
buffer_float32[position++] = node0.rect.left();

engine/src/flutter/shell/platform/android/test/io/flutter/view/AccessibilityBridgeTest.java

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,6 +2410,132 @@ public void itAddsScrollViewToClassName() {
24102410
assertEquals("android.widget.HorizontalScrollView", nodeInfo.getClassName().toString());
24112411
}
24122412

2413+
@Test
2414+
public void itAddsProgressBarToClassName() {
2415+
AccessibilityBridge accessibilityBridge = setUpBridge();
2416+
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
2417+
testSemanticsNode.role = 23; // SemanticsRole::kProgressBar
2418+
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
2419+
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
2420+
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
2421+
assertEquals("android.widget.ProgressBar", nodeInfo.getClassName().toString());
2422+
}
2423+
2424+
@Test
2425+
public void itAddsRangeInfoToProgressBar() {
2426+
AccessibilityBridge accessibilityBridge = setUpBridge();
2427+
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
2428+
testSemanticsNode.role = 23; // SemanticsRole::kProgressBar
2429+
testSemanticsNode.value = "50";
2430+
testSemanticsNode.minValue = "0";
2431+
testSemanticsNode.maxValue = "100";
2432+
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
2433+
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
2434+
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
2435+
assertEquals("android.widget.ProgressBar", nodeInfo.getClassName().toString());
2436+
assertNotNull(nodeInfo.getRangeInfo());
2437+
assertEquals(0.0f, nodeInfo.getRangeInfo().getMin(), 1e-4f);
2438+
assertEquals(100.0f, nodeInfo.getRangeInfo().getMax(), 1e-4f);
2439+
assertEquals(50.0f, nodeInfo.getRangeInfo().getCurrent(), 1e-4f);
2440+
}
2441+
2442+
@Test
2443+
public void itAddsRangeInfoToProgressBar_missingMinAndMaxValue() {
2444+
AccessibilityBridge accessibilityBridge = setUpBridge();
2445+
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
2446+
testSemanticsNode.role = 23; // SemanticsRole::kProgressBar
2447+
testSemanticsNode.value = "50";
2448+
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
2449+
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
2450+
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
2451+
assertEquals("android.widget.ProgressBar", nodeInfo.getClassName().toString());
2452+
assertNotNull(nodeInfo.getRangeInfo());
2453+
assertEquals(Float.NEGATIVE_INFINITY, nodeInfo.getRangeInfo().getMin(), 1e-4f);
2454+
assertEquals(Float.POSITIVE_INFINITY, nodeInfo.getRangeInfo().getMax(), 1e-4f);
2455+
assertEquals(50.0f, nodeInfo.getRangeInfo().getCurrent(), 1e-4f);
2456+
}
2457+
2458+
@Test
2459+
public void itAddsRangeInfoToProgressBar_unparseableMinValue() {
2460+
AccessibilityBridge accessibilityBridge = setUpBridge();
2461+
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
2462+
testSemanticsNode.role = 23; // SemanticsRole::kProgressBar
2463+
testSemanticsNode.value = "50";
2464+
testSemanticsNode.minValue = "a";
2465+
testSemanticsNode.maxValue = "100";
2466+
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
2467+
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
2468+
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
2469+
assertEquals("android.widget.ProgressBar", nodeInfo.getClassName().toString());
2470+
assertNotNull(nodeInfo.getRangeInfo());
2471+
assertEquals(Float.NEGATIVE_INFINITY, nodeInfo.getRangeInfo().getMin(), 1e-4f);
2472+
assertEquals(100.0f, nodeInfo.getRangeInfo().getMax(), 1e-4f);
2473+
assertEquals(50.0f, nodeInfo.getRangeInfo().getCurrent(), 1e-4f);
2474+
}
2475+
2476+
@Test
2477+
public void itAddsRangeInfoToProgressBar_unparseableMaxValue() {
2478+
AccessibilityBridge accessibilityBridge = setUpBridge();
2479+
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
2480+
testSemanticsNode.role = 23; // SemanticsRole::kProgressBar
2481+
testSemanticsNode.value = "50";
2482+
testSemanticsNode.minValue = "0";
2483+
testSemanticsNode.maxValue = "a";
2484+
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
2485+
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
2486+
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
2487+
assertEquals("android.widget.ProgressBar", nodeInfo.getClassName().toString());
2488+
assertNotNull(nodeInfo.getRangeInfo());
2489+
assertEquals(0.0f, nodeInfo.getRangeInfo().getMin(), 1e-4f);
2490+
assertEquals(Float.POSITIVE_INFINITY, nodeInfo.getRangeInfo().getMax(), 1e-4f);
2491+
assertEquals(50.0f, nodeInfo.getRangeInfo().getCurrent(), 1e-4f);
2492+
}
2493+
2494+
@Config(sdk = API_LEVELS.API_34)
2495+
@TargetApi(API_LEVELS.API_34)
2496+
@Test
2497+
public void itAddsRangeInfoToProgressBar_unparseableValue() {
2498+
AccessibilityBridge accessibilityBridge = setUpBridge();
2499+
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
2500+
testSemanticsNode.role = 23; // SemanticsRole::kProgressBar
2501+
testSemanticsNode.value = "a";
2502+
testSemanticsNode.minValue = "0";
2503+
testSemanticsNode.maxValue = "100";
2504+
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
2505+
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
2506+
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
2507+
assertEquals("android.widget.ProgressBar", nodeInfo.getClassName().toString());
2508+
assertNotNull(nodeInfo.getRangeInfo());
2509+
assertEquals(
2510+
AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_FLOAT, nodeInfo.getRangeInfo().getType());
2511+
assertEquals(0.0f, nodeInfo.getRangeInfo().getMin(), 1e-4f);
2512+
assertEquals(0.0f, nodeInfo.getRangeInfo().getMax(), 1e-4f);
2513+
assertEquals(0.0f, nodeInfo.getRangeInfo().getCurrent(), 1e-4f);
2514+
}
2515+
2516+
@Config(sdk = API_LEVELS.API_36)
2517+
@TargetApi(API_LEVELS.API_36)
2518+
@Test
2519+
public void itAddsRangeInfoToProgressBar_unparseableValueAPI36() {
2520+
AccessibilityBridge accessibilityBridge = setUpBridge();
2521+
TestSemanticsNode testSemanticsNode = new TestSemanticsNode();
2522+
testSemanticsNode.role = 23; // SemanticsRole::kProgressBar
2523+
testSemanticsNode.value = "a";
2524+
testSemanticsNode.minValue = "0";
2525+
testSemanticsNode.maxValue = "100";
2526+
TestSemanticsUpdate testSemanticsUpdate = testSemanticsNode.toUpdate();
2527+
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
2528+
AccessibilityNodeInfo nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
2529+
assertEquals("android.widget.ProgressBar", nodeInfo.getClassName().toString());
2530+
assertNotNull(nodeInfo.getRangeInfo());
2531+
assertEquals(
2532+
AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_INDETERMINATE,
2533+
nodeInfo.getRangeInfo().getType());
2534+
assertEquals(0.0f, nodeInfo.getRangeInfo().getMin(), 1e-4f);
2535+
assertEquals(0.0f, nodeInfo.getRangeInfo().getMax(), 1e-4f);
2536+
assertEquals(0.0f, nodeInfo.getRangeInfo().getCurrent(), 1e-4f);
2537+
}
2538+
24132539
@Config(sdk = API_LEVELS.API_32)
24142540
@TargetApi(API_LEVELS.API_32)
24152541
@Test
@@ -2928,6 +3054,9 @@ void addAction(AccessibilityBridge.Action action) {
29283054
String tooltip = null;
29293055
String linkUrl = null;
29303056
String locale = null;
3057+
String minValue = null;
3058+
String maxValue = null;
3059+
int role = 0;
29313060
int headingLevel = 0;
29323061
int textDirection = 0;
29333062
float left = 0.0f;
@@ -2984,6 +3113,7 @@ protected void addToBuffer(
29843113
bytes.putFloat(scrollPosition);
29853114
bytes.putFloat(scrollExtentMax);
29863115
bytes.putFloat(scrollExtentMin);
3116+
bytes.putInt(role);
29873117
if (identifier == null) {
29883118
bytes.putInt(-1);
29893119
} else {
@@ -3013,6 +3143,18 @@ protected void addToBuffer(
30133143
strings.add(locale);
30143144
bytes.putInt(strings.size() - 1);
30153145
}
3146+
if (minValue == null) {
3147+
bytes.putInt(-1);
3148+
} else {
3149+
strings.add(minValue);
3150+
bytes.putInt(strings.size() - 1);
3151+
}
3152+
if (maxValue == null) {
3153+
bytes.putInt(-1);
3154+
} else {
3155+
strings.add(maxValue);
3156+
bytes.putInt(strings.size() - 1);
3157+
}
30163158
bytes.putInt(headingLevel);
30173159
bytes.putInt(textDirection);
30183160
bytes.putFloat(left);

0 commit comments

Comments
 (0)