[go: nahoru, domu]

blob: e7072fae56b9b7c87e21f01e4a84390ad474df75 [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2018 The Chromium Authors
Nektarios Paisiosbe87bc42018-10-12 23:47:032// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ui/accessibility/ax_node_data.h"
6
Nektarios Paisios31e51882020-05-05 22:17:127#include <set>
Lei Zhang998100f2021-06-25 17:58:198#include <string>
9#include <unordered_set>
10#include <utility>
Nektarios Paisios31e51882020-05-05 22:17:1211
Jan Wilken Dörrie721926d2020-12-09 23:57:4712#include "base/containers/contains.h"
Joanmarie Diggs762303d2022-08-09 10:56:5713#include "base/test/gtest_util.h"
Nektarios Paisiosbe87bc42018-10-12 23:47:0314#include "testing/gtest/include/gtest/gtest.h"
Ian Preste1c32992019-12-04 19:53:1315#include "ui/accessibility/ax_enum_util.h"
Nektarios Paisiosbe87bc42018-10-12 23:47:0316#include "ui/accessibility/ax_enums.mojom.h"
Ian Preste1c32992019-12-04 19:53:1317#include "ui/accessibility/ax_role_properties.h"
Nektarios Paisios70b6a5e2021-08-03 05:32:3618#include "ui/accessibility/ax_text_attributes.h"
Nektarios Paisiosbe87bc42018-10-12 23:47:0319
20namespace ui {
21
22TEST(AXNodeDataTest, GetAndSetCheckedState) {
23 AXNodeData root;
24 EXPECT_EQ(ax::mojom::CheckedState::kNone, root.GetCheckedState());
25 EXPECT_FALSE(root.HasIntAttribute(ax::mojom::IntAttribute::kCheckedState));
26
27 root.SetCheckedState(ax::mojom::CheckedState::kMixed);
28 EXPECT_EQ(ax::mojom::CheckedState::kMixed, root.GetCheckedState());
29 EXPECT_TRUE(root.HasIntAttribute(ax::mojom::IntAttribute::kCheckedState));
30
31 root.SetCheckedState(ax::mojom::CheckedState::kFalse);
32 EXPECT_EQ(ax::mojom::CheckedState::kFalse, root.GetCheckedState());
33 EXPECT_TRUE(root.HasIntAttribute(ax::mojom::IntAttribute::kCheckedState));
34
35 root.SetCheckedState(ax::mojom::CheckedState::kNone);
36 EXPECT_EQ(ax::mojom::CheckedState::kNone, root.GetCheckedState());
37 EXPECT_FALSE(root.HasIntAttribute(ax::mojom::IntAttribute::kCheckedState));
38}
39
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5640TEST(AXNodeDataTest, TextAttributes) {
41 AXNodeData node_1;
42 node_1.AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize, 1.5);
43
44 AXNodeData node_2;
45 node_2.AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize, 1.5);
Nektarios Paisios70b6a5e2021-08-03 05:32:3646 EXPECT_TRUE(node_1.GetTextAttributes() == node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5647
48 node_2.AddIntAttribute(ax::mojom::IntAttribute::kColor, 100);
Nektarios Paisios70b6a5e2021-08-03 05:32:3649 EXPECT_TRUE(node_1.GetTextAttributes() != node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5650
51 node_1.AddIntAttribute(ax::mojom::IntAttribute::kColor, 100);
Nektarios Paisios70b6a5e2021-08-03 05:32:3652 EXPECT_TRUE(node_1.GetTextAttributes() == node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5653
54 node_2.RemoveIntAttribute(ax::mojom::IntAttribute::kColor);
Nektarios Paisios70b6a5e2021-08-03 05:32:3655 EXPECT_TRUE(node_1.GetTextAttributes() != node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5656
57 node_2.AddIntAttribute(ax::mojom::IntAttribute::kColor, 100);
Nektarios Paisios70b6a5e2021-08-03 05:32:3658 EXPECT_TRUE(node_1.GetTextAttributes() == node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5659
60 node_1.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily,
61 "test font");
Nektarios Paisios70b6a5e2021-08-03 05:32:3662 EXPECT_TRUE(node_1.GetTextAttributes() != node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5663
64 node_2.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily,
65 "test font");
Nektarios Paisios70b6a5e2021-08-03 05:32:3666 EXPECT_TRUE(node_1.GetTextAttributes() == node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5667
68 node_2.RemoveStringAttribute(ax::mojom::StringAttribute::kFontFamily);
Nektarios Paisios70b6a5e2021-08-03 05:32:3669 EXPECT_TRUE(node_1.GetTextAttributes() != node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5670
71 node_2.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily,
72 "test font");
Nektarios Paisios70b6a5e2021-08-03 05:32:3673 EXPECT_TRUE(node_1.GetTextAttributes() == node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5674
75 node_2.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily,
76 "different font");
Nektarios Paisios70b6a5e2021-08-03 05:32:3677 EXPECT_TRUE(node_1.GetTextAttributes() != node_2.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5678
Sara Katoe38f905a2019-10-17 01:25:0079 std::string tooltip;
80 node_2.AddStringAttribute(ax::mojom::StringAttribute::kTooltip,
81 "test tooltip");
82 EXPECT_TRUE(node_2.GetStringAttribute(ax::mojom::StringAttribute::kTooltip,
83 &tooltip));
84 EXPECT_EQ(tooltip, "test tooltip");
85
Nektarios Paisios70b6a5e2021-08-03 05:32:3686 AXTextAttributes node1_attributes = node_1.GetTextAttributes();
87 AXTextAttributes moved_attributes = std::move(node1_attributes);
88 EXPECT_TRUE(node1_attributes != moved_attributes);
89 EXPECT_TRUE(moved_attributes == node_1.GetTextAttributes());
Kurt Catti-Schmidtf738bce2019-05-08 01:06:5690}
91
Victor Fei4f5aa7d2020-04-09 03:15:5092TEST(AXNodeDataTest, IsButtonPressed) {
93 // A non-button element with CheckedState::kTrue should not return true for
94 // IsButtonPressed.
95 AXNodeData non_button_pressed;
96 non_button_pressed.role = ax::mojom::Role::kGenericContainer;
97 non_button_pressed.SetCheckedState(ax::mojom::CheckedState::kTrue);
98 EXPECT_FALSE(IsButton(non_button_pressed.role));
99 EXPECT_FALSE(non_button_pressed.IsButtonPressed());
100
101 // A button element with CheckedState::kTrue should return true for
102 // IsButtonPressed.
103 AXNodeData button_pressed;
104 button_pressed.role = ax::mojom::Role::kButton;
105 button_pressed.SetCheckedState(ax::mojom::CheckedState::kTrue);
106 EXPECT_TRUE(IsButton(button_pressed.role));
107 EXPECT_TRUE(button_pressed.IsButtonPressed());
108
109 button_pressed.role = ax::mojom::Role::kPopUpButton;
110 EXPECT_TRUE(IsButton(button_pressed.role));
111 EXPECT_TRUE(button_pressed.IsButtonPressed());
112
113 button_pressed.role = ax::mojom::Role::kToggleButton;
114 EXPECT_TRUE(IsButton(button_pressed.role));
115 EXPECT_TRUE(button_pressed.IsButtonPressed());
116
117 // A button element does not have CheckedState::kTrue should return false for
118 // IsButtonPressed.
119 AXNodeData button_not_pressed;
120 button_not_pressed.role = ax::mojom::Role::kButton;
121 button_not_pressed.SetCheckedState(ax::mojom::CheckedState::kNone);
122 EXPECT_TRUE(IsButton(button_not_pressed.role));
123 EXPECT_FALSE(button_not_pressed.IsButtonPressed());
124
125 button_not_pressed.role = ax::mojom::Role::kPopUpButton;
126 button_not_pressed.SetCheckedState(ax::mojom::CheckedState::kFalse);
127 EXPECT_TRUE(IsButton(button_not_pressed.role));
128 EXPECT_FALSE(button_not_pressed.IsButtonPressed());
129
130 button_not_pressed.role = ax::mojom::Role::kToggleButton;
131 button_not_pressed.SetCheckedState(ax::mojom::CheckedState::kMixed);
132 EXPECT_TRUE(IsButton(button_not_pressed.role));
133 EXPECT_FALSE(button_not_pressed.IsButtonPressed());
134}
135
136TEST(AXNodeDataTest, IsClickable) {
Ian Preste1c32992019-12-04 19:53:13137 // Test for ax node data attribute with a custom default action verb.
138 AXNodeData data_default_action_verb;
139
140 for (int action_verb_idx =
141 static_cast<int>(ax::mojom::DefaultActionVerb::kMinValue);
142 action_verb_idx <=
143 static_cast<int>(ax::mojom::DefaultActionVerb::kMaxValue);
144 action_verb_idx++) {
145 data_default_action_verb.SetDefaultActionVerb(
146 static_cast<ax::mojom::DefaultActionVerb>(action_verb_idx));
147 bool is_clickable = data_default_action_verb.IsClickable();
148
149 SCOPED_TRACE(testing::Message()
150 << "ax::mojom::DefaultActionVerb="
151 << ToString(data_default_action_verb.GetDefaultActionVerb())
152 << ", Actual: isClickable=" << is_clickable
153 << ", Expected: isClickable=" << !is_clickable);
154
155 if (data_default_action_verb.GetDefaultActionVerb() ==
156 ax::mojom::DefaultActionVerb::kClickAncestor ||
157 data_default_action_verb.GetDefaultActionVerb() ==
158 ax::mojom::DefaultActionVerb::kNone)
159 EXPECT_FALSE(is_clickable);
160 else
161 EXPECT_TRUE(is_clickable);
162 }
163
164 // Test for iterating through all roles and validate if a role is clickable.
Nektarios Paisios31e51882020-05-05 22:17:12165 std::set<ax::mojom::Role> roles_expected_is_clickable = {
Ian Preste1c32992019-12-04 19:53:13166 ax::mojom::Role::kButton,
167 ax::mojom::Role::kCheckBox,
168 ax::mojom::Role::kColorWell,
Nektarios Paisios31e51882020-05-05 22:17:12169 ax::mojom::Role::kComboBoxMenuButton,
Daniel Libbya620cff2022-09-15 22:46:22170 ax::mojom::Role::kComboBoxSelect,
Nektarios Paisios31e51882020-05-05 22:17:12171 ax::mojom::Role::kDate,
172 ax::mojom::Role::kDateTime,
Ian Preste1c32992019-12-04 19:53:13173 ax::mojom::Role::kDisclosureTriangle,
174 ax::mojom::Role::kDocBackLink,
175 ax::mojom::Role::kDocBiblioRef,
176 ax::mojom::Role::kDocGlossRef,
177 ax::mojom::Role::kDocNoteRef,
Nektarios Paisios31e51882020-05-05 22:17:12178 ax::mojom::Role::kImeCandidate,
179 ax::mojom::Role::kInputTime,
Ian Preste1c32992019-12-04 19:53:13180 ax::mojom::Role::kLink,
Nektarios Paisios31e51882020-05-05 22:17:12181 ax::mojom::Role::kListBox,
Ian Preste1c32992019-12-04 19:53:13182 ax::mojom::Role::kListBoxOption,
Ian Preste1c32992019-12-04 19:53:13183 ax::mojom::Role::kMenuItem,
184 ax::mojom::Role::kMenuItemCheckBox,
185 ax::mojom::Role::kMenuItemRadio,
186 ax::mojom::Role::kMenuListOption,
Ankit Kumar 🌪️4d5bf202020-01-28 05:30:47187 ax::mojom::Role::kPdfActionableHighlight,
Ian Preste1c32992019-12-04 19:53:13188 ax::mojom::Role::kPopUpButton,
Nektarios Paisios31e51882020-05-05 22:17:12189 ax::mojom::Role::kPortal,
Ian Preste1c32992019-12-04 19:53:13190 ax::mojom::Role::kRadioButton,
Nektarios Paisios31e51882020-05-05 22:17:12191 ax::mojom::Role::kSearchBox,
192 ax::mojom::Role::kSpinButton,
Ian Preste1c32992019-12-04 19:53:13193 ax::mojom::Role::kSwitch,
194 ax::mojom::Role::kTab,
Nektarios Paisios31e51882020-05-05 22:17:12195 ax::mojom::Role::kTextField,
196 ax::mojom::Role::kTextFieldWithComboBox,
Ian Preste1c32992019-12-04 19:53:13197 ax::mojom::Role::kToggleButton};
198
199 AXNodeData data;
200
201 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
202 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
203 data.role = static_cast<ax::mojom::Role>(role_idx);
204 bool is_clickable = data.IsClickable();
205
206 SCOPED_TRACE(testing::Message()
207 << "ax::mojom::Role=" << ToString(data.role)
208 << ", Actual: isClickable=" << is_clickable
209 << ", Expected: isClickable=" << !is_clickable);
210
Nektarios Paisios31e51882020-05-05 22:17:12211 EXPECT_EQ(base::Contains(roles_expected_is_clickable, data.role),
212 is_clickable);
Ian Preste1c32992019-12-04 19:53:13213 }
214}
215
Victor Fei4f5aa7d2020-04-09 03:15:50216TEST(AXNodeDataTest, IsInvocable) {
Ian Preste1c32992019-12-04 19:53:13217 // Test for iterating through all roles and validate if a role is invocable.
Benjamin Beaudry412260d72022-01-14 02:52:36218 // A role is invocable if it is clickable and supports neither expand collapse
219 // nor toggle. A link should always be invocable, regardless of whether it is
220 // clickable or supports expand/collapse or toggle.
Ian Preste1c32992019-12-04 19:53:13221 AXNodeData data;
222 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
223 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
224 data.role = static_cast<ax::mojom::Role>(role_idx);
Nektarios Paisios31e51882020-05-05 22:17:12225 bool is_activatable = data.IsActivatable();
226 const bool supports_expand_collapse = data.SupportsExpandCollapse();
227 const bool supports_toggle = ui::SupportsToggle(data.role);
228 const bool is_clickable = data.IsClickable();
229 const bool is_invocable = data.IsInvocable();
Ian Preste1c32992019-12-04 19:53:13230
231 SCOPED_TRACE(testing::Message()
232 << "ax::mojom::Role=" << ToString(data.role)
Nektarios Paisios31e51882020-05-05 22:17:12233 << ", isClickable=" << is_clickable << ", isActivatable="
234 << is_activatable << ", supportsToggle=" << supports_toggle
Ian Preste1c32992019-12-04 19:53:13235 << ", supportsExpandCollapse=" << supports_expand_collapse
236 << ", Actual: isInvocable=" << is_invocable
237 << ", Expected: isInvocable=" << !is_invocable);
238
Benjamin Beaudry412260d72022-01-14 02:52:36239 if (ui::IsLink(data.role) ||
240 (is_clickable && !is_activatable && !supports_toggle &&
241 !supports_expand_collapse)) {
Ian Preste1c32992019-12-04 19:53:13242 EXPECT_TRUE(is_invocable);
Benjamin Beaudry412260d72022-01-14 02:52:36243 } else {
Ian Preste1c32992019-12-04 19:53:13244 EXPECT_FALSE(is_invocable);
Benjamin Beaudry412260d72022-01-14 02:52:36245 }
Ian Preste1c32992019-12-04 19:53:13246 }
247}
248
Victor Fei4f5aa7d2020-04-09 03:15:50249TEST(AXNodeDataTest, IsMenuButton) {
250 // A non button element should return false for IsMenuButton.
251 AXNodeData non_button;
252 non_button.role = ax::mojom::Role::kGenericContainer;
253 EXPECT_FALSE(IsButton(non_button.role));
254 EXPECT_FALSE(non_button.IsMenuButton());
255
256 // Only button element with HasPopup::kMenu should return true for
257 // IsMenuButton. All other ax::mojom::HasPopup types should return false.
258 AXNodeData button_with_popup;
259
260 button_with_popup.role = ax::mojom::Role::kButton;
261
262 for (int has_popup_idx = static_cast<int>(ax::mojom::HasPopup::kMinValue);
263 has_popup_idx <= static_cast<int>(ax::mojom::HasPopup::kMaxValue);
264 has_popup_idx++) {
265 button_with_popup.SetHasPopup(
266 static_cast<ax::mojom::HasPopup>(has_popup_idx));
267 bool is_menu_button = button_with_popup.IsMenuButton();
268
269 SCOPED_TRACE(testing::Message()
270 << "ax::mojom::Role=" << ToString(button_with_popup.role)
271 << ", hasPopup=" << button_with_popup.GetHasPopup()
272 << ", Actual: isMenuButton=" << is_menu_button
273 << ", Expected: isMenuButton=" << !is_menu_button);
274
275 if (IsButton(button_with_popup.role) &&
276 button_with_popup.GetHasPopup() == ax::mojom::HasPopup::kMenu)
277 EXPECT_TRUE(is_menu_button);
278 else
279 EXPECT_FALSE(is_menu_button);
280 }
281}
282
283TEST(AXNodeDataTest, SupportsExpandCollapse) {
Ian Preste1c32992019-12-04 19:53:13284 // Test for iterating through all hasPopup attributes and validate if a
285 // hasPopup attribute supports expand collapse.
286 AXNodeData data_has_popup;
287
288 for (int has_popup_idx = static_cast<int>(ax::mojom::HasPopup::kMinValue);
289 has_popup_idx <= static_cast<int>(ax::mojom::HasPopup::kMaxValue);
290 has_popup_idx++) {
291 data_has_popup.SetHasPopup(static_cast<ax::mojom::HasPopup>(has_popup_idx));
292 bool supports_expand_collapse = data_has_popup.SupportsExpandCollapse();
293
294 SCOPED_TRACE(testing::Message() << "ax::mojom::HasPopup="
295 << ToString(data_has_popup.GetHasPopup())
296 << ", Actual: supportsExpandCollapse="
297 << supports_expand_collapse
298 << ", Expected: supportsExpandCollapse="
299 << !supports_expand_collapse);
300
301 if (data_has_popup.GetHasPopup() == ax::mojom::HasPopup::kFalse)
302 EXPECT_FALSE(supports_expand_collapse);
303 else
304 EXPECT_TRUE(supports_expand_collapse);
305 }
306
307 // Test for iterating through all states and validate if a state supports
308 // expand collapse.
309 AXNodeData data_state;
310
311 for (int state_idx = static_cast<int>(ax::mojom::State::kMinValue);
312 state_idx <= static_cast<int>(ax::mojom::State::kMaxValue);
313 state_idx++) {
314 ax::mojom::State state = static_cast<ax::mojom::State>(state_idx);
315
316 // skipping kNone here because AXNodeData::AddState, RemoveState forbids
317 // kNone to be added/removed and would fail DCHECK.
318 if (state == ax::mojom::State::kNone)
319 continue;
320
321 data_state.AddState(state);
322
323 bool supports_expand_collapse = data_state.SupportsExpandCollapse();
324
325 SCOPED_TRACE(testing::Message() << "ax::mojom::State=" << ToString(state)
326 << ", Actual: supportsExpandCollapse="
327 << supports_expand_collapse
328 << ", Expected: supportsExpandCollapse="
329 << !supports_expand_collapse);
330
331 if (data_state.HasState(ax::mojom::State::kExpanded) ||
332 data_state.HasState(ax::mojom::State::kCollapsed))
333 EXPECT_TRUE(supports_expand_collapse);
334 else
335 EXPECT_FALSE(supports_expand_collapse);
336
337 data_state.RemoveState(state);
338 }
339
340 // Test for iterating through all roles and validate if a role supports expand
341 // collapse.
342 AXNodeData data;
343
344 std::unordered_set<ax::mojom::Role> roles_expected_supports_expand_collapse =
Daniel Libbya620cff2022-09-15 22:46:22345 {ax::mojom::Role::kComboBoxGrouping,
346 ax::mojom::Role::kComboBoxMenuButton,
347 ax::mojom::Role::kComboBoxSelect,
Ian Preste1c32992019-12-04 19:53:13348 ax::mojom::Role::kDisclosureTriangle,
Daniel Libbya620cff2022-09-15 22:46:22349 ax::mojom::Role::kTextFieldWithComboBox,
350 ax::mojom::Role::kTreeItem};
Ian Preste1c32992019-12-04 19:53:13351
352 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
353 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
354 data.role = static_cast<ax::mojom::Role>(role_idx);
355 bool supports_expand_collapse = data.SupportsExpandCollapse();
356
357 SCOPED_TRACE(testing::Message() << "ax::mojom::Role=" << ToString(data.role)
358 << ", Actual: supportsExpandCollapse="
359 << supports_expand_collapse
360 << ", Expected: supportsExpandCollapse="
361 << !supports_expand_collapse);
362
363 if (roles_expected_supports_expand_collapse.find(data.role) !=
364 roles_expected_supports_expand_collapse.end())
365 EXPECT_TRUE(supports_expand_collapse);
366 else
367 EXPECT_FALSE(supports_expand_collapse);
368 }
369}
370
Joanmarie Diggs762303d2022-08-09 10:56:57371TEST(AXNodeDataTest, SetName) {
372 AXNodeData data;
Joanmarie Diggs008ea7c2022-09-12 20:22:34373 // SetName should not be called on a role of kUnknown. That role means the
374 // role has not yet been set, and we need a role to identify the NameFrom on
375 // objects where it has not been set. This is enforced by a DCHECK.
376 EXPECT_DCHECK_DEATH(data.SetName("no role yet"));
377
Joanmarie Diggs762303d2022-08-09 10:56:57378 // SetName should not be called on a role of kNone. That role is used for
379 // presentational objects which should not be included in the accessibility
380 // tree. This is enforced by a DCHECK.
381 data.role = ax::mojom::Role::kNone;
382 EXPECT_DCHECK_DEATH(data.SetName("role is presentational"));
383
384 // For roles other than text, setting the name should result in the NameFrom
385 // source being kAttribute.
386 data.role = ax::mojom::Role::kButton;
387 data.SetName("foo");
388 EXPECT_EQ("foo", data.GetStringAttribute(ax::mojom::StringAttribute::kName));
389 EXPECT_EQ(data.GetNameFrom(), ax::mojom::NameFrom::kAttribute);
390
391 // TODO(accessibility): The static text role should have a NameFrom source of
392 // kContents. But nothing clears the NameFrom if the role of an existing
393 // object changes because currently there is no AXNodeData::SetRole method.
394 data.role = ax::mojom::Role::kStaticText;
395 data.SetName("bar");
396 EXPECT_EQ("bar", data.GetStringAttribute(ax::mojom::StringAttribute::kName));
397 EXPECT_EQ(data.GetNameFrom(), ax::mojom::NameFrom::kAttribute);
398
399 data.RemoveIntAttribute(ax::mojom::IntAttribute::kNameFrom);
400 data.SetName("baz");
401 EXPECT_EQ("baz", data.GetStringAttribute(ax::mojom::StringAttribute::kName));
402 EXPECT_EQ(data.GetNameFrom(), ax::mojom::NameFrom::kContents);
403
404 data.SetNameExplicitlyEmpty();
405 EXPECT_EQ("", data.GetStringAttribute(ax::mojom::StringAttribute::kName));
406 EXPECT_EQ(data.GetNameFrom(), ax::mojom::NameFrom::kAttributeExplicitlyEmpty);
407
408 data.SetName("foo");
409 EXPECT_EQ("foo", data.GetStringAttribute(ax::mojom::StringAttribute::kName));
410 EXPECT_EQ(data.GetNameFrom(), ax::mojom::NameFrom::kContents);
411}
412
Hiroki Satofdb71f412020-02-27 01:18:37413TEST(AXNodeDataTest, BitFieldsSanityCheck) {
414 EXPECT_LT(static_cast<size_t>(ax::mojom::State::kMaxValue),
415 sizeof(AXNodeData::state) * 8);
416 EXPECT_LT(static_cast<size_t>(ax::mojom::Action::kMaxValue),
417 sizeof(AXNodeData::actions) * 8);
418}
419
Nektarios Paisiosbe87bc42018-10-12 23:47:03420} // namespace ui