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

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

Issue 2894103002: Int and Float properties for Accessibility Object Model phase 1 (Closed)
Patch Set: Update webexposed/ Created 3 years, 7 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"
9 #include "modules/accessibility/AXTableCell.h"
10 #include "modules/accessibility/AXTableRow.h"
8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 11 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
9 #include "web/tests/sim/SimRequest.h" 12 #include "web/tests/sim/SimRequest.h"
10 #include "web/tests/sim/SimTest.h" 13 #include "web/tests/sim/SimTest.h"
11 14
12 namespace blink { 15 namespace blink {
13 16
14 namespace { 17 namespace {
15 18
16 class AccessibilityObjectModelTest 19 class AccessibilityObjectModelTest
17 : public SimTest, 20 : public SimTest,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 button->accessibleNode()->setRole(g_null_atom); 127 button->accessibleNode()->setRole(g_null_atom);
125 button->accessibleNode()->setLabel(g_null_atom); 128 button->accessibleNode()->setLabel(g_null_atom);
126 button->accessibleNode()->setDisabled(false, true); 129 button->accessibleNode()->setDisabled(false, true);
127 130
128 // The AX Object should now revert to ARIA. 131 // The AX Object should now revert to ARIA.
129 EXPECT_EQ(kCheckBoxRole, axButton->RoleValue()); 132 EXPECT_EQ(kCheckBoxRole, axButton->RoleValue());
130 EXPECT_EQ("Check", axButton->GetName(name_from, &name_objects)); 133 EXPECT_EQ("Check", axButton->GetName(name_from, &name_objects));
131 EXPECT_FALSE(axButton->IsEnabled()); 134 EXPECT_FALSE(axButton->IsEnabled());
132 } 135 }
133 136
137 TEST_F(AccessibilityObjectModelTest, RangeProperties) {
138 SimRequest main_resource("https://example.com/", "text/html");
139 LoadURL("https://example.com/");
140 main_resource.Complete("<div role=slider id=slider>");
141
142 auto* slider = GetDocument().getElementById("slider");
143 ASSERT_NE(nullptr, slider);
144 slider->accessibleNode()->setValueMin(-0.5, false);
145 slider->accessibleNode()->setValueMax(0.5, false);
146 slider->accessibleNode()->setValueNow(0.1, false);
147
148 auto* cache = AXObjectCache();
149 ASSERT_NE(nullptr, cache);
150 auto* ax_slider = cache->GetOrCreate(slider);
151 EXPECT_EQ(-0.5f, ax_slider->MinValueForRange());
152 EXPECT_EQ(0.5f, ax_slider->MaxValueForRange());
153 EXPECT_EQ(0.1f, ax_slider->ValueForRange());
154 }
155
156 TEST_F(AccessibilityObjectModelTest, Level) {
157 SimRequest main_resource("https://example.com/", "text/html");
158 LoadURL("https://example.com/");
159 main_resource.Complete("<div role=heading id=heading>");
160
161 auto* heading = GetDocument().getElementById("heading");
162 ASSERT_NE(nullptr, heading);
163 heading->accessibleNode()->setLevel(5, false);
164
165 auto* cache = AXObjectCache();
166 ASSERT_NE(nullptr, cache);
167 auto* ax_heading = cache->GetOrCreate(heading);
168 EXPECT_EQ(5, ax_heading->HeadingLevel());
169 }
170
171 TEST_F(AccessibilityObjectModelTest, ListItem) {
172 SimRequest main_resource("https://example.com/", "text/html");
173 LoadURL("https://example.com/");
174 main_resource.Complete(
175 "<div role=list><div role=listitem id=listitem></div></div>");
176
177 auto* listitem = GetDocument().getElementById("listitem");
178 ASSERT_NE(nullptr, listitem);
179 listitem->accessibleNode()->setPosInSet(9, false);
180 listitem->accessibleNode()->setSetSize(10, false);
181
182 auto* cache = AXObjectCache();
183 ASSERT_NE(nullptr, cache);
184 auto* ax_listitem = cache->GetOrCreate(listitem);
185 EXPECT_EQ(9, ax_listitem->PosInSet());
186 EXPECT_EQ(10, ax_listitem->SetSize());
187 }
188
189 TEST_F(AccessibilityObjectModelTest, Grid) {
190 SimRequest main_resource("https://example.com/", "text/html");
191 LoadURL("https://example.com/");
192 main_resource.Complete(
193 "<div role=grid id=grid>"
194 " <div role=row id=row>"
195 " <div role=gridcell id=cell></div>"
196 " <div role=gridcell id=cell2></div>"
197 " </div>"
198 "</div>");
199
200 auto* grid = GetDocument().getElementById("grid");
201 ASSERT_NE(nullptr, grid);
202 grid->accessibleNode()->setColCount(16, false);
203 grid->accessibleNode()->setRowCount(9, false);
204
205 auto* row = GetDocument().getElementById("row");
206 ASSERT_NE(nullptr, row);
207 row->accessibleNode()->setColIndex(8, false);
208 row->accessibleNode()->setRowIndex(5, false);
209
210 auto* cell = GetDocument().getElementById("cell");
211
212 auto* cell2 = GetDocument().getElementById("cell2");
213 ASSERT_NE(nullptr, cell2);
214 cell2->accessibleNode()->setColIndex(10, false);
215 cell2->accessibleNode()->setRowIndex(7, false);
216
217 auto* cache = AXObjectCache();
218 ASSERT_NE(nullptr, cache);
219
220 auto* ax_grid = static_cast<AXTable*>(cache->GetOrCreate(grid));
221 EXPECT_EQ(16, ax_grid->AriaColumnCount());
222 EXPECT_EQ(9, ax_grid->AriaRowCount());
223
224 auto* ax_cell = static_cast<AXTableCell*>(cache->GetOrCreate(cell));
225 EXPECT_TRUE(ax_cell->IsTableCell());
226 EXPECT_EQ(8U, ax_cell->AriaColumnIndex());
227 EXPECT_EQ(5U, ax_cell->AriaRowIndex());
228
229 auto* ax_cell2 = static_cast<AXTableCell*>(cache->GetOrCreate(cell2));
230 EXPECT_TRUE(ax_cell2->IsTableCell());
231 EXPECT_EQ(10U, ax_cell2->AriaColumnIndex());
232 EXPECT_EQ(7U, ax_cell2->AriaRowIndex());
233 }
234
134 } // namespace 235 } // namespace
135 236
136 } // namespace blink 237 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698