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

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: Rebase again. 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 #include "base/location.h" 9 #include "base/location.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 565
566 // Moving to the third view (but remaining in the content area) should also 566 // Moving to the third view (but remaining in the content area) should also
567 // forward to the native NSWindow implementation. 567 // forward to the native NSWindow implementation.
568 event_generator.MoveMouseTo(gfx::Point(250, 50)); 568 event_generator.MoveMouseTo(gfx::Point(250, 50));
569 [widget->GetNativeWindow() cursorUpdate:event_in_content]; 569 [widget->GetNativeWindow() cursorUpdate:event_in_content];
570 EXPECT_EQ(arrow, [NSCursor currentCursor]); 570 EXPECT_EQ(arrow, [NSCursor currentCursor]);
571 571
572 widget->CloseNow(); 572 widget->CloseNow();
573 } 573 }
574 574
575 // Tests that an accessibility request from the system makes its way through to
576 // a views::Label filling the window.
577 TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
tapted 2016/06/17 03:32:49 NativeWidgetMacAccessibilityTest doesn't add a tes
Patti Lor 2016/06/17 05:57:36 Done.
578 Widget* widget = CreateTopLevelPlatformWidget();
579 gfx::Rect screen_rect(50, 50, 100, 100);
580 widget->SetBounds(screen_rect);
581
582 const base::string16 test_string = base::ASCIIToUTF16("Green");
583 views::Label* label = new views::Label(test_string);
584 label->SetBounds(0, 0, 100, 100);
585 widget->GetContentsView()->AddChildView(label);
586 widget->Show();
587
588 // Accessibility hit tests come in Cocoa screen coordinates.
589 NSRect nsrect = gfx::ScreenRectToNSRect(screen_rect);
590 NSPoint midpoint = NSMakePoint(NSMidX(nsrect), NSMidY(nsrect));
591
592 id hit = [widget->GetNativeWindow() accessibilityHitTest:midpoint];
593 id title = [hit accessibilityAttributeValue:NSAccessibilityTitleAttribute];
594 EXPECT_NSEQ(title, @"Green");
595
596 widget->CloseNow();
597 }
598
599 // Tests creating a views::Widget parented off a native NSWindow. 575 // Tests creating a views::Widget parented off a native NSWindow.
600 TEST_F(NativeWidgetMacTest, NonWidgetParent) { 576 TEST_F(NativeWidgetMacTest, NonWidgetParent) {
601 NSWindow* native_parent = MakeNativeParent(); 577 NSWindow* native_parent = MakeNativeParent();
602 578
603 base::scoped_nsobject<NSView> anchor_view( 579 base::scoped_nsobject<NSView> anchor_view(
604 [[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]); 580 [[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]);
605 [[native_parent contentView] addSubview:anchor_view]; 581 [[native_parent contentView] addSubview:anchor_view];
606 582
607 // Note: Don't use WidgetTest::CreateChildPlatformWidget because that makes 583 // Note: Don't use WidgetTest::CreateChildPlatformWidget because that makes
608 // windows of TYPE_CONTROL which need a parent Widget to obtain the focus 584 // windows of TYPE_CONTROL which need a parent Widget to obtain the focus
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 1628
1653 - (void)dealloc { 1629 - (void)dealloc {
1654 if (deallocFlag_) { 1630 if (deallocFlag_) {
1655 DCHECK(!*deallocFlag_); 1631 DCHECK(!*deallocFlag_);
1656 *deallocFlag_ = true; 1632 *deallocFlag_ = true;
1657 } 1633 }
1658 [super dealloc]; 1634 [super dealloc];
1659 } 1635 }
1660 1636
1661 @end 1637 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698