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

Side by Side Diff: ui/views/accessibility/native_view_accessibility_unittest.cc

Issue 2119413004: a11y: Exclude children of nested keyboard accessible controls from a11y tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't ignore children if they're accessibility focusable, regardless of enabled state. Created 4 years 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 #include "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "ui/accessibility/ax_node_data.h" 7 #include "ui/accessibility/ax_node_data.h"
8 #include "ui/gfx/geometry/rect_conversions.h" 8 #include "ui/gfx/geometry/rect_conversions.h"
9 #include "ui/views/accessibility/native_view_accessibility.h" 9 #include "ui/views/accessibility/native_view_accessibility.h"
10 #include "ui/views/controls/button/button.h" 10 #include "ui/views/controls/button/button.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 protected: 63 protected:
64 views::Widget* widget_; 64 views::Widget* widget_;
65 TestButton* button_; 65 TestButton* button_;
66 NativeViewAccessibility* button_accessibility_; 66 NativeViewAccessibility* button_accessibility_;
67 Label* label_; 67 Label* label_;
68 NativeViewAccessibility* label_accessibility_; 68 NativeViewAccessibility* label_accessibility_;
69 }; 69 };
70 70
71 TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) { 71 TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) {
72 EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility_->GetData().role); 72 EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility_->GetData().role);
73 #if defined(OS_MACOSX)
74 // Accessibility focusable controls on Mac are always leaf nodes, so to check
75 // the role matches here, make button unfocusable.
76 button_->SetFocusBehavior(View::FocusBehavior::NEVER);
tapted 2016/11/29 03:12:49 We can add // On Mac, the label isn't given a rol
Patti Lor 2016/11/29 23:26:18 Done.
77 #endif
73 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role); 78 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role);
74 } 79 }
75 80
76 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { 81 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) {
77 gfx::Rect bounds = gfx::ToEnclosingRect( 82 gfx::Rect bounds = gfx::ToEnclosingRect(
78 button_accessibility_->GetData().location); 83 button_accessibility_->GetData().location);
79 bounds.Offset(button_accessibility_->GetGlobalCoordinateOffset()); 84 bounds.Offset(button_accessibility_->GetGlobalCoordinateOffset());
80 EXPECT_EQ(button_->GetBoundsInScreen(), bounds); 85 EXPECT_EQ(button_->GetBoundsInScreen(), bounds);
81 } 86 }
82 87
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass 143 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass
139 // defined above that destroys itself when its parent widget is destroyed. 144 // defined above that destroys itself when its parent widget is destroyed.
140 TestNativeViewAccessibility* child_accessible = 145 TestNativeViewAccessibility* child_accessible =
141 new TestNativeViewAccessibility(child_widget->GetRootView()); 146 new TestNativeViewAccessibility(child_widget->GetRootView());
142 child_accessible->SetParentWidget(parent_widget.get()); 147 child_accessible->SetParentWidget(parent_widget.get());
143 parent_widget.reset(); 148 parent_widget.reset();
144 } 149 }
145 150
146 } // namespace test 151 } // namespace test
147 } // namespace views 152 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698