| OLD | NEW |
| 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_nsautorelease_pool.h" | 10 #import "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 // Tests that an accessibility request from the system makes its way through to | 645 // Tests that an accessibility request from the system makes its way through to |
| 646 // a views::Label filling the window. | 646 // a views::Label filling the window. |
| 647 TEST_F(NativeWidgetMacTest, AccessibilityIntegration) { | 647 TEST_F(NativeWidgetMacTest, AccessibilityIntegration) { |
| 648 Widget* widget = CreateTopLevelPlatformWidget(); | 648 Widget* widget = CreateTopLevelPlatformWidget(); |
| 649 gfx::Rect screen_rect(50, 50, 100, 100); | 649 gfx::Rect screen_rect(50, 50, 100, 100); |
| 650 widget->SetBounds(screen_rect); | 650 widget->SetBounds(screen_rect); |
| 651 | 651 |
| 652 const base::string16 test_string = base::ASCIIToUTF16("Green"); | 652 const base::string16 test_string = base::ASCIIToUTF16("Green"); |
| 653 views::Label* label = new views::Label(test_string); | 653 views::Label* label = new views::Label(test_string); |
| 654 label->SetBounds(0, 0, 100, 100); | 654 label->SetBounds(0, 0, 100, 100); |
| 655 label->SetFocusBehavior(ClientView::FocusBehavior::ACCESSIBLE_ONLY); |
| 655 widget->GetContentsView()->AddChildView(label); | 656 widget->GetContentsView()->AddChildView(label); |
| 656 widget->Show(); | 657 widget->Show(); |
| 657 | 658 |
| 658 // Accessibility hit tests come in Cocoa screen coordinates. | 659 // Accessibility hit tests come in Cocoa screen coordinates. |
| 659 NSRect nsrect = gfx::ScreenRectToNSRect(screen_rect); | 660 NSRect nsrect = gfx::ScreenRectToNSRect(screen_rect); |
| 660 NSPoint midpoint = NSMakePoint(NSMidX(nsrect), NSMidY(nsrect)); | 661 NSPoint midpoint = NSMakePoint(NSMidX(nsrect), NSMidY(nsrect)); |
| 661 | 662 |
| 662 id hit = [widget->GetNativeWindow() accessibilityHitTest:midpoint]; | 663 id hit = [widget->GetNativeWindow() accessibilityHitTest:midpoint]; |
| 663 id title = [hit accessibilityAttributeValue:NSAccessibilityTitleAttribute]; | 664 id title = [hit accessibilityAttributeValue:NSAccessibilityTitleAttribute]; |
| 664 EXPECT_NSEQ(title, @"Green"); | 665 EXPECT_NSEQ(@"Green", title); |
| 665 | 666 |
| 666 widget->CloseNow(); | 667 widget->CloseNow(); |
| 667 } | 668 } |
| 668 | 669 |
| 669 // Tests creating a views::Widget parented off a native NSWindow. | 670 // Tests creating a views::Widget parented off a native NSWindow. |
| 670 TEST_F(NativeWidgetMacTest, NonWidgetParent) { | 671 TEST_F(NativeWidgetMacTest, NonWidgetParent) { |
| 671 NSWindow* native_parent = MakeNativeParent(); | 672 NSWindow* native_parent = MakeNativeParent(); |
| 672 | 673 |
| 673 base::scoped_nsobject<NSView> anchor_view( | 674 base::scoped_nsobject<NSView> anchor_view( |
| 674 [[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]); | 675 [[NSView alloc] initWithFrame:[[native_parent contentView] bounds]]); |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 | 1794 |
| 1794 - (void)dealloc { | 1795 - (void)dealloc { |
| 1795 if (deallocFlag_) { | 1796 if (deallocFlag_) { |
| 1796 DCHECK(!*deallocFlag_); | 1797 DCHECK(!*deallocFlag_); |
| 1797 *deallocFlag_ = true; | 1798 *deallocFlag_ = true; |
| 1798 } | 1799 } |
| 1799 [super dealloc]; | 1800 [super dealloc]; |
| 1800 } | 1801 } |
| 1801 | 1802 |
| 1802 @end | 1803 @end |
| OLD | NEW |