Chromium Code Reviews| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 } | 81 } |
| 82 | 82 |
| 83 TEST_F(NativeViewAccessibilityTest, LabelIsChildOfButton) { | 83 TEST_F(NativeViewAccessibilityTest, LabelIsChildOfButton) { |
| 84 EXPECT_EQ(1, button_accessibility_->GetChildCount()); | 84 EXPECT_EQ(1, button_accessibility_->GetChildCount()); |
| 85 EXPECT_EQ(label_->GetNativeViewAccessible(), | 85 EXPECT_EQ(label_->GetNativeViewAccessible(), |
| 86 button_accessibility_->ChildAtIndex(0)); | 86 button_accessibility_->ChildAtIndex(0)); |
| 87 EXPECT_EQ(button_->GetNativeViewAccessible(), | 87 EXPECT_EQ(button_->GetNativeViewAccessible(), |
| 88 label_accessibility_->GetParent()); | 88 label_accessibility_->GetParent()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(NativeViewAccessibilityTest, InvisibleViews) { | |
|
karandeepb
2016/12/28 10:57:10
Doesn't this first require widget_->Show() or is t
Patti Lor
2016/12/29 00:57:56
It seems to work still even when the widget is inv
karandeepb
2016/12/29 09:36:16
Weird!
| |
| 92 EXPECT_FALSE( | |
| 93 button_accessibility_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); | |
| 94 EXPECT_FALSE( | |
| 95 label_accessibility_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); | |
| 96 button_->SetVisible(false); | |
| 97 EXPECT_TRUE( | |
| 98 button_accessibility_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); | |
| 99 EXPECT_TRUE( | |
|
karandeepb
2016/12/28 10:57:10
I believe this is FALSE currently, which this CL c
Patti Lor
2016/12/29 00:57:56
Yep! Have checked it fails without changes to nati
| |
| 100 label_accessibility_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); | |
| 101 } | |
| 102 | |
| 91 TEST_F(NativeViewAccessibilityTest, WritableFocus) { | 103 TEST_F(NativeViewAccessibilityTest, WritableFocus) { |
| 92 widget_->Show(); | 104 widget_->Show(); |
| 93 // Make |button_| focusable, and focus/unfocus it via NativeViewAccessibility. | 105 // Make |button_| focusable, and focus/unfocus it via NativeViewAccessibility. |
| 94 button_->SetFocusBehavior(View::FocusBehavior::ALWAYS); | 106 button_->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
| 95 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView()); | 107 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView()); |
| 96 EXPECT_EQ(nullptr, button_accessibility_->GetFocus()); | 108 EXPECT_EQ(nullptr, button_accessibility_->GetFocus()); |
| 97 EXPECT_TRUE(button_accessibility_->SetFocused(true)); | 109 EXPECT_TRUE(button_accessibility_->SetFocused(true)); |
| 98 EXPECT_EQ(button_, button_->GetFocusManager()->GetFocusedView()); | 110 EXPECT_EQ(button_, button_->GetFocusManager()->GetFocusedView()); |
| 99 EXPECT_EQ(button_->GetNativeViewAccessible(), | 111 EXPECT_EQ(button_->GetNativeViewAccessible(), |
| 100 button_accessibility_->GetFocus()); | 112 button_accessibility_->GetFocus()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass | 150 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass |
| 139 // defined above that destroys itself when its parent widget is destroyed. | 151 // defined above that destroys itself when its parent widget is destroyed. |
| 140 TestNativeViewAccessibility* child_accessible = | 152 TestNativeViewAccessibility* child_accessible = |
| 141 new TestNativeViewAccessibility(child_widget->GetRootView()); | 153 new TestNativeViewAccessibility(child_widget->GetRootView()); |
| 142 child_accessible->SetParentWidget(parent_widget.get()); | 154 child_accessible->SetParentWidget(parent_widget.get()); |
| 143 parent_widget.reset(); | 155 parent_widget.reset(); |
| 144 } | 156 } |
| 145 | 157 |
| 146 } // namespace test | 158 } // namespace test |
| 147 } // namespace views | 159 } // namespace views |
| OLD | NEW |