| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 button_->SetFocusBehavior(View::FocusBehavior::ALWAYS); | 94 button_->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
| 95 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView()); | 95 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView()); |
| 96 EXPECT_EQ(nullptr, button_accessibility_->GetFocus()); | 96 EXPECT_EQ(nullptr, button_accessibility_->GetFocus()); |
| 97 EXPECT_TRUE(button_accessibility_->SetFocused(true)); | 97 EXPECT_TRUE(button_accessibility_->SetFocused(true)); |
| 98 EXPECT_EQ(button_, button_->GetFocusManager()->GetFocusedView()); | 98 EXPECT_EQ(button_, button_->GetFocusManager()->GetFocusedView()); |
| 99 EXPECT_EQ(button_->GetNativeViewAccessible(), | 99 EXPECT_EQ(button_->GetNativeViewAccessible(), |
| 100 button_accessibility_->GetFocus()); | 100 button_accessibility_->GetFocus()); |
| 101 EXPECT_TRUE(button_accessibility_->SetFocused(false)); | 101 EXPECT_TRUE(button_accessibility_->SetFocused(false)); |
| 102 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView()); | 102 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView()); |
| 103 EXPECT_EQ(nullptr, button_accessibility_->GetFocus()); | 103 EXPECT_EQ(nullptr, button_accessibility_->GetFocus()); |
| 104 |
| 105 // If not focusable at all, SetFocused() should return false. |
| 106 button_->SetEnabled(false); |
| 107 EXPECT_FALSE(button_accessibility_->SetFocused(true)); |
| 104 } | 108 } |
| 105 | 109 |
| 106 // Subclass of NativeViewAccessibility that destroys itself when its | 110 // Subclass of NativeViewAccessibility that destroys itself when its |
| 107 // parent widget is destroyed, for the purposes of making sure this | 111 // parent widget is destroyed, for the purposes of making sure this |
| 108 // doesn't lead to a crash. | 112 // doesn't lead to a crash. |
| 109 class TestNativeViewAccessibility : public NativeViewAccessibility { | 113 class TestNativeViewAccessibility : public NativeViewAccessibility { |
| 110 public: | 114 public: |
| 111 explicit TestNativeViewAccessibility(View* view) | 115 explicit TestNativeViewAccessibility(View* view) |
| 112 : NativeViewAccessibility(view) {} | 116 : NativeViewAccessibility(view) {} |
| 113 | 117 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 134 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass | 138 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass |
| 135 // defined above that destroys itself when its parent widget is destroyed. | 139 // defined above that destroys itself when its parent widget is destroyed. |
| 136 TestNativeViewAccessibility* child_accessible = | 140 TestNativeViewAccessibility* child_accessible = |
| 137 new TestNativeViewAccessibility(child_widget->GetRootView()); | 141 new TestNativeViewAccessibility(child_widget->GetRootView()); |
| 138 child_accessible->SetParentWidget(parent_widget.get()); | 142 child_accessible->SetParentWidget(parent_widget.get()); |
| 139 parent_widget.reset(); | 143 parent_widget.reset(); |
| 140 } | 144 } |
| 141 | 145 |
| 142 } // namespace test | 146 } // namespace test |
| 143 } // namespace views | 147 } // namespace views |
| OLD | NEW |