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 #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 Loading... | |
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) | |
dmazzoni
2016/11/30 23:12:44
I'm okay with removing this test or rewriting it t
Patti Lor
2016/12/01 01:12:07
Will go ahead and do this if it's decided we'll go
| |
74 // On Mac, the label isn't given a role. Since it's a subview of |button_| | |
75 // (and the button is focusable), the label is assumed to form part of the | |
76 // button and not have a role of its own. | |
77 EXPECT_EQ(ui::AX_ROLE_UNKNOWN, label_accessibility_->GetData().role); | |
78 // This will happen for all potentially keyboard-focusable Views with | |
79 // non-keyboard-focusable children, so if we make the button unfocusable, the | |
80 // label will be allowed to have its own role again. | |
81 button_->SetFocusBehavior(View::FocusBehavior::NEVER); | |
82 #endif | |
73 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role); | 83 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role); |
74 } | 84 } |
75 | 85 |
76 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { | 86 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { |
77 gfx::Rect bounds = gfx::ToEnclosingRect( | 87 gfx::Rect bounds = gfx::ToEnclosingRect( |
78 button_accessibility_->GetData().location); | 88 button_accessibility_->GetData().location); |
79 bounds.Offset(button_accessibility_->GetGlobalCoordinateOffset()); | 89 bounds.Offset(button_accessibility_->GetGlobalCoordinateOffset()); |
80 EXPECT_EQ(button_->GetBoundsInScreen(), bounds); | 90 EXPECT_EQ(button_->GetBoundsInScreen(), bounds); |
81 } | 91 } |
82 | 92 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass | 148 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass |
139 // defined above that destroys itself when its parent widget is destroyed. | 149 // defined above that destroys itself when its parent widget is destroyed. |
140 TestNativeViewAccessibility* child_accessible = | 150 TestNativeViewAccessibility* child_accessible = |
141 new TestNativeViewAccessibility(child_widget->GetRootView()); | 151 new TestNativeViewAccessibility(child_widget->GetRootView()); |
142 child_accessible->SetParentWidget(parent_widget.get()); | 152 child_accessible->SetParentWidget(parent_widget.get()); |
143 parent_widget.reset(); | 153 parent_widget.reset(); |
144 } | 154 } |
145 | 155 |
146 } // namespace test | 156 } // namespace test |
147 } // namespace views | 157 } // namespace views |
OLD | NEW |