Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_unittest.cc

Issue 2191833003: Use text affinity to return correct accessible line boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug in browser_accessibility_win.cc Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 events2[0].id = -1; 1487 events2[0].id = -1;
1488 events2[0].event_type = ui::AX_EVENT_NONE; 1488 events2[0].event_type = ui::AX_EVENT_NONE;
1489 manager->OnAccessibilityEvents(events2); 1489 manager->OnAccessibilityEvents(events2);
1490 1490
1491 // Make sure that the focused node was updated to the new root and 1491 // Make sure that the focused node was updated to the new root and
1492 // that this doesn't crash. 1492 // that this doesn't crash.
1493 ASSERT_EQ(3, manager->GetRoot()->GetId()); 1493 ASSERT_EQ(3, manager->GetRoot()->GetId());
1494 ASSERT_EQ(3, manager->GetFocus()->GetId()); 1494 ASSERT_EQ(3, manager->GetFocus()->GetId());
1495 } 1495 }
1496 1496
1497 TEST(BrowserAccessibilityManagerTest, LineStartBoundary) {
1498 ui::AXNodeData root;
1499 root.id = 1;
1500 root.role = ui::AX_ROLE_ROOT_WEB_AREA;
1501
1502 ui::AXNodeData static_text;
1503 static_text.id = 2;
1504 static_text.SetName("1-2-3-4");
1505 static_text.role = ui::AX_ROLE_STATIC_TEXT;
1506 root.child_ids.push_back(2);
1507
1508 ui::AXNodeData inline_text1;
1509 inline_text1.id = 3;
1510 inline_text1.SetName("1-2-");
1511 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX;
1512 static_text.child_ids.push_back(3);
1513
1514 ui::AXNodeData inline_text2;
1515 inline_text2.id = 4;
1516 inline_text2.SetName("3-4");
1517 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX;
1518 static_text.child_ids.push_back(4);
1519
1520 std::unique_ptr<BrowserAccessibilityManager> manager(
1521 BrowserAccessibilityManager::Create(
1522 MakeAXTreeUpdate(root, static_text, inline_text1, inline_text2),
1523 nullptr, new CountedBrowserAccessibilityFactory()));
1524
1525 BrowserAccessibility* root_accessible = manager->GetRoot();
1526 ASSERT_NE(nullptr, root_accessible);
1527 BrowserAccessibility* static_text_accessible =
1528 root_accessible->PlatformGetChild(0);
1529 ASSERT_NE(nullptr, static_text_accessible);
1530
1531 // If the affinity is downstream, check that we get the second line.
1532 ASSERT_EQ(4, static_text_accessible->GetLineStartBoundary(
1533 4, ui::BACKWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_DOWNSTREAM));
1534 ASSERT_EQ(7, static_text_accessible->GetLineStartBoundary(
1535 4, ui::FORWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_DOWNSTREAM));
1536
1537 // If the affinity is upstream, check that we get the second line.
1538 ASSERT_EQ(0, static_text_accessible->GetLineStartBoundary(
1539 4, ui::BACKWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_UPSTREAM));
1540 ASSERT_EQ(4, static_text_accessible->GetLineStartBoundary(
1541 4, ui::FORWARDS_DIRECTION, ui::AX_TEXT_AFFINITY_UPSTREAM));
1542 }
1543
1497 } // namespace content 1544 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698