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

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

Issue 2341633006: MacViews/a11y: Allow accessibility clients to update the selected text. (Closed)
Patch Set: Move accessibility notification for text selection being changed to SelectRange() instead. Created 4 years, 3 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
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 8f224aa37768d8d07e59c3ae67f668a1fe1c1b1e..f557df81ec6221539be5389d849a9e6925c031be 100644
--- a/ui/views/widget/native_widget_mac_accessibility_unittest.mm
+++ b/ui/views/widget/native_widget_mac_accessibility_unittest.mm
@@ -336,6 +336,40 @@ TEST_F(NativeWidgetMacAccessibilityTest, TextfieldWritableAttributes) {
EXPECT_NSEQ(kTestPlaceholderText,
AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
EXPECT_EQ(base::SysNSStringToUTF16(kTestPlaceholderText), textfield->text());
+ textfield->SetReadOnly(false);
+
+ // Change the selection text when there is no selected text.
+ textfield->SelectRange(gfx::Range(0, 0));
+ EXPECT_TRUE([ax_node
+ accessibilityIsAttributeSettable:NSAccessibilitySelectedTextAttribute]);
+
+ NSString* new_string =
+ [kTestStringValue stringByAppendingString:kTestPlaceholderText];
+ [ax_node accessibilitySetValue:kTestStringValue
+ forAttribute:NSAccessibilitySelectedTextAttribute];
+ EXPECT_NSEQ(new_string,
+ AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
+ EXPECT_EQ(base::SysNSStringToUTF16(new_string), textfield->text());
+
+ // Replace entire selection.
+ gfx::Range test_range(0, [new_string length]);
+ textfield->SelectRange(test_range);
+ [ax_node accessibilitySetValue:kTestStringValue
+ forAttribute:NSAccessibilitySelectedTextAttribute];
+ EXPECT_NSEQ(kTestStringValue,
+ AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
+ EXPECT_EQ(base::SysNSStringToUTF16(kTestStringValue), textfield->text());
+
+ // Replace a section only.
+ test_range = gfx::Range(5, [kTestStringValue length]);
+ new_string = [[kTestStringValue substringWithRange:NSMakeRange(0, 5)]
+ stringByAppendingString:kTestPlaceholderText];
+ textfield->SelectRange(test_range);
+ [ax_node accessibilitySetValue:kTestPlaceholderText
+ forAttribute:NSAccessibilitySelectedTextAttribute];
+ EXPECT_NSEQ(new_string,
+ AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
+ EXPECT_EQ(base::SysNSStringToUTF16(new_string), textfield->text());
}
tapted 2016/09/27 07:16:30 are there cross-platform tests for AccessibilitySe
Patti Lor 2016/10/20 04:19:34 No, I don't think so - I can add some? Not sure wh
tapted 2016/10/20 05:54:58 Hm - there's a windows-specific test in NativeView
Patti Lor 2016/10/24 04:31:48 Ok :) I missed the Windows one - thanks for invest
} // namespace views
« ui/views/controls/textfield/textfield.cc ('K') | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698