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

Side by Side Diff: third_party/WebKit/Source/web/tests/AccessibilityObjectModelTest.cpp

Issue 2907133002: Move WebAXObject.cpp to core/ (WIP) (Closed)
Patch Set: Created 3 years, 6 months 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "core/dom/AccessibleNode.h" 5 #include "core/dom/AccessibleNode.h"
6 #include "core/html/HTMLBodyElement.h" 6 #include "core/html/HTMLBodyElement.h"
7 #include "modules/accessibility/AXObjectCacheImpl.h" 7 #include "modules/accessibility/AXObjectCacheImpl.h"
8 #include "modules/accessibility/AXTable.h" 8 #include "modules/accessibility/AXTable.h"
9 #include "modules/accessibility/AXTableCell.h" 9 #include "modules/accessibility/AXTableCell.h"
10 #include "modules/accessibility/AXTableRow.h" 10 #include "modules/accessibility/AXTableRow.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 textbox->setAttribute("role", "combobox"); 72 textbox->setAttribute("role", "combobox");
73 textbox->setAttribute("aria-label", "Combo"); 73 textbox->setAttribute("aria-label", "Combo");
74 textbox->setAttribute("aria-disabled", "true"); 74 textbox->setAttribute("aria-disabled", "true");
75 75
76 // Assert that the ARIA attributes affect the AX object. 76 // Assert that the ARIA attributes affect the AX object.
77 auto* cache = AXObjectCache(); 77 auto* cache = AXObjectCache();
78 ASSERT_NE(nullptr, cache); 78 ASSERT_NE(nullptr, cache);
79 auto* axTextBox = cache->GetOrCreate(textbox); 79 auto* axTextBox = cache->GetOrCreate(textbox);
80 EXPECT_EQ(kComboBoxRole, axTextBox->RoleValue()); 80 EXPECT_EQ(kComboBoxRole, axTextBox->RoleValue());
81 AXNameFrom name_from; 81 AXNameFrom name_from;
82 AXObjectImpl::AXObjectVector name_objects; 82 AXObjectImpl::AXObjectImplVector name_objects;
83 EXPECT_EQ("Combo", axTextBox->GetName(name_from, &name_objects)); 83 EXPECT_EQ("Combo", axTextBox->GetName(name_from, &name_objects));
84 EXPECT_FALSE(axTextBox->IsEnabled()); 84 EXPECT_FALSE(axTextBox->IsEnabled());
85 85
86 // The AOM properties should still all be null. 86 // The AOM properties should still all be null.
87 EXPECT_EQ(nullptr, textbox->accessibleNode()->role()); 87 EXPECT_EQ(nullptr, textbox->accessibleNode()->role());
88 EXPECT_EQ(nullptr, textbox->accessibleNode()->label()); 88 EXPECT_EQ(nullptr, textbox->accessibleNode()->label());
89 bool is_null = false; 89 bool is_null = false;
90 EXPECT_FALSE(textbox->accessibleNode()->disabled(is_null)); 90 EXPECT_FALSE(textbox->accessibleNode()->disabled(is_null));
91 EXPECT_TRUE(is_null); 91 EXPECT_TRUE(is_null);
92 } 92 }
93 93
94 TEST_F(AccessibilityObjectModelTest, AOMPropertiesCanBeCleared) { 94 TEST_F(AccessibilityObjectModelTest, AOMPropertiesCanBeCleared) {
95 SimRequest main_resource("https://example.com/", "text/html"); 95 SimRequest main_resource("https://example.com/", "text/html");
96 LoadURL("https://example.com/"); 96 LoadURL("https://example.com/");
97 main_resource.Complete("<input type=button id=button>"); 97 main_resource.Complete("<input type=button id=button>");
98 98
99 // Set ARIA attributes. 99 // Set ARIA attributes.
100 auto* button = GetDocument().getElementById("button"); 100 auto* button = GetDocument().getElementById("button");
101 ASSERT_NE(nullptr, button); 101 ASSERT_NE(nullptr, button);
102 button->setAttribute("role", "checkbox"); 102 button->setAttribute("role", "checkbox");
103 button->setAttribute("aria-label", "Check"); 103 button->setAttribute("aria-label", "Check");
104 button->setAttribute("aria-disabled", "true"); 104 button->setAttribute("aria-disabled", "true");
105 105
106 // Assert that the AX object was affected by ARIA attributes. 106 // Assert that the AX object was affected by ARIA attributes.
107 auto* cache = AXObjectCache(); 107 auto* cache = AXObjectCache();
108 ASSERT_NE(nullptr, cache); 108 ASSERT_NE(nullptr, cache);
109 auto* axButton = cache->GetOrCreate(button); 109 auto* axButton = cache->GetOrCreate(button);
110 EXPECT_EQ(kCheckBoxRole, axButton->RoleValue()); 110 EXPECT_EQ(kCheckBoxRole, axButton->RoleValue());
111 AXNameFrom name_from; 111 AXNameFrom name_from;
112 AXObjectImpl::AXObjectVector name_objects; 112 AXObjectImpl::AXObjectImplVector name_objects;
113 EXPECT_EQ("Check", axButton->GetName(name_from, &name_objects)); 113 EXPECT_EQ("Check", axButton->GetName(name_from, &name_objects));
114 EXPECT_FALSE(axButton->IsEnabled()); 114 EXPECT_FALSE(axButton->IsEnabled());
115 115
116 // Now set the AOM properties to override. 116 // Now set the AOM properties to override.
117 button->accessibleNode()->setRole("radio"); 117 button->accessibleNode()->setRole("radio");
118 button->accessibleNode()->setLabel("Radio"); 118 button->accessibleNode()->setLabel("Radio");
119 button->accessibleNode()->setDisabled(false, false); 119 button->accessibleNode()->setDisabled(false, false);
120 120
121 // Assert that the AX object was affected by AOM properties. 121 // Assert that the AX object was affected by AOM properties.
122 EXPECT_EQ(kRadioButtonRole, axButton->RoleValue()); 122 EXPECT_EQ(kRadioButtonRole, axButton->RoleValue());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 auto* ax_cell2 = static_cast<AXTableCell*>(cache->GetOrCreate(cell2)); 229 auto* ax_cell2 = static_cast<AXTableCell*>(cache->GetOrCreate(cell2));
230 EXPECT_TRUE(ax_cell2->IsTableCell()); 230 EXPECT_TRUE(ax_cell2->IsTableCell());
231 EXPECT_EQ(10U, ax_cell2->AriaColumnIndex()); 231 EXPECT_EQ(10U, ax_cell2->AriaColumnIndex());
232 EXPECT_EQ(7U, ax_cell2->AriaRowIndex()); 232 EXPECT_EQ(7U, ax_cell2->AriaRowIndex());
233 } 233 }
234 234
235 } // namespace 235 } // namespace
236 236
237 } // namespace blink 237 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebAXObject.cpp ('k') | third_party/WebKit/public/web/WebAXObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698