Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(850)

Unified Diff: ui/views/widget/native_widget_mac_accessibility_unittest.mm

Issue 2684203002: MacViews/a11y: Allow accessibility clients to set new selections in Textfields. (Closed)
Patch Set: Revert textfield.cc. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/native_widget_mac_accessibility_unittest.mm
diff --git a/ui/views/widget/native_widget_mac_accessibility_unittest.mm b/ui/views/widget/native_widget_mac_accessibility_unittest.mm
index 3d641d190f9eab41fa0d4a97d726766736902263..3f35f0e17aa6284236f4bcdead8fd19659e6335c 100644
--- a/ui/views/widget/native_widget_mac_accessibility_unittest.mm
+++ b/ui/views/widget/native_widget_mac_accessibility_unittest.mm
@@ -411,6 +411,30 @@ TEST_F(NativeWidgetMacAccessibilityTest, TextfieldWritableAttributes) {
// Make sure the cursor is at the end of the replacement.
EXPECT_EQ(gfx::Range(front.length() + replacement.length()),
textfield->GetSelectedRange());
+
+ // Check it's not possible to change the selection range when read-only. Note
+ // that this behavior is inconsistent with Cocoa - selections can be set via
+ // a11y in non-editable, selectable NSTextfields. https://crbug.com/692362
tapted 2017/02/15 22:31:51 .. selectable NSTextfields (unless they are passwo
Patti Lor 2017/02/16 00:34:11 Done.
+ textfield->SetReadOnly(true);
+ EXPECT_FALSE([ax_node accessibilityIsAttributeSettable:
+ NSAccessibilitySelectedTextRangeAttribute]);
+ textfield->SetReadOnly(false);
+ EXPECT_TRUE([ax_node accessibilityIsAttributeSettable:
+ NSAccessibilitySelectedTextRangeAttribute]);
+
+ // Change the selection to a valid range within the text.
+ [ax_node accessibilitySetValue:[NSValue valueWithRange:NSMakeRange(2, 5)]
+ forAttribute:NSAccessibilitySelectedTextRangeAttribute];
+ EXPECT_EQ(gfx::Range(2, 7), textfield->GetSelectedRange());
+ // If the length is longer than the value length, default to the max possible.
+ [ax_node accessibilitySetValue:[NSValue valueWithRange:NSMakeRange(0, 1000)]
+ forAttribute:NSAccessibilitySelectedTextRangeAttribute];
+ EXPECT_EQ(gfx::Range(0, textfield->text().length()),
+ textfield->GetSelectedRange());
+ // Check just moving the cursor works, too.
+ [ax_node accessibilitySetValue:[NSValue valueWithRange:NSMakeRange(5, 0)]
+ forAttribute:NSAccessibilitySelectedTextRangeAttribute];
+ EXPECT_EQ(gfx::Range(5, 5), textfield->GetSelectedRange());
}
} // namespace views
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698