| 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 tree.Unserialize(initial_state); | 609 tree.Unserialize(initial_state); |
| 610 } | 610 } |
| 611 | 611 |
| 612 TEST(AXTreeTest, RoleAndStateChangeCallbacks) { | 612 TEST(AXTreeTest, RoleAndStateChangeCallbacks) { |
| 613 AXTreeUpdate initial_state; | 613 AXTreeUpdate initial_state; |
| 614 initial_state.root_id = 1; | 614 initial_state.root_id = 1; |
| 615 initial_state.nodes.resize(1); | 615 initial_state.nodes.resize(1); |
| 616 initial_state.nodes[0].id = 1; | 616 initial_state.nodes[0].id = 1; |
| 617 initial_state.nodes[0].role = AX_ROLE_BUTTON; | 617 initial_state.nodes[0].role = AX_ROLE_BUTTON; |
| 618 initial_state.nodes[0].AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, | 618 initial_state.nodes[0].AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, |
| 619 ui::AX_CHECKED_STATE_TRUE); | 619 ui::AX_BUTTON_STATE_TRUE); |
| 620 initial_state.nodes[0].AddState(AX_STATE_FOCUSABLE); | 620 initial_state.nodes[0].AddState(AX_STATE_FOCUSABLE); |
| 621 AXTree tree(initial_state); | 621 AXTree tree(initial_state); |
| 622 | 622 |
| 623 FakeAXTreeDelegate fake_delegate; | 623 FakeAXTreeDelegate fake_delegate; |
| 624 tree.SetDelegate(&fake_delegate); | 624 tree.SetDelegate(&fake_delegate); |
| 625 | 625 |
| 626 // Change the role and state. | 626 // Change the role and state. |
| 627 AXTreeUpdate update; | 627 AXTreeUpdate update; |
| 628 update.root_id = 1; | 628 update.root_id = 1; |
| 629 update.nodes.resize(1); | 629 update.nodes.resize(1); |
| 630 update.nodes[0].id = 1; | 630 update.nodes[0].id = 1; |
| 631 update.nodes[0].role = AX_ROLE_CHECK_BOX; | 631 update.nodes[0].role = AX_ROLE_CHECK_BOX; |
| 632 update.nodes[0].AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, | 632 update.nodes[0].AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, |
| 633 ui::AX_CHECKED_STATE_FALSE); | 633 ui::AX_BUTTON_STATE_FALSE); |
| 634 update.nodes[0].AddState(AX_STATE_FOCUSABLE); | 634 update.nodes[0].AddState(AX_STATE_FOCUSABLE); |
| 635 update.nodes[0].AddState(AX_STATE_VISITED); | 635 update.nodes[0].AddState(AX_STATE_VISITED); |
| 636 EXPECT_TRUE(tree.Unserialize(update)); | 636 EXPECT_TRUE(tree.Unserialize(update)); |
| 637 | 637 |
| 638 const std::vector<std::string>& change_log = | 638 const std::vector<std::string>& change_log = |
| 639 fake_delegate.attribute_change_log(); | 639 fake_delegate.attribute_change_log(); |
| 640 ASSERT_EQ(3U, change_log.size()); | 640 ASSERT_EQ(3U, change_log.size()); |
| 641 EXPECT_EQ("Role changed from button to checkBox", change_log[0]); | 641 EXPECT_EQ("Role changed from button to checkBox", change_log[0]); |
| 642 EXPECT_EQ("visited changed to true", change_log[1]); | 642 EXPECT_EQ("visited changed to true", change_log[1]); |
| 643 EXPECT_EQ("checkedState changed from 2 to 1", change_log[2]); | 643 EXPECT_EQ("checkedState changed from 2 to 1", change_log[2]); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 fake_delegate2.attribute_change_log(); | 777 fake_delegate2.attribute_change_log(); |
| 778 ASSERT_EQ(3U, change_log2.size()); | 778 ASSERT_EQ(3U, change_log2.size()); |
| 779 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]); | 779 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]); |
| 780 EXPECT_EQ("detailsIds changed from 3 to 2,2", change_log2[1]); | 780 EXPECT_EQ("detailsIds changed from 3 to 2,2", change_log2[1]); |
| 781 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]); | 781 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]); |
| 782 | 782 |
| 783 tree.SetDelegate(NULL); | 783 tree.SetDelegate(NULL); |
| 784 } | 784 } |
| 785 | 785 |
| 786 } // namespace ui | 786 } // namespace ui |
| OLD | NEW |