OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 events2[0].id = -1; | 1601 events2[0].id = -1; |
1602 events2[0].event_type = ui::AX_EVENT_NONE; | 1602 events2[0].event_type = ui::AX_EVENT_NONE; |
1603 manager->OnAccessibilityEvents(events2); | 1603 manager->OnAccessibilityEvents(events2); |
1604 | 1604 |
1605 // Make sure that the focused node was updated to the new root and | 1605 // Make sure that the focused node was updated to the new root and |
1606 // that this doesn't crash. | 1606 // that this doesn't crash. |
1607 ASSERT_EQ(3, manager->GetRoot()->GetId()); | 1607 ASSERT_EQ(3, manager->GetRoot()->GetId()); |
1608 ASSERT_EQ(3, manager->GetFocus()->GetId()); | 1608 ASSERT_EQ(3, manager->GetFocus()->GetId()); |
1609 } | 1609 } |
1610 | 1610 |
1611 TEST(BrowserAccessibilityManagerTest, LineStartBoundary) { | |
1612 ui::AXNodeData root; | |
1613 root.id = 1; | |
1614 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | |
1615 | |
1616 ui::AXNodeData static_text; | |
1617 static_text.id = 2; | |
1618 static_text.SetName("1-2-3-4"); | |
1619 static_text.role = ui::AX_ROLE_STATIC_TEXT; | |
1620 root.child_ids.push_back(2); | |
1621 | |
1622 ui::AXNodeData inline_text1; | |
1623 inline_text1.id = 3; | |
1624 inline_text1.SetName("1-2-"); | |
1625 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | |
1626 static_text.child_ids.push_back(3); | |
1627 | |
1628 ui::AXNodeData inline_text2; | |
1629 inline_text2.id = 4; | |
1630 inline_text2.SetName("3-4"); | |
1631 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | |
1632 static_text.child_ids.push_back(4); | |
1633 | |
1634 std::unique_ptr<BrowserAccessibilityManager> manager( | |
1635 BrowserAccessibilityManager::Create( | |
1636 MakeAXTreeUpdate(root, static_text, inline_text1, inline_text2), | |
1637 nullptr, new CountedBrowserAccessibilityFactory())); | |
1638 | |
1639 BrowserAccessibility* root_accessible = manager->GetRoot(); | |
1640 ASSERT_NE(nullptr, root_accessible); | |
1641 BrowserAccessibility* static_text_accessible = | |
1642 root_accessible->PlatformGetChild(0); | |
1643 ASSERT_NE(nullptr, static_text_accessible); | |
1644 | |
1645 // If the affinity is downstream, check that we get the second line. | |
1646 ASSERT_EQ(4, static_text_accessible->GetLineStartBoundary( | |
1647 4, ui::BACKWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_DOWNSTREAM)); | |
1648 ASSERT_EQ(7, static_text_accessible->GetLineStartBoundary( | |
1649 4, ui::FORWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_DOWNSTREAM)); | |
1650 | |
1651 // If the affinity is upstream, check that we get the second line. | |
1652 ASSERT_EQ(0, static_text_accessible->GetLineStartBoundary( | |
1653 4, ui::BACKWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_UPSTREAM)); | |
1654 ASSERT_EQ(4, static_text_accessible->GetLineStartBoundary( | |
1655 4, ui::FORWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_UPSTREAM)); | |
1656 } | |
1657 | |
1658 } // namespace content | 1611 } // namespace content |
OLD | NEW |