| Index: ui/accessibility/ax_node_position_unittest.cc
|
| diff --git a/ui/accessibility/ax_node_position_unittest.cc b/ui/accessibility/ax_node_position_unittest.cc
|
| index c6641e0ba2ffaa31df4588b661680bf868e6b4eb..e3ca95f5c7725a3b2635a4155ef8bc057305e237 100644
|
| --- a/ui/accessibility/ax_node_position_unittest.cc
|
| +++ b/ui/accessibility/ax_node_position_unittest.cc
|
| @@ -25,7 +25,9 @@
|
|
|
| namespace ui {
|
|
|
| -using TestPositionType = std::unique_ptr<AXPosition<AXNodePosition, AXNode>>;
|
| +using ConcretePositionType =
|
| + std::unique_ptr<AXPosition<AXNodePosition, AXNode>>;
|
| +using TestPositionType = std::unique_ptr<AXPositionBase>;
|
|
|
| namespace {
|
|
|
| @@ -211,17 +213,40 @@ void AXPositionTest::TearDown() {
|
| AXNodePosition::SetTreeForTesting(nullptr);
|
| }
|
|
|
| +TestPositionType AsBase(ConcretePositionType concrete) {
|
| + return base::WrapUnique<AXPositionBase>(concrete.release());
|
| +}
|
| +
|
| +TestPositionType CreateNullPosition() {
|
| + return AsBase(AXNodePosition::CreateConcreteNullPosition());
|
| +}
|
| +
|
| +TestPositionType CreateTreePosition(int tree_id,
|
| + int32_t anchor_id,
|
| + int child_index) {
|
| + return AsBase(AXNodePosition::CreateConcreteTreePosition(tree_id, anchor_id,
|
| + child_index));
|
| +}
|
| +
|
| +TestPositionType CreateTextPosition(int tree_id,
|
| + int32_t anchor_id,
|
| + int text_offset,
|
| + AXTextAffinity affinity) {
|
| + return AsBase(AXNodePosition::CreateConcreteTextPosition(
|
| + tree_id, anchor_id, text_offset, affinity));
|
| +}
|
| +
|
| } // namespace
|
|
|
| TEST_F(AXPositionTest, Clone) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType copy_position = null_position->Clone();
|
| ASSERT_NE(nullptr, copy_position);
|
| EXPECT_TRUE(copy_position->IsNullPosition());
|
|
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + TestPositionType tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| copy_position = tree_position->Clone();
|
| ASSERT_NE(nullptr, copy_position);
|
| @@ -230,8 +255,8 @@ TEST_F(AXPositionTest, Clone) {
|
| EXPECT_EQ(1, copy_position->child_index());
|
| EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, AXNodePosition::BEFORE_TEXT);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, root_.id,
|
| + AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, tree_position);
|
| copy_position = tree_position->Clone();
|
| ASSERT_NE(nullptr, copy_position);
|
| @@ -240,9 +265,9 @@ TEST_F(AXPositionTest, Clone) {
|
| EXPECT_EQ(AXNodePosition::BEFORE_TEXT, copy_position->child_index());
|
| EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
|
|
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| copy_position = text_position->Clone();
|
| ASSERT_NE(nullptr, copy_position);
|
| @@ -251,9 +276,9 @@ TEST_F(AXPositionTest, Clone) {
|
| EXPECT_EQ(1, copy_position->text_offset());
|
| EXPECT_EQ(AX_TEXT_AFFINITY_UPSTREAM, copy_position->affinity());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| copy_position = text_position->Clone();
|
| ASSERT_NE(nullptr, copy_position);
|
| @@ -265,99 +290,99 @@ TEST_F(AXPositionTest, Clone) {
|
| }
|
|
|
| TEST_F(AXPositionTest, AtStartOfAnchorWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| EXPECT_FALSE(null_position->AtStartOfAnchor());
|
| }
|
|
|
| TEST_F(AXPositionTest, AtStartOfAnchorWithTreePosition) {
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| + TestPositionType tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_TRUE(tree_position->AtStartOfAnchor());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_FALSE(tree_position->AtStartOfAnchor());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_FALSE(tree_position->AtStartOfAnchor());
|
|
|
| // A "before text" position.
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, AXNodePosition::BEFORE_TEXT);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_TRUE(tree_position->AtStartOfAnchor());
|
|
|
| // An "after text" position.
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* child_index */);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_FALSE(tree_position->AtStartOfAnchor());
|
| }
|
|
|
| TEST_F(AXPositionTest, AtStartOfAnchorWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_TRUE(text_position->AtStartOfAnchor());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtStartOfAnchor());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtStartOfAnchor());
|
| }
|
|
|
| TEST_F(AXPositionTest, AtEndOfAnchorWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| EXPECT_FALSE(null_position->AtEndOfAnchor());
|
| }
|
|
|
| TEST_F(AXPositionTest, AtEndOfAnchorWithTreePosition) {
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| + TestPositionType tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_TRUE(tree_position->AtEndOfAnchor());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 2 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 2 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_FALSE(tree_position->AtEndOfAnchor());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| EXPECT_FALSE(tree_position->AtEndOfAnchor());
|
| }
|
|
|
| TEST_F(AXPositionTest, AtEndOfAnchorWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_TRUE(text_position->AtEndOfAnchor());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtEndOfAnchor());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtEndOfAnchor());
|
| }
|
| @@ -365,106 +390,106 @@ TEST_F(AXPositionTest, AtEndOfAnchorWithTextPosition) {
|
| TEST_F(AXPositionTest, AtStartOfLineWithTextPosition) {
|
| // An upstream affinity should not affect the outcome since there is no soft
|
| // line break.
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_TRUE(text_position->AtStartOfLine());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtStartOfLine());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, line_break_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, line_break_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtStartOfLine());
|
|
|
| // An "after text" position anchored at the line break should visually be the
|
| // same as a text position at the start of the next line.
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, line_break_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, line_break_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_TRUE(text_position->AtStartOfLine());
|
|
|
| // An upstream affinity should not affect the outcome since there is no soft
|
| // line break.
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_TRUE(text_position->AtStartOfLine());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtStartOfLine());
|
| }
|
|
|
| TEST_F(AXPositionTest, AtEndOfLineWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtEndOfLine());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_TRUE(text_position->AtEndOfLine());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, line_break_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, line_break_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtEndOfLine());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_FALSE(text_position->AtEndOfLine());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| EXPECT_TRUE(text_position->AtEndOfLine());
|
| }
|
|
|
| TEST_F(AXPositionTest, LowestCommonAncestor) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| // An "after children" position.
|
| - TestPositionType root_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| + TestPositionType root_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| ASSERT_NE(nullptr, root_position);
|
| // A "before text" position.
|
| - TestPositionType button_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType button_position = CreateTreePosition(
|
| tree_.data().tree_id, button_.id, AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, button_position);
|
| - TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType text_field_position = CreateTreePosition(
|
| tree_.data().tree_id, text_field_.id, 2 /* child_index */);
|
| ASSERT_NE(nullptr, text_field_position);
|
| - TestPositionType static_text1_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType static_text1_position = CreateTreePosition(
|
| tree_.data().tree_id, static_text1_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, static_text1_position);
|
| - TestPositionType static_text2_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType static_text2_position = CreateTreePosition(
|
| tree_.data().tree_id, static_text2_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, static_text2_position);
|
| - TestPositionType inline_box1_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType inline_box1_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, inline_box1_position);
|
| - TestPositionType inline_box2_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + TestPositionType inline_box2_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, inline_box2_position);
|
|
|
| TestPositionType test_position =
|
| @@ -521,7 +546,7 @@ TEST_F(AXPositionTest, LowestCommonAncestor) {
|
| }
|
|
|
| TEST_F(AXPositionTest, AsTreePositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->AsTreePosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -529,8 +554,8 @@ TEST_F(AXPositionTest, AsTreePositionWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, AsTreePositionWithTreePosition) {
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + TestPositionType tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| TestPositionType test_position = tree_position->AsTreePosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -543,9 +568,9 @@ TEST_F(AXPositionTest, AsTreePositionWithTreePosition) {
|
|
|
| TEST_F(AXPositionTest, AsTreePositionWithTextPosition) {
|
| // Create a text position pointing to the last character in the text field.
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 12 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 12 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position = text_position->AsTreePosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -559,9 +584,9 @@ TEST_F(AXPositionTest, AsTreePositionWithTextPosition) {
|
| EXPECT_EQ(12, test_position->text_offset());
|
|
|
| // Test for a "before text" position.
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->AsTreePosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -572,9 +597,9 @@ TEST_F(AXPositionTest, AsTreePositionWithTextPosition) {
|
| EXPECT_EQ(0, test_position->text_offset());
|
|
|
| // Test for an "after text" position.
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->AsTreePosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -586,7 +611,7 @@ TEST_F(AXPositionTest, AsTreePositionWithTextPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, AsTextPositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->AsTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -596,7 +621,7 @@ TEST_F(AXPositionTest, AsTextPositionWithNullPosition) {
|
| TEST_F(AXPositionTest, AsTextPositionWithTreePosition) {
|
| // Create a tree position pointing to the line break node inside the text
|
| // field.
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType tree_position = CreateTreePosition(
|
| tree_.data().tree_id, text_field_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| TestPositionType test_position = tree_position->AsTextPosition();
|
| @@ -611,8 +636,8 @@ TEST_F(AXPositionTest, AsTextPositionWithTreePosition) {
|
| EXPECT_EQ(1, test_position->child_index());
|
|
|
| // Test for a "before text" position.
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, AXNodePosition::BEFORE_TEXT);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->AsTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -623,8 +648,8 @@ TEST_F(AXPositionTest, AsTextPositionWithTreePosition) {
|
| EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
|
|
|
| // Test for an "after text" position.
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* child_index */);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->AsTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -636,9 +661,9 @@ TEST_F(AXPositionTest, AsTextPositionWithTreePosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, AsTextPositionWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position = text_position->AsTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -651,7 +676,7 @@ TEST_F(AXPositionTest, AsTextPositionWithTextPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, AsLeafTextPositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -661,7 +686,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithNullPosition) {
|
| TEST_F(AXPositionTest, AsLeafTextPositionWithTreePosition) {
|
| // Create a tree position pointing to the first static text node inside the
|
| // text field.
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType tree_position = CreateTreePosition(
|
| tree_.data().tree_id, text_field_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| TestPositionType test_position = tree_position->AsLeafTextPosition();
|
| @@ -674,8 +699,8 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTreePosition) {
|
|
|
| // Create a tree position pointing to the line break node inside the text
|
| // field.
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, text_field_.id, 1 /* child_index */);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, text_field_.id,
|
| + 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -687,8 +712,8 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTreePosition) {
|
|
|
| // Create a text position pointing to the second static text node inside the
|
| // text field.
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, text_field_.id, 2 /* child_index */);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, text_field_.id,
|
| + 2 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -702,9 +727,9 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTreePosition) {
|
| TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) {
|
| // Create a text position pointing to the end of the root (an "after text"
|
| // position).
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, root_.id, 28 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, root_.id, 28 /* text_offset */,
|
| + AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position = text_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -714,9 +739,9 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) {
|
| EXPECT_EQ(6, test_position->text_offset());
|
| EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -726,9 +751,9 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) {
|
| EXPECT_EQ(0, test_position->text_offset());
|
| EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -740,9 +765,9 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) {
|
|
|
| // Create a text position pointing to the line break character inside the text
|
| // field.
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -754,9 +779,9 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) {
|
|
|
| // Create a text position pointing to the offset after the last character in
|
| // the text field, (an "after text" position).
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 13 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 13 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->AsLeafTextPosition();
|
| ASSERT_NE(nullptr, test_position);
|
| @@ -768,7 +793,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position =
|
| null_position->CreatePositionAtStartOfAnchor();
|
| @@ -777,8 +802,8 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTreePosition) {
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| + TestPositionType tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| TestPositionType test_position =
|
| tree_position->CreatePositionAtStartOfAnchor();
|
| @@ -787,8 +812,8 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTreePosition) {
|
| EXPECT_EQ(root_.id, test_position->anchor_id());
|
| EXPECT_EQ(0, test_position->child_index());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->CreatePositionAtStartOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -797,8 +822,8 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTreePosition) {
|
| EXPECT_EQ(0, test_position->child_index());
|
|
|
| // An "after text" position.
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* child_index */);
|
| + tree_position = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->CreatePositionAtStartOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -808,9 +833,9 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTreePosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position =
|
| text_position->CreatePositionAtStartOfAnchor();
|
| @@ -820,9 +845,9 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTextPosition) {
|
| EXPECT_EQ(0, test_position->text_offset());
|
| EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreatePositionAtStartOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -834,7 +859,7 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTextPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->CreatePositionAtEndOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -842,8 +867,8 @@ TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTreePosition) {
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| + TestPositionType tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| TestPositionType test_position = tree_position->CreatePositionAtEndOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -851,8 +876,8 @@ TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTreePosition) {
|
| EXPECT_EQ(root_.id, test_position->anchor_id());
|
| EXPECT_EQ(3, test_position->child_index());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->CreatePositionAtEndOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -862,9 +887,9 @@ TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTreePosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position = text_position->CreatePositionAtEndOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -873,9 +898,9 @@ TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTextPosition) {
|
| EXPECT_EQ(6, test_position->text_offset());
|
| EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreatePositionAtEndOfAnchor();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -887,7 +912,7 @@ TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTextPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateChildPositionAtWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->CreateChildPositionAt(0);
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -895,8 +920,8 @@ TEST_F(AXPositionTest, CreateChildPositionAtWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateChildPositionAtWithTreePosition) {
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 2 /* child_index */);
|
| + TestPositionType tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 2 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| TestPositionType test_position = tree_position->CreateChildPositionAt(1);
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -906,8 +931,8 @@ TEST_F(AXPositionTest, CreateChildPositionAtWithTreePosition) {
|
| // a "before text" position.
|
| EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, button_.id, 0 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, button_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->CreateChildPositionAt(0);
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -915,9 +940,9 @@ TEST_F(AXPositionTest, CreateChildPositionAtWithTreePosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateChildPositionAtWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, static_text1_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, static_text1_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position = text_position->CreateChildPositionAt(0);
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -925,9 +950,9 @@ TEST_F(AXPositionTest, CreateChildPositionAtWithTextPosition) {
|
| EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
|
| EXPECT_EQ(0, test_position->text_offset());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, static_text2_.id, 4 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, static_text2_.id,
|
| + 4 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreateChildPositionAt(1);
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -935,7 +960,7 @@ TEST_F(AXPositionTest, CreateChildPositionAtWithTextPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateParentPositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->CreateParentPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -943,7 +968,7 @@ TEST_F(AXPositionTest, CreateParentPositionWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateParentPositionWithTreePosition) {
|
| - TestPositionType tree_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType tree_position = CreateTreePosition(
|
| tree_.data().tree_id, check_box_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| TestPositionType test_position = tree_position->CreateParentPosition();
|
| @@ -953,8 +978,8 @@ TEST_F(AXPositionTest, CreateParentPositionWithTreePosition) {
|
| // |child_index| should point to the check box node.
|
| EXPECT_EQ(1, test_position->child_index());
|
|
|
| - tree_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + tree_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position);
|
| test_position = tree_position->CreateParentPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -962,9 +987,9 @@ TEST_F(AXPositionTest, CreateParentPositionWithTreePosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateParentPositionWithTextPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position = text_position->CreateParentPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -983,7 +1008,7 @@ TEST_F(AXPositionTest, CreateParentPositionWithTextPosition) {
|
|
|
| TEST_F(AXPositionTest,
|
| CreateNextAndPreviousTextAnchorPositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position =
|
| null_position->CreateNextTextAnchorPosition();
|
| @@ -995,8 +1020,8 @@ TEST_F(AXPositionTest,
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateNextTextAnchorPosition) {
|
| - TestPositionType check_box_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + TestPositionType check_box_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, check_box_position);
|
| TestPositionType test_position =
|
| check_box_position->CreateNextTextAnchorPosition();
|
| @@ -1008,9 +1033,9 @@ TEST_F(AXPositionTest, CreateNextTextAnchorPosition) {
|
|
|
| // The text offset on the root points to the text coming from inside the check
|
| // box.
|
| - check_box_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, root_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + check_box_position =
|
| + CreateTextPosition(tree_.data().tree_id, root_.id, 6 /* text_offset */,
|
| + AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, check_box_position);
|
| test_position = check_box_position->CreateNextTextAnchorPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1019,9 +1044,9 @@ TEST_F(AXPositionTest, CreateNextTextAnchorPosition) {
|
| EXPECT_EQ(check_box_.id, test_position->anchor_id());
|
| EXPECT_EQ(0, test_position->text_offset());
|
|
|
| - TestPositionType button_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, button_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType button_position =
|
| + CreateTextPosition(tree_.data().tree_id, button_.id, 1 /* text_offset */,
|
| + AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, button_position);
|
| test_position = button_position->CreateNextTextAnchorPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1055,8 +1080,8 @@ TEST_F(AXPositionTest, CreateNextTextAnchorPosition) {
|
| EXPECT_NE(nullptr, test_position);
|
| EXPECT_TRUE(test_position->IsNullPosition());
|
|
|
| - TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 2 /* child_index */);
|
| + TestPositionType text_field_position =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 2 /* child_index */);
|
| ASSERT_NE(nullptr, text_field_position);
|
| test_position = text_field_position->CreateNextTextAnchorPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1067,9 +1092,9 @@ TEST_F(AXPositionTest, CreateNextTextAnchorPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePreviousTextAnchorPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position =
|
| text_position->CreatePreviousTextAnchorPosition();
|
| @@ -1080,7 +1105,7 @@ TEST_F(AXPositionTest, CreatePreviousTextAnchorPosition) {
|
| EXPECT_EQ(0, test_position->text_offset());
|
|
|
| // Create a "before text" tree position on the second line of the text box.
|
| - TestPositionType before_text_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType before_text_position = CreateTreePosition(
|
| tree_.data().tree_id, inline_box2_.id, AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, before_text_position);
|
| test_position = before_text_position->CreatePreviousTextAnchorPosition();
|
| @@ -1115,7 +1140,7 @@ TEST_F(AXPositionTest, CreatePreviousTextAnchorPosition) {
|
| EXPECT_NE(nullptr, test_position);
|
| EXPECT_TRUE(test_position->IsNullPosition());
|
|
|
| - TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
|
| + TestPositionType text_field_position = CreateTreePosition(
|
| tree_.data().tree_id, text_field_.id, 2 /* child_index */);
|
| ASSERT_NE(nullptr, text_field_position);
|
| test_position = text_field_position->CreatePreviousTextAnchorPosition();
|
| @@ -1127,9 +1152,9 @@ TEST_F(AXPositionTest, CreatePreviousTextAnchorPosition) {
|
|
|
| // The text offset on the root points to the text coming from inside the check
|
| // box.
|
| - TestPositionType check_box_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, check_box_.id, 6 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType check_box_position =
|
| + CreateTextPosition(tree_.data().tree_id, check_box_.id,
|
| + 6 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, check_box_position);
|
| test_position = check_box_position->CreatePreviousTextAnchorPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1140,7 +1165,7 @@ TEST_F(AXPositionTest, CreatePreviousTextAnchorPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateNextAndPreviousCharacterPositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->CreateNextCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1151,9 +1176,9 @@ TEST_F(AXPositionTest, CreateNextAndPreviousCharacterPositionWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateNextCharacterPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 4 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 4 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position = text_position->CreateNextCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1161,9 +1186,9 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) {
|
| EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
|
| EXPECT_EQ(5, test_position->text_offset());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreateNextCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1183,9 +1208,9 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) {
|
| EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
|
| EXPECT_EQ(1, test_position->text_offset());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, check_box_.id, 9 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, check_box_.id,
|
| + 9 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreateNextCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1193,9 +1218,9 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) {
|
| EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
|
| EXPECT_EQ(0, test_position->text_offset());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreateNextCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1207,9 +1232,9 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreatePreviousCharacterPosition) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| TestPositionType test_position =
|
| text_position->CreatePreviousCharacterPosition();
|
| @@ -1218,9 +1243,9 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) {
|
| EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
|
| EXPECT_EQ(4, test_position->text_offset());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box2_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreatePreviousCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1240,9 +1265,9 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) {
|
| EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
|
| EXPECT_EQ(4, test_position->text_offset());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreatePreviousCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1250,9 +1275,9 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) {
|
| EXPECT_EQ(check_box_.id, test_position->anchor_id());
|
| EXPECT_EQ(8, test_position->text_offset());
|
|
|
| - text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position);
|
| test_position = text_position->CreatePreviousCharacterPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1263,7 +1288,7 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateNextAndPreviousWordStartPositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->CreateNextWordStartPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1274,7 +1299,7 @@ TEST_F(AXPositionTest, CreateNextAndPreviousWordStartPositionWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, CreateNextAndPreviousWordEndPositionWithNullPosition) {
|
| - TestPositionType null_position = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position);
|
| TestPositionType test_position = null_position->CreateNextWordEndPosition();
|
| EXPECT_NE(nullptr, test_position);
|
| @@ -1285,173 +1310,173 @@ TEST_F(AXPositionTest, CreateNextAndPreviousWordEndPositionWithNullPosition) {
|
| }
|
|
|
| TEST_F(AXPositionTest, OperatorEquals) {
|
| - TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position1 = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position1);
|
| - TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position2 = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position2);
|
| EXPECT_EQ(*null_position1, *null_position2);
|
|
|
| // Child indices must match.
|
| - TestPositionType button_position1 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| + TestPositionType button_position1 =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, button_position1);
|
| - TestPositionType button_position2 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| + TestPositionType button_position2 =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, button_position2);
|
| EXPECT_EQ(*button_position1, *button_position2);
|
|
|
| // Both child indices are invalid. It should result in equivalent null
|
| // positions.
|
| - TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 4 /* child_index */);
|
| + TestPositionType tree_position1 =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 4 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position1);
|
| - TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
|
| + TestPositionType tree_position2 = CreateTreePosition(
|
| tree_.data().tree_id, root_.id, AXNodePosition::INVALID_INDEX);
|
| ASSERT_NE(nullptr, tree_position2);
|
| EXPECT_EQ(*tree_position1, *tree_position2);
|
|
|
| // An invalid position should not be equivalent to an "after children"
|
| // position.
|
| - tree_position1 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| + tree_position1 =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 3 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position1);
|
| - tree_position2 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, -1 /* child_index */);
|
| + tree_position2 =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, -1 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position2);
|
| EXPECT_NE(*tree_position1, *tree_position2);
|
|
|
| // Two "after children" positions on the same node should be equivalent.
|
| - tree_position1 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, text_field_.id, 3 /* child_index */);
|
| + tree_position1 = CreateTreePosition(tree_.data().tree_id, text_field_.id,
|
| + 3 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position1);
|
| - tree_position2 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, text_field_.id, 3 /* child_index */);
|
| + tree_position2 = CreateTreePosition(tree_.data().tree_id, text_field_.id,
|
| + 3 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position2);
|
| EXPECT_EQ(*tree_position1, *tree_position2);
|
|
|
| // Two "before text" positions on the same node should be equivalent.
|
| - tree_position1 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, AXNodePosition::BEFORE_TEXT);
|
| + tree_position1 = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, tree_position1);
|
| - tree_position2 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, AXNodePosition::BEFORE_TEXT);
|
| + tree_position2 = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, tree_position2);
|
| EXPECT_EQ(*tree_position1, *tree_position2);
|
|
|
| // Both text offsets are invalid. It should result in equivalent null
|
| // positions.
|
| - TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 15 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + TestPositionType text_position1 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 15 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position1);
|
| - TestPositionType text_position2 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, text_field_.id, -1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + TestPositionType text_position2 =
|
| + CreateTextPosition(tree_.data().tree_id, text_field_.id,
|
| + -1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position2);
|
| EXPECT_EQ(*text_position1, *text_position2);
|
|
|
| - text_position1 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position1 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position1);
|
| - text_position2 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + text_position2 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position2);
|
| EXPECT_EQ(*text_position1, *text_position2);
|
|
|
| // Affinities should match.
|
| - text_position2 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position2 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position2);
|
| EXPECT_NE(*text_position1, *text_position2);
|
|
|
| // Text offsets should match.
|
| - text_position1 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position1 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 5 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position1);
|
| EXPECT_NE(*text_position1, *text_position2);
|
|
|
| // Two "after text" positions on the same node should be equivalent.
|
| - text_position1 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, line_break_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position1 =
|
| + CreateTextPosition(tree_.data().tree_id, line_break_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position1);
|
| - text_position2 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, line_break_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position2 =
|
| + CreateTextPosition(tree_.data().tree_id, line_break_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position2);
|
| EXPECT_EQ(*text_position1, *text_position2);
|
| }
|
|
|
| TEST_F(AXPositionTest, OperatorsLessThanAndGreaterThan) {
|
| - TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position1 = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position1);
|
| - TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
|
| + TestPositionType null_position2 = CreateNullPosition();
|
| ASSERT_NE(nullptr, null_position2);
|
| EXPECT_FALSE(*null_position1 < *null_position2);
|
| EXPECT_FALSE(*null_position1 > *null_position2);
|
|
|
| - TestPositionType button_position1 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| + TestPositionType button_position1 =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| ASSERT_NE(nullptr, button_position1);
|
| - TestPositionType button_position2 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| + TestPositionType button_position2 =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 1 /* child_index */);
|
| ASSERT_NE(nullptr, button_position2);
|
| EXPECT_LT(*button_position1, *button_position2);
|
| EXPECT_GT(*button_position2, *button_position1);
|
|
|
| - TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
|
| + TestPositionType tree_position1 = CreateTreePosition(
|
| tree_.data().tree_id, text_field_.id, 2 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position1);
|
| // An "after children" position.
|
| - TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
|
| + TestPositionType tree_position2 = CreateTreePosition(
|
| tree_.data().tree_id, text_field_.id, 3 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position2);
|
| EXPECT_LT(*tree_position1, *tree_position2);
|
| EXPECT_GT(*tree_position2, *tree_position1);
|
|
|
| // A "before text" position.
|
| - tree_position1 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, AXNodePosition::BEFORE_TEXT);
|
| + tree_position1 = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + AXNodePosition::BEFORE_TEXT);
|
| ASSERT_NE(nullptr, tree_position1);
|
| // An "after text" position.
|
| - tree_position2 = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* child_index */);
|
| + tree_position2 = CreateTreePosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* child_index */);
|
| ASSERT_NE(nullptr, tree_position2);
|
| EXPECT_LT(*tree_position1, *tree_position2);
|
| EXPECT_GT(*tree_position2, *tree_position1);
|
|
|
| - TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 2 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position1 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 2 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position1);
|
| - TestPositionType text_position2 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position2 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| ASSERT_NE(nullptr, text_position2);
|
| EXPECT_GT(*text_position1, *text_position2);
|
| EXPECT_LT(*text_position2, *text_position1);
|
|
|
| // Affinities should not matter.
|
| - text_position2 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position2 =
|
| + CreateTextPosition(tree_.data().tree_id, inline_box1_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position2);
|
| EXPECT_GT(*text_position1, *text_position2);
|
| EXPECT_LT(*text_position2, *text_position1);
|
|
|
| // An "after text" position.
|
| - text_position1 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, line_break_.id, 1 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position1 =
|
| + CreateTextPosition(tree_.data().tree_id, line_break_.id,
|
| + 1 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position1);
|
| // A "before text" position.
|
| - text_position2 = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, line_break_.id, 0 /* text_offset */,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + text_position2 =
|
| + CreateTextPosition(tree_.data().tree_id, line_break_.id,
|
| + 0 /* text_offset */, AX_TEXT_AFFINITY_UPSTREAM);
|
| ASSERT_NE(nullptr, text_position2);
|
| EXPECT_GT(*text_position1, *text_position2);
|
| EXPECT_LT(*text_position2, *text_position1);
|
| @@ -1462,9 +1487,9 @@ TEST_F(AXPositionTest, OperatorsLessThanAndGreaterThan) {
|
| //
|
|
|
| TEST_P(AXPositionTestWithParam, TraverseTreeStartingWithAffinityDownstream) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, GetParam().start_node_id_, GetParam().start_offset_,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, GetParam().start_node_id_,
|
| + GetParam().start_offset_, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| for (const std::string& expectation : GetParam().expectations) {
|
| text_position = GetParam().TestMethod.Run(text_position);
|
| EXPECT_NE(nullptr, text_position);
|
| @@ -1473,9 +1498,9 @@ TEST_P(AXPositionTestWithParam, TraverseTreeStartingWithAffinityDownstream) {
|
| }
|
|
|
| TEST_P(AXPositionTestWithParam, TraverseTreeStartingWithAffinityUpstream) {
|
| - TestPositionType text_position = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, GetParam().start_node_id_, GetParam().start_offset_,
|
| - AX_TEXT_AFFINITY_UPSTREAM);
|
| + TestPositionType text_position =
|
| + CreateTextPosition(tree_.data().tree_id, GetParam().start_node_id_,
|
| + GetParam().start_offset_, AX_TEXT_AFFINITY_UPSTREAM);
|
| for (const std::string& expectation : GetParam().expectations) {
|
| text_position = GetParam().TestMethod.Run(text_position);
|
| EXPECT_NE(nullptr, text_position);
|
| @@ -1980,16 +2005,14 @@ TEST_F(AXPositionTest, AXRangeGetTextWithWholeObjects) {
|
| // Create a range starting from the button object and ending at the last
|
| // character of the root, i.e. at the last character of the second line in the
|
| // text field.
|
| - TestPositionType start = AXNodePosition::CreateTreePosition(
|
| - tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| - TestPositionType end = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, root_.id, 28 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| - AXRange<AXPosition<AXNodePosition, AXNode>> forward_range(start->Clone(),
|
| - end->Clone());
|
| + TestPositionType start =
|
| + CreateTreePosition(tree_.data().tree_id, root_.id, 0 /* child_index */);
|
| + TestPositionType end =
|
| + CreateTextPosition(tree_.data().tree_id, root_.id, 28 /* text_offset */,
|
| + AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + ui::AXAbstractRange forward_range(start->Clone(), end->Clone());
|
| EXPECT_EQ(all_text, forward_range.GetText());
|
| - AXRange<AXPosition<AXNodePosition, AXNode>> backward_range(std::move(end),
|
| - std::move(start));
|
| + ui::AXAbstractRange backward_range(std::move(end), std::move(start));
|
| EXPECT_EQ(all_text, backward_range.GetText());
|
| }
|
|
|
| @@ -1997,17 +2020,15 @@ TEST_F(AXPositionTest, AXRangeGetTextWithTextOffsets) {
|
| base::string16 most_text = base::UTF8ToUTF16("tonCheck boxLine 1\nLine");
|
| // Create a range starting from the third character in the button object and
|
| // ending two characters before the end of the root.
|
| - TestPositionType start = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, button_.id, 3 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| - TestPositionType end = AXNodePosition::CreateTextPosition(
|
| - tree_.data().tree_id, static_text2_.id, 4 /* text_offset */,
|
| - AX_TEXT_AFFINITY_DOWNSTREAM);
|
| - AXRange<AXPosition<AXNodePosition, AXNode>> forward_range(start->Clone(),
|
| - end->Clone());
|
| + TestPositionType start =
|
| + CreateTextPosition(tree_.data().tree_id, button_.id, 3 /* text_offset */,
|
| + AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + TestPositionType end =
|
| + CreateTextPosition(tree_.data().tree_id, static_text2_.id,
|
| + 4 /* text_offset */, AX_TEXT_AFFINITY_DOWNSTREAM);
|
| + ui::AXAbstractRange forward_range(start->Clone(), end->Clone());
|
| EXPECT_EQ(most_text, forward_range.GetText());
|
| - AXRange<AXPosition<AXNodePosition, AXNode>> backward_range(std::move(end),
|
| - std::move(start));
|
| + ui::AXAbstractRange backward_range(std::move(end), std::move(start));
|
| EXPECT_EQ(most_text, backward_range.GetText());
|
| }
|
|
|
|
|