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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h"
11 #import "testing/gtest_mac.h"
10 #import "ui/events/test/cocoa_test_event_utils.h" 12 #import "ui/events/test/cocoa_test_event_utils.h"
11 #include "ui/events/test/event_generator.h" 13 #include "ui/events/test/event_generator.h"
14 #import "ui/gfx/mac/coordinate_conversion.h"
15 #include "ui/views/controls/label.h"
12 #include "ui/views/native_cursor.h" 16 #include "ui/views/native_cursor.h"
13 #include "ui/views/test/test_widget_observer.h" 17 #include "ui/views/test/test_widget_observer.h"
14 #include "ui/views/test/widget_test.h" 18 #include "ui/views/test/widget_test.h"
15 19
16 namespace views { 20 namespace views {
17 namespace test { 21 namespace test {
18 22
19 // Tests for parts of NativeWidgetMac not covered by BridgedNativeWidget, which 23 // Tests for parts of NativeWidgetMac not covered by BridgedNativeWidget, which
20 // need access to Cocoa APIs. 24 // need access to Cocoa APIs.
21 typedef WidgetTest NativeWidgetMacTest; 25 typedef WidgetTest NativeWidgetMacTest;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 334
331 // Moving to the third view (but remaining in the content area) should also 335 // Moving to the third view (but remaining in the content area) should also
332 // forward to the native NSWindow implementation. 336 // forward to the native NSWindow implementation.
333 event_generator.MoveMouseTo(gfx::Point(250, 50)); 337 event_generator.MoveMouseTo(gfx::Point(250, 50));
334 [widget->GetNativeWindow() cursorUpdate:event_in_content]; 338 [widget->GetNativeWindow() cursorUpdate:event_in_content];
335 EXPECT_EQ(arrow, [NSCursor currentCursor]); 339 EXPECT_EQ(arrow, [NSCursor currentCursor]);
336 340
337 widget->CloseNow(); 341 widget->CloseNow();
338 } 342 }
339 343
344 // Tests that an accessibility request from the system makes its way through to
345 // a views::Label filling the window.
346 TEST_F(NativeWidgetMacTest, AccessibilityIntegration) {
347 Widget* widget = CreateTopLevelPlatformWidget();
348 gfx::Rect screen_rect(50, 50, 100, 100);
349 widget->SetBounds(screen_rect);
350
351 const base::string16 test_string = base::ASCIIToUTF16("Green");
352 views::Label* label = new views::Label(test_string);
353 label->SetBounds(0, 0, 100, 100);
354 widget->GetContentsView()->AddChildView(label);
355 widget->Show();
356
357 // Accessibility hit tests come in Cocoa screen coordinates.
358 NSRect nsrect = gfx::ScreenRectToNSRect(screen_rect);
359 NSPoint midpoint = NSMakePoint(NSMidX(nsrect), NSMidY(nsrect));
360
361 id hit = [widget->GetNativeWindow() accessibilityHitTest:midpoint];
362 id title = [hit accessibilityAttributeValue:NSAccessibilityTitleAttribute];
363 EXPECT_NSEQ(title, @"Green");
364 }
365
340 } // namespace test 366 } // namespace test
341 } // namespace views 367 } // namespace views
OLDNEW
« 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