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 Textfield* textfield = AddChildTextfield(GetWidgetBounds().size()); | |
| 310 | |
| 311 // Get the textfield accessibility object. | |
| 312 NSPoint midpoint = gfx::ScreenPointToNSPoint(GetWidgetBounds().CenterPoint()); | |
| 313 id axTextfield = [widget()->GetNativeWindow() accessibilityHitTest:midpoint]; | |
|
tapted
2016/08/12 03:50:52
nit: ax_textfield (or perhaps ax_node?)
Patti Lor
2016/08/12 05:16:54
Done.
| |
| 314 EXPECT_TRUE(axTextfield); | |
| 315 | |
| 316 // Make sure it's the correct accessibility object. | |
| 317 id value = | |
| 318 [axTextfield accessibilityAttributeValue:NSAccessibilityValueAttribute]; | |
| 319 EXPECT_NSEQ(kTestStringValue, value); | |
| 320 | |
| 321 // Write a new NSAccessibilityValueAttribute. | |
| 322 EXPECT_TRUE([axTextfield | |
| 323 accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]); | |
| 324 [axTextfield accessibilitySetValue:kTestPlaceholderText | |
| 325 forAttribute:NSAccessibilityValueAttribute]; | |
| 326 EXPECT_NSEQ(kTestPlaceholderText, | |
| 327 AttributeValueAtMidpoint(NSAccessibilityValueAttribute)); | |
| 328 EXPECT_EQ(base::SysNSStringToUTF16(kTestPlaceholderText), textfield->text()); | |
| 329 | |
| 330 // Test a read-only textfield. | |
| 331 textfield->SetReadOnly(true); | |
| 332 EXPECT_FALSE([axTextfield | |
| 333 accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]); | |
| 334 [axTextfield accessibilitySetValue:kTestStringValue | |
| 335 forAttribute:NSAccessibilityValueAttribute]; | |
|
tapted
2016/08/12 03:50:52
nit: align colons
Patti Lor
2016/08/12 05:16:54
Done.
| |
| 336 EXPECT_NSEQ(kTestPlaceholderText, | |
| 337 AttributeValueAtMidpoint(NSAccessibilityValueAttribute)); | |
| 338 EXPECT_EQ(base::SysNSStringToUTF16(kTestPlaceholderText), textfield->text()); | |
| 339 } | |
| 340 | |
| 307 } // namespace views | 341 } // namespace views |
| OLD | NEW |