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

Unified Diff: ui/views/widget/native_widget_mac_unittest.mm

Issue 976403004: MacViews: Fix accessibility hit tests, provide AXTitle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150303-MacViews-Disable-Touch-Tests
Patch Set: tweak comments Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698