Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 EXPECT_EQ(selection_range, | 297 EXPECT_EQ(selection_range, |
| 298 gfx::Range([AttributeValueAtMidpoint( | 298 gfx::Range([AttributeValueAtMidpoint( |
| 299 NSAccessibilitySelectedTextRangeAttribute) rangeValue])); | 299 NSAccessibilitySelectedTextRangeAttribute) rangeValue])); |
| 300 | 300 |
| 301 // NSAccessibilityVisibleCharacterRangeAttribute. | 301 // NSAccessibilityVisibleCharacterRangeAttribute. |
| 302 EXPECT_EQ(gfx::Range(0, kTestStringValue.length), | 302 EXPECT_EQ(gfx::Range(0, kTestStringValue.length), |
| 303 gfx::Range([AttributeValueAtMidpoint( | 303 gfx::Range([AttributeValueAtMidpoint( |
| 304 NSAccessibilityVisibleCharacterRangeAttribute) rangeValue])); | 304 NSAccessibilityVisibleCharacterRangeAttribute) rangeValue])); |
| 305 } | 305 } |
| 306 | 306 |
| 307 // Test writing accessibility attributes via an accessibility client. | |
| 308 TEST_F(NativeWidgetMacAccessibilityTest, TextfieldWritableAttributes) { | |
| 309 AddChildTextfield(GetWidgetBounds().size()); | |
| 310 | |
| 311 // Get the textfield accessibility object. | |
| 312 NSPoint midpoint = gfx::ScreenPointToNSPoint(GetWidgetBounds().CenterPoint()); | |
| 313 id textfield = [widget()->GetNativeWindow() accessibilityHitTest:midpoint]; | |
| 314 EXPECT_TRUE(textfield); | |
| 315 | |
| 316 // Make sure it's the correct accessibility object. | |
| 317 id value = | |
| 318 [textfield accessibilityAttributeValue:NSAccessibilityValueAttribute]; | |
| 319 EXPECT_NSEQ(kTestStringValue, value); | |
| 320 | |
| 321 // Write a new NSAccessibilityValueAttribute. | |
| 322 EXPECT_TRUE([textfield | |
| 323 accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]); | |
| 324 [textfield accessibilitySetValue:kTestPlaceholderText | |
| 325 forAttribute:NSAccessibilityValueAttribute]; | |
| 326 EXPECT_NSEQ(kTestPlaceholderText, | |
| 327 AttributeValueAtMidpoint(NSAccessibilityValueAttribute)); | |
| 328 } | |
|
tapted
2016/08/11 04:23:26
We should also check that the value of the views::
Patti Lor
2016/08/12 01:57:42
Done. Also added tests for a read-only textfield.
| |
| 329 | |
| 307 } // namespace views | 330 } // namespace views |
| OLD | NEW |