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

Side by Side Diff: ui/views/widget/native_widget_mac_accessibility_unittest.mm

Issue 2230093002: MacViews a11y: Allow accessibility clients to set the AXValue on some controls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't say attributes are settable until implemented. Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « ui/views/accessibility/native_view_accessibility_auralinux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ax_node = [widget()->GetNativeWindow() accessibilityHitTest:midpoint];
314 EXPECT_TRUE(ax_node);
315
316 // Make sure it's the correct accessibility object.
317 id value =
318 [ax_node accessibilityAttributeValue:NSAccessibilityValueAttribute];
319 EXPECT_NSEQ(kTestStringValue, value);
320
321 // Write a new NSAccessibilityValueAttribute.
322 EXPECT_TRUE(
323 [ax_node accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]);
324 [ax_node 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(
333 [ax_node accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]);
334 [ax_node accessibilitySetValue:kTestStringValue
335 forAttribute:NSAccessibilityValueAttribute];
336 EXPECT_NSEQ(kTestPlaceholderText,
337 AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
338 EXPECT_EQ(base::SysNSStringToUTF16(kTestPlaceholderText), textfield->text());
339 }
340
307 } // namespace views 341 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/accessibility/native_view_accessibility_auralinux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698