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

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

Issue 2016243002: Mac a11y: Add RoleDescription and Value attributes to accessibility information. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TODO for comparing against Cocoa. Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/views/widget/native_widget_mac.h" 5 #import "ui/views/widget/native_widget_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #import "base/mac/foundation_util.h" 9 #import "base/mac/foundation_util.h"
10 #import "base/mac/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 554
555 // Moving to the third view (but remaining in the content area) should also 555 // Moving to the third view (but remaining in the content area) should also
556 // forward to the native NSWindow implementation. 556 // forward to the native NSWindow implementation.
557 event_generator.MoveMouseTo(gfx::Point(250, 50)); 557 event_generator.MoveMouseTo(gfx::Point(250, 50));
558 [widget->GetNativeWindow() cursorUpdate:event_in_content]; 558 [widget->GetNativeWindow() cursorUpdate:event_in_content];
559 EXPECT_EQ(arrow, [NSCursor currentCursor]); 559 EXPECT_EQ(arrow, [NSCursor currentCursor]);
560 560
561 widget->CloseNow(); 561 widget->CloseNow();
562 } 562 }
563 563
564 // Tests that an accessibility request from the system makes its way through to
565 // a views::Label filling the window.
566 TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
567 Widget* widget = CreateTopLevelPlatformWidget();
568 gfx::Rect screen_rect(50, 50, 100, 100);
569 widget->SetBounds(screen_rect);
570
571 const base::string16 test_string = base::ASCIIToUTF16("Green");
572 views::Label* label = new views::Label(test_string);
573 label->SetBounds(0, 0, 100, 100);
574 widget->GetContentsView()->AddChildView(label);
575 widget->Show();
576
577 // Accessibility hit tests come in Cocoa screen coordinates.
578 NSRect nsrect = gfx::ScreenRectToNSRect(screen_rect);
579 NSPoint midpoint = NSMakePoint(NSMidX(nsrect), NSMidY(nsrect));
580
581 id hit = [widget->GetNativeWindow() accessibilityHitTest:midpoint];
582 id title = [hit accessibilityAttributeValue:NSAccessibilityTitleAttribute];
583 EXPECT_NSEQ(title, @"Green");
584
585 widget->CloseNow();
586 }
587
588 // Tests creating a views::Widget parented off a native NSWindow. 564 // Tests creating a views::Widget parented off a native NSWindow.
589 TEST_F(NativeWidgetMacTest, NonWidgetParent) { 565 TEST_F(NativeWidgetMacTest, NonWidgetParent) {
590 NSWindow* native_parent = MakeNativeParent(); 566 NSWindow* native_parent = MakeNativeParent();
591 567
592 base::scoped_nsobject<NSView> anchor_view( 568 base::scoped_nsobject<NSView> anchor_view(
593 [[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]); 569 [[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]);
594 [[native_parent contentView] addSubview:anchor_view]; 570 [[native_parent contentView] addSubview:anchor_view];
595 571
596 // Note: Don't use WidgetTest::CreateChildPlatformWidget because that makes 572 // Note: Don't use WidgetTest::CreateChildPlatformWidget because that makes
597 // windows of TYPE_CONTROL which need a parent Widget to obtain the focus 573 // windows of TYPE_CONTROL which need a parent Widget to obtain the focus
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 lastDirtyRect_ = dirtyRect; 1561 lastDirtyRect_ = dirtyRect;
1586 } 1562 }
1587 1563
1588 @end 1564 @end
1589 1565
1590 @implementation FocusableTestNSView 1566 @implementation FocusableTestNSView
1591 - (BOOL)acceptsFirstResponder { 1567 - (BOOL)acceptsFirstResponder {
1592 return YES; 1568 return YES;
1593 } 1569 }
1594 @end 1570 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698