Index: ui/views/widget/native_widget_mac_unittest.mm |
diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm |
index 7593f985fc20d650fb38e0bb51c00b8e92263ee0..af715a15d7deeff67abb15607e163927b1d9cea7 100644 |
--- a/ui/views/widget/native_widget_mac_unittest.mm |
+++ b/ui/views/widget/native_widget_mac_unittest.mm |
@@ -7,8 +7,12 @@ |
#import <Cocoa/Cocoa.h> |
#include "base/run_loop.h" |
+#include "base/strings/utf_string_conversions.h" |
+#import "testing/gtest_mac.h" |
#import "ui/events/test/cocoa_test_event_utils.h" |
#include "ui/events/test/event_generator.h" |
+#import "ui/gfx/mac/coordinate_conversion.h" |
+#include "ui/views/controls/label.h" |
#include "ui/views/native_cursor.h" |
#include "ui/views/test/test_widget_observer.h" |
#include "ui/views/test/widget_test.h" |
@@ -337,5 +341,27 @@ TEST_F(NativeWidgetMacTest, SetCursor) { |
widget->CloseNow(); |
} |
+// Tests that an accessibility request from the system makes its way through to |
+// a views::Label filling the window. |
+TEST_F(NativeWidgetMacTest, AccessibilityIntegration) { |
+ Widget* widget = CreateTopLevelPlatformWidget(); |
+ gfx::Rect screen_rect(50, 50, 100, 100); |
+ widget->SetBounds(screen_rect); |
+ |
+ const base::string16 test_string = base::ASCIIToUTF16("Green"); |
+ views::Label* label = new views::Label(test_string); |
+ label->SetBounds(0, 0, 100, 100); |
+ widget->GetContentsView()->AddChildView(label); |
+ widget->Show(); |
+ |
+ // Accessibility hit tests come in Cocoa screen coordinates. |
+ NSRect nsrect = gfx::ScreenRectToNSRect(screen_rect); |
+ NSPoint midpoint = NSMakePoint(NSMidX(nsrect), NSMidY(nsrect)); |
+ |
+ id hit = [widget->GetNativeWindow() accessibilityHitTest:midpoint]; |
+ id title = [hit accessibilityAttributeValue:NSAccessibilityTitleAttribute]; |
+ EXPECT_NSEQ(title, @"Green"); |
+} |
+ |
} // namespace test |
} // namespace views |