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

Side by Side 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: Review comments. Created 4 years, 1 month 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
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 // Test a read-only textfield. 330 // Test a read-only textfield.
331 textfield->SetReadOnly(true); 331 textfield->SetReadOnly(true);
332 EXPECT_FALSE( 332 EXPECT_FALSE(
333 [ax_node accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]); 333 [ax_node accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]);
334 [ax_node accessibilitySetValue:kTestStringValue 334 [ax_node accessibilitySetValue:kTestStringValue
335 forAttribute:NSAccessibilityValueAttribute]; 335 forAttribute:NSAccessibilityValueAttribute];
336 EXPECT_NSEQ(kTestPlaceholderText, 336 EXPECT_NSEQ(kTestPlaceholderText,
337 AttributeValueAtMidpoint(NSAccessibilityValueAttribute)); 337 AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
338 EXPECT_EQ(base::SysNSStringToUTF16(kTestPlaceholderText), textfield->text()); 338 EXPECT_EQ(base::SysNSStringToUTF16(kTestPlaceholderText), textfield->text());
339 textfield->SetReadOnly(false);
340
341 // Change the selection text when there is no selected text.
342 textfield->SelectRange(gfx::Range(0, 0));
343 EXPECT_TRUE([ax_node
344 accessibilityIsAttributeSettable:NSAccessibilitySelectedTextAttribute]);
345
346 NSString* new_string =
347 [kTestStringValue stringByAppendingString:kTestPlaceholderText];
348 [ax_node accessibilitySetValue:kTestStringValue
349 forAttribute:NSAccessibilitySelectedTextAttribute];
350 EXPECT_NSEQ(new_string,
351 AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
352 EXPECT_EQ(base::SysNSStringToUTF16(new_string), textfield->text());
353
354 // Replace entire selection.
355 gfx::Range test_range(0, [new_string length]);
356 textfield->SelectRange(test_range);
357 [ax_node accessibilitySetValue:kTestStringValue
358 forAttribute:NSAccessibilitySelectedTextAttribute];
359 EXPECT_NSEQ(kTestStringValue,
360 AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
361 EXPECT_EQ(base::SysNSStringToUTF16(kTestStringValue), textfield->text());
362
363 // Replace a section only.
dmazzoni 2016/10/26 04:26:02 It'd be nice to try replacing something in the mid
Patti Lor 2016/10/27 00:38:48 Done.
364 test_range = gfx::Range(5, [kTestStringValue length]);
365 new_string = [[kTestStringValue substringWithRange:NSMakeRange(0, 5)]
366 stringByAppendingString:kTestPlaceholderText];
367 textfield->SelectRange(test_range);
368 [ax_node accessibilitySetValue:kTestPlaceholderText
369 forAttribute:NSAccessibilitySelectedTextAttribute];
370 EXPECT_NSEQ(new_string,
371 AttributeValueAtMidpoint(NSAccessibilityValueAttribute));
372 EXPECT_EQ(base::SysNSStringToUTF16(new_string), textfield->text());
339 } 373 }
340 374
341 } // namespace views 375 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698