| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "ui/accessibility/ax_view_state.h" | 6 #include "ui/accessibility/ax_view_state.h" |
| 7 #include "ui/gfx/geometry/rect_conversions.h" |
| 7 #include "ui/views/accessibility/native_view_accessibility.h" | 8 #include "ui/views/accessibility/native_view_accessibility.h" |
| 8 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
| 9 #include "ui/views/controls/label.h" | 10 #include "ui/views/controls/label.h" |
| 10 #include "ui/views/test/views_test_base.h" | 11 #include "ui/views/test/views_test_base.h" |
| 11 | 12 |
| 12 namespace views { | 13 namespace views { |
| 13 namespace test { | 14 namespace test { |
| 14 | 15 |
| 15 class NativeViewAccessibilityTest; | 16 class NativeViewAccessibilityTest; |
| 16 | 17 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 std::unique_ptr<Label> label_; | 54 std::unique_ptr<Label> label_; |
| 54 NativeViewAccessibility* label_accessibility_; | 55 NativeViewAccessibility* label_accessibility_; |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) { | 58 TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) { |
| 58 EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility_->GetData().role); | 59 EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility_->GetData().role); |
| 59 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role); | 60 EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility_->GetData().role); |
| 60 } | 61 } |
| 61 | 62 |
| 62 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { | 63 TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { |
| 63 gfx::Rect bounds = button_accessibility_->GetData().location; | 64 gfx::Rect bounds = gfx::ToEnclosingRect( |
| 65 button_accessibility_->GetData().location); |
| 64 bounds.Offset(button_accessibility_->GetGlobalCoordinateOffset()); | 66 bounds.Offset(button_accessibility_->GetGlobalCoordinateOffset()); |
| 65 EXPECT_EQ(button_->GetBoundsInScreen(), bounds); | 67 EXPECT_EQ(button_->GetBoundsInScreen(), bounds); |
| 66 } | 68 } |
| 67 | 69 |
| 68 TEST_F(NativeViewAccessibilityTest, LabelIsChildOfButton) { | 70 TEST_F(NativeViewAccessibilityTest, LabelIsChildOfButton) { |
| 69 EXPECT_EQ(1, button_accessibility_->GetChildCount()); | 71 EXPECT_EQ(1, button_accessibility_->GetChildCount()); |
| 70 EXPECT_EQ(label_->GetNativeViewAccessible(), | 72 EXPECT_EQ(label_->GetNativeViewAccessible(), |
| 71 button_accessibility_->ChildAtIndex(0)); | 73 button_accessibility_->ChildAtIndex(0)); |
| 72 EXPECT_EQ(button_->GetNativeViewAccessible(), | 74 EXPECT_EQ(button_->GetNativeViewAccessible(), |
| 73 label_accessibility_->GetParent()); | 75 label_accessibility_->GetParent()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 104 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass | 106 // WidgetObserver. Note that TestNativeViewAccessibility is a subclass |
| 105 // defined above that destroys itself when its parent widget is destroyed. | 107 // defined above that destroys itself when its parent widget is destroyed. |
| 106 TestNativeViewAccessibility* child_accessible = | 108 TestNativeViewAccessibility* child_accessible = |
| 107 new TestNativeViewAccessibility(child_widget->GetRootView()); | 109 new TestNativeViewAccessibility(child_widget->GetRootView()); |
| 108 child_accessible->SetParentWidget(parent_widget.get()); | 110 child_accessible->SetParentWidget(parent_widget.get()); |
| 109 parent_widget.reset(); | 111 parent_widget.reset(); |
| 110 } | 112 } |
| 111 | 113 |
| 112 } // namespace test | 114 } // namespace test |
| 113 } // namespace views | 115 } // namespace views |
| OLD | NEW |