Chromium Code Reviews| 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..467a56e63c989f6ba4fcb31c87063cfca555202c 100644 |
| --- a/ui/views/widget/native_widget_mac_accessibility_unittest.mm |
| +++ b/ui/views/widget/native_widget_mac_accessibility_unittest.mm |
| @@ -411,6 +411,28 @@ 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 it's read-only. |
|
tapted
2017/02/09 23:09:37
Check that it *is* possible? Which I think is righ
Patti Lor
2017/02/13 23:31:03
Done, thanks. I had to change Textfield::SetSelect
|
| + textfield->SetReadOnly(true); |
| + EXPECT_TRUE([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 |