7#include "gtest/gtest.h"
17void MakeTable(AXNodeData*
table,
int id,
int row_count,
int col_count) {
24void MakeRowGroup(AXNodeData* row_group,
int id) {
29void MakeRow(AXNodeData* row,
int id,
int row_index) {
35void MakeCell(AXNodeData* cell,
53void MakeColumnHeader(AXNodeData* cell,
59 MakeCell(cell,
id, row_index, col_index, row_span, col_span);
63void MakeRowHeader(AXNodeData* cell,
69 MakeCell(cell,
id, row_index, col_index, row_span, col_span);
77#define EXPECT_OPTIONAL_EQ(expected, actual) \
78 EXPECT_TRUE(actual.has_value()); \
80 EXPECT_EQ(expected, actual.value()); \
90 return tree->GetTableInfo(node);
102 initial_state.
nodes.resize(8);
103 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
104 initial_state.
nodes[0].child_ids = {888, 3};
106 MakeRowGroup(&initial_state.
nodes[1], 888);
107 initial_state.
nodes[1].child_ids = {2};
109 MakeRow(&initial_state.
nodes[2], 2, 0);
110 initial_state.
nodes[2].child_ids = {4, 5};
112 MakeRow(&initial_state.
nodes[3], 3, 1);
113 initial_state.
nodes[3].child_ids = {6, 7};
114 MakeColumnHeader(&initial_state.
nodes[4], 4, 0, 0);
115 MakeColumnHeader(&initial_state.
nodes[5], 5, 0, 1);
116 MakeCell(&initial_state.
nodes[6], 6, 1, 0);
117 MakeCell(&initial_state.
nodes[7], 7, 1, 1);
118 AXTree tree(initial_state);
125 EXPECT_FALSE(table_info);
127 table_info = GetTableInfo(&tree, tree.
root());
143 EXPECT_EQ(4, table_info->
cell_ids[0][0]);
144 EXPECT_EQ(5, table_info->
cell_ids[0][1]);
145 EXPECT_EQ(6, table_info->
cell_ids[1][0]);
146 EXPECT_EQ(7, table_info->
cell_ids[1][1]);
159 EXPECT_EQ(2u, table_info->
row_nodes.size());
160 EXPECT_EQ(2, table_info->
row_nodes[0]->data().id);
161 EXPECT_EQ(3, table_info->
row_nodes[1]->data().id);
171 EXPECT_FALSE(
table->IsTableRow());
172 EXPECT_FALSE(
table->IsTableCellOrHeader());
176 ASSERT_TRUE(
table->GetTableCellFromCoords(0, 0));
177 EXPECT_EQ(4,
table->GetTableCellFromCoords(0, 0)->id());
178 EXPECT_EQ(5,
table->GetTableCellFromCoords(0, 1)->id());
179 EXPECT_EQ(6,
table->GetTableCellFromCoords(1, 0)->id());
180 EXPECT_EQ(7,
table->GetTableCellFromCoords(1, 1)->id());
181 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(2, 1));
182 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(1, -1));
184 EXPECT_EQ(4,
table->GetTableCellFromIndex(0)->id());
185 EXPECT_EQ(5,
table->GetTableCellFromIndex(1)->id());
186 EXPECT_EQ(6,
table->GetTableCellFromIndex(2)->id());
187 EXPECT_EQ(7,
table->GetTableCellFromIndex(3)->id());
188 EXPECT_EQ(
nullptr,
table->GetTableCellFromIndex(-1));
189 EXPECT_EQ(
nullptr,
table->GetTableCellFromIndex(4));
192 EXPECT_FALSE(row_0->
IsTable());
198 EXPECT_FALSE(row_1->
IsTable());
204 EXPECT_FALSE(cell_0_0->
IsTable());
214 EXPECT_FALSE(cell_1_1->
IsTable());
222 std::vector<AXNode*> col_headers;
224 EXPECT_EQ(1U, col_headers.size());
225 EXPECT_EQ(5, col_headers[0]->
id());
227 std::vector<AXNode*> row_headers;
229 EXPECT_EQ(0
U, row_headers.size());
231 EXPECT_EQ(2u,
table->GetTableRowNodeIds().size());
232 EXPECT_EQ(2,
table->GetTableRowNodeIds()[0]);
233 EXPECT_EQ(3,
table->GetTableRowNodeIds()[1]);
253 initial_state.
nodes.resize(7);
254 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
255 initial_state.
nodes[0].child_ids = {2, 3};
256 MakeRow(&initial_state.
nodes[1], 2, 0);
257 initial_state.
nodes[1].child_ids = {4, 5};
258 MakeRow(&initial_state.
nodes[2], 3, 1);
259 initial_state.
nodes[2].child_ids = {6, 7};
260 MakeCell(&initial_state.
nodes[3], 4, 0, 0);
261 MakeCell(&initial_state.
nodes[4], 5, 0, 1, 1, 5);
262 MakeCell(&initial_state.
nodes[5], 6, 1, 0);
263 MakeCell(&initial_state.
nodes[6], 7, 1, 1, 3, 1);
264 AXTree tree(initial_state);
270 EXPECT_EQ(2u, table_info->
row_nodes.size());
271 EXPECT_EQ(2, table_info->
row_nodes[0]->data().id);
272 EXPECT_EQ(3, table_info->
row_nodes[1]->data().id);
280 initial_state.
nodes.resize(3);
281 MakeTable(&initial_state.
nodes[0], 1, 8, 9);
282 initial_state.
nodes[0].child_ids = {2};
283 MakeRow(&initial_state.
nodes[1], 2, 0);
284 initial_state.
nodes[1].child_ids = {3};
285 MakeCell(&initial_state.
nodes[2], 3, 0, 1);
286 AXTree tree(initial_state);
292 EXPECT_EQ(1u, table_info->
row_nodes.size());
293 EXPECT_EQ(2, table_info->
row_nodes[0]->data().id);
300 initial_state.
nodes.resize(3);
301 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
302 initial_state.
nodes[0].child_ids = {2};
303 MakeRow(&initial_state.
nodes[1], 2, 0);
304 initial_state.
nodes[1].child_ids = {3};
305 MakeCell(&initial_state.
nodes[2], 3, 0, 0);
306 AXTree tree(initial_state);
314 EXPECT_EQ(table_info, table_info_2);
318 MakeCell(&
update.nodes[2], 3, 0, 0, 1, 2);
325 EXPECT_EQ(1u, table_info->
row_nodes.size());
326 EXPECT_EQ(2, table_info->
row_nodes[0]->data().id);
339 initial_state.
nodes.resize(6);
340 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
341 initial_state.
nodes[0].child_ids = {2, 3};
342 MakeRow(&initial_state.
nodes[1], 2, 0);
343 initial_state.
nodes[1].child_ids = {4, 5};
344 MakeRow(&initial_state.
nodes[2], 3, 1);
345 initial_state.
nodes[2].child_ids = {6};
346 MakeCell(&initial_state.
nodes[3], 4, 0, 0, 2, 1);
347 MakeCell(&initial_state.
nodes[4], 5, 0, 1, 1, 5);
348 MakeCell(&initial_state.
nodes[5], 6, 1, 1);
349 AXTree tree(initial_state);
352 EXPECT_EQ(4, table_info->
cell_ids[0][0]);
353 EXPECT_EQ(5, table_info->
cell_ids[0][1]);
354 EXPECT_EQ(5, table_info->
cell_ids[0][1]);
355 EXPECT_EQ(4, table_info->
cell_ids[1][0]);
356 EXPECT_EQ(6, table_info->
cell_ids[1][1]);
357 EXPECT_EQ(0, table_info->
cell_ids[1][2]);
368 EXPECT_EQ(2u, table_info->
row_nodes.size());
369 EXPECT_EQ(2, table_info->
row_nodes[0]->data().id);
370 EXPECT_EQ(3, table_info->
row_nodes[1]->data().id);
390 initial_state.
nodes.resize(10);
391 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
392 initial_state.
nodes[0].child_ids = {2, 7};
393 MakeRow(&initial_state.
nodes[1], 2, 0);
394 initial_state.
nodes[1].child_ids = {3};
395 initial_state.
nodes[2].id = 3;
397 initial_state.
nodes[2].child_ids = {4, 6};
398 initial_state.
nodes[3].id = 4;
400 initial_state.
nodes[3].child_ids = {5};
401 MakeCell(&initial_state.
nodes[4], 5, 0, 0);
402 MakeCell(&initial_state.
nodes[5], 6, 0, 1);
403 initial_state.
nodes[6].id = 7;
405 initial_state.
nodes[6].child_ids = {8};
406 MakeRow(&initial_state.
nodes[7], 8, 1);
407 initial_state.
nodes[7].child_ids = {9, 10};
408 MakeCell(&initial_state.
nodes[8], 9, 1, 0);
409 MakeCell(&initial_state.
nodes[9], 10, 1, 1);
410 AXTree tree(initial_state);
413 EXPECT_FALSE(table_info);
415 table_info = GetTableInfo(&tree, tree.
root());
421 EXPECT_EQ(5, table_info->
cell_ids[0][0]);
422 EXPECT_EQ(6, table_info->
cell_ids[0][1]);
423 EXPECT_EQ(9, table_info->
cell_ids[1][0]);
424 EXPECT_EQ(10, table_info->
cell_ids[1][1]);
426 EXPECT_EQ(2u, table_info->
row_nodes.size());
427 EXPECT_EQ(2, table_info->
row_nodes[0]->data().id);
428 EXPECT_EQ(8, table_info->
row_nodes[1]->data().id);
444 initial_state.
nodes.resize(8);
445 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
446 initial_state.
nodes[0].child_ids = {2, 3, 4};
447 MakeRow(&initial_state.
nodes[1], 2, 0);
448 initial_state.
nodes[1].child_ids = {5};
449 MakeRow(&initial_state.
nodes[2], 3, 1);
450 initial_state.
nodes[2].child_ids = {6, 7};
451 MakeRow(&initial_state.
nodes[3], 4, 2);
452 initial_state.
nodes[3].child_ids = {8};
453 MakeColumnHeader(&initial_state.
nodes[4], 5, 0, 1, 1, 2);
454 MakeRowHeader(&initial_state.
nodes[5], 6, 1, 0, 2, 1);
455 MakeCell(&initial_state.
nodes[6], 7, 1, 1);
456 MakeCell(&initial_state.
nodes[7], 8, 2, 2);
457 AXTree tree(initial_state);
460 EXPECT_FALSE(table_info);
462 table_info = GetTableInfo(&tree, tree.
root());
479 EXPECT_EQ(0, table_info->
cell_ids[0][0]);
480 EXPECT_EQ(5, table_info->
cell_ids[0][1]);
481 EXPECT_EQ(5, table_info->
cell_ids[0][2]);
482 EXPECT_EQ(6, table_info->
cell_ids[1][0]);
483 EXPECT_EQ(7, table_info->
cell_ids[1][1]);
484 EXPECT_EQ(0, table_info->
cell_ids[1][2]);
485 EXPECT_EQ(6, table_info->
cell_ids[2][0]);
486 EXPECT_EQ(0, table_info->
cell_ids[2][1]);
487 EXPECT_EQ(8, table_info->
cell_ids[2][2]);
489 EXPECT_EQ(3u, table_info->
row_nodes.size());
490 EXPECT_EQ(2, table_info->
row_nodes[0]->data().id);
491 EXPECT_EQ(3, table_info->
row_nodes[1]->data().id);
492 EXPECT_EQ(4, table_info->
row_nodes[2]->data().id);
500 initial_state.
nodes.resize(7);
501 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
502 initial_state.
nodes[0].child_ids = {2, 3};
503 MakeRow(&initial_state.
nodes[1], 2, 0);
504 initial_state.
nodes[1].child_ids = {4, 5};
505 MakeRow(&initial_state.
nodes[2], 3, 1);
506 initial_state.
nodes[2].child_ids = {6, 7};
507 MakeColumnHeader(&initial_state.
nodes[3], 4, 0, 0);
508 MakeColumnHeader(&initial_state.
nodes[4], 5, 0, 1);
509 MakeCell(&initial_state.
nodes[5], 6, 1, 0);
510 MakeCell(&initial_state.
nodes[6], 7, 1, 1);
511 AXTree tree(initial_state);
515 EXPECT_FALSE(table_info);
517 table_info = GetTableInfo(&tree, tree.
root());
529 EXPECT_EQ(2U, table_info->
extra_mac_nodes[0]->GetUnignoredIndexInParent());
532 std::vector<int32_t> indirect_child_ids;
535 &indirect_child_ids));
536 EXPECT_EQ(2U, indirect_child_ids.size());
537 EXPECT_EQ(4, indirect_child_ids[0]);
538 EXPECT_EQ(6, indirect_child_ids[1]);
546 EXPECT_EQ(3U, table_info->
extra_mac_nodes[1]->GetUnignoredIndexInParent());
549 indirect_child_ids.clear();
552 &indirect_child_ids));
553 EXPECT_EQ(2U, indirect_child_ids.size());
554 EXPECT_EQ(5, indirect_child_ids[0]);
555 EXPECT_EQ(7, indirect_child_ids[1]);
563 EXPECT_EQ(4U, table_info->
extra_mac_nodes[2]->GetUnignoredIndexInParent());
564 indirect_child_ids.clear();
567 &indirect_child_ids));
568 EXPECT_EQ(2U, indirect_child_ids.size());
569 EXPECT_EQ(4, indirect_child_ids[0]);
570 EXPECT_EQ(5, indirect_child_ids[1]);
576 initial_state.
nodes.resize(7);
577 initial_state.
nodes[0].id = 1;
579 initial_state.
nodes[0].child_ids = {2, 3};
580 initial_state.
nodes[1].id = 2;
582 initial_state.
nodes[1].child_ids = {4, 5};
583 initial_state.
nodes[2].id = 3;
585 initial_state.
nodes[2].child_ids = {6, 7};
586 initial_state.
nodes[3].id = 4;
588 initial_state.
nodes[4].id = 5;
590 initial_state.
nodes[5].id = 6;
592 initial_state.
nodes[6].id = 7;
595 AXTree tree(initial_state);
599 EXPECT_FALSE(
table->IsTableRow());
600 EXPECT_FALSE(
table->IsTableCellOrHeader());
601 EXPECT_EQ(2,
table->GetTableColCount());
602 EXPECT_EQ(2,
table->GetTableRowCount());
604 EXPECT_EQ(2u,
table->GetTableRowNodeIds().size());
605 EXPECT_EQ(2,
table->GetTableRowNodeIds()[0]);
606 EXPECT_EQ(3,
table->GetTableRowNodeIds()[1]);
608 EXPECT_EQ(4,
table->GetTableCellFromCoords(0, 0)->id());
609 EXPECT_EQ(5,
table->GetTableCellFromCoords(0, 1)->id());
610 EXPECT_EQ(6,
table->GetTableCellFromCoords(1, 0)->id());
611 EXPECT_EQ(7,
table->GetTableCellFromCoords(1, 1)->id());
612 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(2, 1));
613 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(1, -1));
615 EXPECT_EQ(4,
table->GetTableCellFromIndex(0)->id());
616 EXPECT_EQ(5,
table->GetTableCellFromIndex(1)->id());
617 EXPECT_EQ(6,
table->GetTableCellFromIndex(2)->id());
618 EXPECT_EQ(7,
table->GetTableCellFromIndex(3)->id());
619 EXPECT_EQ(
nullptr,
table->GetTableCellFromIndex(-1));
620 EXPECT_EQ(
nullptr,
table->GetTableCellFromIndex(4));
640 initial_state.
nodes.resize(7);
641 initial_state.
nodes[0].id = 1;
643 initial_state.
nodes[0].child_ids = {2, 3};
644 initial_state.
nodes[1].id = 2;
646 initial_state.
nodes[1].child_ids = {4, 5};
647 initial_state.
nodes[2].id = 3;
649 initial_state.
nodes[2].child_ids = {6, 7};
650 initial_state.
nodes[3].id = 4;
652 initial_state.
nodes[4].id = 5;
654 initial_state.
nodes[5].id = 6;
656 initial_state.
nodes[6].id = 7;
659 AXTree tree(initial_state);
662 EXPECT_EQ(2,
table->GetTableColCount());
663 EXPECT_EQ(2,
table->GetTableRowCount());
684 update.nodes[5].AddIntAttribute(
688 update.nodes[6].AddIntAttribute(
694 EXPECT_EQ(5,
table->GetTableColCount());
698 EXPECT_EQ(3,
table->GetTableRowCount());
700 EXPECT_EQ(2u,
table->GetTableRowNodeIds().size());
701 EXPECT_EQ(2,
table->GetTableRowNodeIds()[0]);
702 EXPECT_EQ(3,
table->GetTableRowNodeIds()[1]);
716 EXPECT_EQ(4,
table->GetTableCellFromCoords(0, 0)->id());
717 EXPECT_EQ(5,
table->GetTableCellFromCoords(0, 1)->id());
718 EXPECT_EQ(6,
table->GetTableCellFromCoords(2, 0)->id());
719 EXPECT_EQ(7,
table->GetTableCellFromCoords(2, 2)->id());
720 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(0, 2));
721 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(1, 0));
722 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(1, 1));
723 EXPECT_EQ(
nullptr,
table->GetTableCellFromCoords(2, 1));
736 initial_state.
nodes.resize(7);
737 MakeTable(&initial_state.
nodes[0], 1, 2, 2);
738 initial_state.
nodes[0].child_ids = {2, 3};
739 MakeRow(&initial_state.
nodes[1], 2, 0);
740 initial_state.
nodes[1].child_ids = {4, 5};
741 MakeRow(&initial_state.
nodes[2], 3, 0);
742 initial_state.
nodes[2].child_ids = {6, 7};
743 MakeCell(&initial_state.
nodes[3], 4, 2, 0);
744 MakeCell(&initial_state.
nodes[4], 5, 2, 1);
745 MakeCell(&initial_state.
nodes[5], 6, 2, 0);
746 MakeCell(&initial_state.
nodes[6], 7, 2, 1);
747 AXTree tree(initial_state);
750 EXPECT_EQ(2,
table->GetTableColCount());
751 EXPECT_EQ(4,
table->GetTableRowCount());
753 EXPECT_EQ(2u,
table->GetTableRowNodeIds().size());
754 EXPECT_EQ(2,
table->GetTableRowNodeIds()[0]);
755 EXPECT_EQ(3,
table->GetTableRowNodeIds()[1]);
777 initial_state.
nodes.resize(7);
778 MakeTable(&initial_state.
nodes[0], 1, 2, 2);
779 initial_state.
nodes[0].child_ids = {2, 3};
780 MakeRow(&initial_state.
nodes[1], 2, 0);
781 initial_state.
nodes[1].child_ids = {4, 5};
782 MakeRow(&initial_state.
nodes[2], 3, 0);
783 initial_state.
nodes[2].child_ids = {6, 7};
784 MakeCell(&initial_state.
nodes[3], 4, 0, 1);
785 MakeCell(&initial_state.
nodes[4], 5, 0, 1);
786 MakeCell(&initial_state.
nodes[5], 6, 1, 2);
787 MakeCell(&initial_state.
nodes[6], 7, 1, 1);
788 AXTree tree(initial_state);
791 EXPECT_EQ(4,
table->GetTableColCount());
792 EXPECT_EQ(2,
table->GetTableRowCount());
794 EXPECT_EQ(2u,
table->GetTableRowNodeIds().size());
795 EXPECT_EQ(2,
table->GetTableRowNodeIds()[0]);
796 EXPECT_EQ(3,
table->GetTableRowNodeIds()[1]);
817 initial_state.
nodes.resize(13);
818 MakeTable(&initial_state.
nodes[0], 1, 3, 3);
821 initial_state.
nodes[0].AddIntAttribute(
823 initial_state.
nodes[0].child_ids = {2, 3, 4};
824 MakeRow(&initial_state.
nodes[1], 2, 0);
825 initial_state.
nodes[1].child_ids = {5, 6, 7};
826 MakeRow(&initial_state.
nodes[2], 3, 1);
827 initial_state.
nodes[2].AddIntAttribute(
829 initial_state.
nodes[2].child_ids = {8, 9, 10};
830 MakeRow(&initial_state.
nodes[3], 4, 2);
831 initial_state.
nodes[3].AddIntAttribute(
833 initial_state.
nodes[3].child_ids = {11, 12, 13};
834 MakeCell(&initial_state.
nodes[4], 5, 0, 0);
835 initial_state.
nodes[4].AddIntAttribute(
837 initial_state.
nodes[4].AddIntAttribute(
839 MakeCell(&initial_state.
nodes[5], 6, 0, 1);
840 MakeCell(&initial_state.
nodes[6], 7, 0, 2);
841 MakeCell(&initial_state.
nodes[7], 8, 1, 0);
842 MakeCell(&initial_state.
nodes[8], 9, 1, 1);
843 MakeCell(&initial_state.
nodes[9], 10, 1, 2);
844 MakeCell(&initial_state.
nodes[10], 11, 2, 0);
845 initial_state.
nodes[10].AddIntAttribute(
847 MakeCell(&initial_state.
nodes[11], 12, 2, 1);
848 initial_state.
nodes[11].AddIntAttribute(
850 MakeCell(&initial_state.
nodes[12], 13, 2, 2);
851 initial_state.
nodes[12].AddIntAttribute(
853 AXTree tree(initial_state);
856 EXPECT_EQ(5,
table->GetTableAriaColCount());
857 EXPECT_EQ(5,
table->GetTableAriaRowCount());
859 EXPECT_EQ(3u,
table->GetTableRowNodeIds().size());
860 EXPECT_EQ(2,
table->GetTableRowNodeIds()[0]);
861 EXPECT_EQ(3,
table->GetTableRowNodeIds()[1]);
862 EXPECT_EQ(4,
table->GetTableRowNodeIds()[2]);
916 initial_state.
nodes.resize(4);
917 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
918 initial_state.
nodes[0].child_ids = {2};
919 MakeRow(&initial_state.
nodes[1], 2, 0);
920 initial_state.
nodes[1].child_ids = {3, 4};
921 MakeCell(&initial_state.
nodes[2], 3, 0, 0);
922 MakeCell(&initial_state.
nodes[3], 4, 0, 1);
923 AXTree tree(initial_state);
936 table_info = GetTableInfo(&tree, tree.
root());
937 EXPECT_FALSE(table_info);
945 initial_state.
nodes.resize(7);
946 MakeTable(&initial_state.
nodes[0], 1, 0, 0);
947 initial_state.
nodes[0].child_ids = {2, 3};
948 MakeRow(&initial_state.
nodes[1], 2, 0);
949 initial_state.
nodes[1].child_ids = {4, 5};
950 MakeRow(&initial_state.
nodes[2], 3, 1);
951 initial_state.
nodes[2].child_ids = {6, 7};
952 MakeColumnHeader(&initial_state.
nodes[3], 4, 0, 0);
953 MakeColumnHeader(&initial_state.
nodes[4], 5, 0, 1);
954 MakeCell(&initial_state.
nodes[5], 6, 1, 0);
955 MakeCell(&initial_state.
nodes[6], 7, 1, 1);
956 AXTree tree(initial_state);
960 ASSERT_NE(
nullptr, table_info);
967 update1.
nodes.resize(1);
968 MakeRow(&update1.
nodes[0], 2, 0);
970 update1.
nodes[0].child_ids = {4, 5};
972 table_info = GetTableInfo(&tree, tree.
root());
982 EXPECT_EQ(3U, table_info->
extra_mac_nodes[0]->GetUnignoredIndexInParent());
985 std::vector<int32_t> indirect_child_ids;
988 &indirect_child_ids));
989 EXPECT_EQ(1U, indirect_child_ids.size());
990 EXPECT_EQ(6, indirect_child_ids[0]);
998 EXPECT_EQ(4U, table_info->
extra_mac_nodes[1]->GetUnignoredIndexInParent());
1001 indirect_child_ids.clear();
1004 &indirect_child_ids));
1005 EXPECT_EQ(1U, indirect_child_ids.size());
1006 EXPECT_EQ(7, indirect_child_ids[0]);
1014 EXPECT_EQ(5U, table_info->
extra_mac_nodes[2]->GetUnignoredIndexInParent());
1015 indirect_child_ids.clear();
1018 &indirect_child_ids));
1019 EXPECT_EQ(0
U, indirect_child_ids.size());
1026 update2.
nodes.resize(1);
1027 MakeTable(&update2.
nodes[0], 1, 0, 0);
1028 update2.
nodes[0].child_ids = {3};
1030 table_info = GetTableInfo(&tree, tree.
root());
1040 EXPECT_EQ(1U, table_info->
extra_mac_nodes[0]->GetUnignoredIndexInParent());
1043 std::vector<int32_t> indirect_child_ids;
1046 &indirect_child_ids));
1047 EXPECT_EQ(1U, indirect_child_ids.size());
1048 EXPECT_EQ(6, indirect_child_ids[0]);
1056 EXPECT_EQ(2U, table_info->
extra_mac_nodes[1]->GetUnignoredIndexInParent());
1059 indirect_child_ids.clear();
1062 &indirect_child_ids));
1063 EXPECT_EQ(1U, indirect_child_ids.size());
1064 EXPECT_EQ(7, indirect_child_ids[0]);
1072 EXPECT_EQ(3U, table_info->
extra_mac_nodes[2]->GetUnignoredIndexInParent());
1073 indirect_child_ids.clear();
1076 &indirect_child_ids));
1077 EXPECT_EQ(0
U, indirect_child_ids.size());
1086 MakeTable(&
update.nodes[0], 1, 0, 0);
1087 update.nodes[0].child_ids = {2};
1088 MakeRow(&
update.nodes[1], 2, 0);
1089 update.nodes[1].child_ids = {3, 10};
1090 MakeCell(&
update.nodes[2], 3, 0, 0);
1091 MakeCell(&
update.nodes[3], 10, 0, 1);
1095 ASSERT_TRUE(table_info);
1100 EXPECT_EQ(
"|3 |10|\n", table_info->
ToString());
1104 update.nodes[0].child_ids = {2, 4};
1105 MakeRow(&
update.nodes[4], 4, 0);
1106 update.nodes[4].child_ids = {5};
1107 MakeCell(&
update.nodes[5], 5, -1, -1);
1111 table_info = GetTableInfo(&tree, tree.
root());
1112 ASSERT_TRUE(table_info);
1123 update.nodes[0].child_ids = {2, 6, 4};
1124 MakeRow(&
update.nodes[1], 6, 0);
1125 update.nodes[1].child_ids = {7};
1126 MakeCell(&
update.nodes[2], 7, -1, -1, 1, 2);
1130 table_info = GetTableInfo(&tree, tree.
root());
1131 ASSERT_TRUE(table_info);
1143 update.nodes[0].child_ids = {2, 6, 4, 8};
1144 MakeRow(&
update.nodes[1], 8, 0);
1145 update.nodes[1].child_ids = {9};
1146 MakeCell(&
update.nodes[2], 9, -1, -1, 2, 3);
1150 table_info = GetTableInfo(&tree, tree.
root());
1151 ASSERT_TRUE(table_info);
1164 update.nodes[0].child_ids = {6, 8};
1168 table_info = GetTableInfo(&tree, tree.
root());
1169 ASSERT_TRUE(table_info);
#define EXPECT_OPTIONAL_EQ(expected, actual)
std::optional< int > GetTableCellIndex() const
std::optional< int > GetTableCellRowIndex() const
bool IsTableCellOrHeader() const
std::optional< int > GetTableCellAriaColIndex() const
std::optional< int > GetTableRowRowIndex() const
void GetTableCellColHeaders(std::vector< AXNode * > *col_headers) const
std::vector< AXNode::AXID > GetTableRowNodeIds() const
std::optional< int > GetTableCellAriaRowIndex() const
const std::vector< AXNode * > & children() const
void GetTableCellRowHeaders(std::vector< AXNode * > *row_headers) const
std::optional< int > GetTableCellColSpan() const
std::optional< int > GetTableCellRowSpan() const
std::optional< int > GetTableCellColIndex() const
~AXTableInfoTest() override
AXTableInfo * GetTableInfo(AXTree *tree, AXNode *node)
std::vector< std::vector< int32_t > > col_headers
std::vector< std::vector< int32_t > > cell_ids
std::vector< AXNode * > extra_mac_nodes
std::unordered_map< int32_t, size_t > cell_id_to_index
std::vector< AXNode * > row_nodes
std::string ToString() const
std::vector< std::vector< int32_t > > row_headers
std::vector< int32_t > unique_cell_ids
virtual bool Unserialize(const AXTreeUpdate &update)
AXNode * GetFromId(int32_t id) const override
void SetEnableExtraMacNodes(bool enabled)
TEST_F(AXPositionTest, Clone)
const std::vector< int32_t > & GetIntListAttribute(ax::mojom::IntListAttribute attribute) const
int GetIntAttribute(ax::mojom::IntAttribute attribute) const
std::vector< AXNodeData > nodes
#define EXPECT_TRUE(handle)