OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/accessibility/ax_tree.h" | 5 #include "ui/accessibility/ax_tree.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 tree.Unserialize(initial_state); | 620 tree.Unserialize(initial_state); |
621 } | 621 } |
622 | 622 |
623 TEST(AXTreeTest, RoleAndStateChangeCallbacks) { | 623 TEST(AXTreeTest, RoleAndStateChangeCallbacks) { |
624 AXTreeUpdate initial_state; | 624 AXTreeUpdate initial_state; |
625 initial_state.root_id = 1; | 625 initial_state.root_id = 1; |
626 initial_state.nodes.resize(1); | 626 initial_state.nodes.resize(1); |
627 initial_state.nodes[0].id = 1; | 627 initial_state.nodes[0].id = 1; |
628 initial_state.nodes[0].role = AX_ROLE_BUTTON; | 628 initial_state.nodes[0].role = AX_ROLE_BUTTON; |
629 initial_state.nodes[0].state = 0; | 629 initial_state.nodes[0].state = 0; |
630 initial_state.nodes[0].AddStateFlag(AX_STATE_CHECKED); | 630 initial_state.nodes[0].AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, |
| 631 ui::AX_CHECKED_STATE_TRUE); |
631 initial_state.nodes[0].AddStateFlag(AX_STATE_FOCUSABLE); | 632 initial_state.nodes[0].AddStateFlag(AX_STATE_FOCUSABLE); |
632 AXTree tree(initial_state); | 633 AXTree tree(initial_state); |
633 | 634 |
634 FakeAXTreeDelegate fake_delegate; | 635 FakeAXTreeDelegate fake_delegate; |
635 tree.SetDelegate(&fake_delegate); | 636 tree.SetDelegate(&fake_delegate); |
636 | 637 |
637 // Change the role and state. | 638 // Change the role and state. |
638 AXTreeUpdate update; | 639 AXTreeUpdate update; |
639 update.root_id = 1; | 640 update.root_id = 1; |
640 update.nodes.resize(1); | 641 update.nodes.resize(1); |
641 update.nodes[0].id = 1; | 642 update.nodes[0].id = 1; |
642 update.nodes[0].role = AX_ROLE_CHECK_BOX; | 643 update.nodes[0].role = AX_ROLE_CHECK_BOX; |
643 update.nodes[0].state = 0; | 644 update.nodes[0].state = 0; |
| 645 update.nodes[0].AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, |
| 646 ui::AX_CHECKED_STATE_FALSE); |
644 update.nodes[0].AddStateFlag(AX_STATE_FOCUSABLE); | 647 update.nodes[0].AddStateFlag(AX_STATE_FOCUSABLE); |
645 update.nodes[0].AddStateFlag(AX_STATE_VISITED); | 648 update.nodes[0].AddStateFlag(AX_STATE_VISITED); |
646 EXPECT_TRUE(tree.Unserialize(update)); | 649 EXPECT_TRUE(tree.Unserialize(update)); |
647 | 650 |
648 const std::vector<std::string>& change_log = | 651 const std::vector<std::string>& change_log = |
649 fake_delegate.attribute_change_log(); | 652 fake_delegate.attribute_change_log(); |
650 ASSERT_EQ(3U, change_log.size()); | 653 ASSERT_EQ(3U, change_log.size()); |
651 EXPECT_EQ("Role changed from button to checkBox", change_log[0]); | 654 EXPECT_EQ("Role changed from button to checkBox", change_log[0]); |
652 EXPECT_EQ("checked changed to false", change_log[1]); | 655 EXPECT_EQ("visited changed to true", change_log[1]); |
653 EXPECT_EQ("visited changed to true", change_log[2]); | 656 EXPECT_EQ("checkedState changed from 2 to 1", change_log[2]); |
654 | 657 |
655 tree.SetDelegate(NULL); | 658 tree.SetDelegate(NULL); |
656 } | 659 } |
657 | 660 |
658 TEST(AXTreeTest, AttributeChangeCallbacks) { | 661 TEST(AXTreeTest, AttributeChangeCallbacks) { |
659 AXTreeUpdate initial_state; | 662 AXTreeUpdate initial_state; |
660 initial_state.root_id = 1; | 663 initial_state.root_id = 1; |
661 initial_state.nodes.resize(1); | 664 initial_state.nodes.resize(1); |
662 initial_state.nodes[0].id = 1; | 665 initial_state.nodes[0].id = 1; |
663 initial_state.nodes[0].AddStringAttribute(AX_ATTR_NAME, "N1"); | 666 initial_state.nodes[0].AddStringAttribute(AX_ATTR_NAME, "N1"); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 fake_delegate2.attribute_change_log(); | 790 fake_delegate2.attribute_change_log(); |
788 ASSERT_EQ(3U, change_log2.size()); | 791 ASSERT_EQ(3U, change_log2.size()); |
789 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]); | 792 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]); |
790 EXPECT_EQ("detailsIds changed from 3 to 2,2", change_log2[1]); | 793 EXPECT_EQ("detailsIds changed from 3 to 2,2", change_log2[1]); |
791 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]); | 794 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]); |
792 | 795 |
793 tree.SetDelegate(NULL); | 796 tree.SetDelegate(NULL); |
794 } | 797 } |
795 | 798 |
796 } // namespace ui | 799 } // namespace ui |
OLD | NEW |