| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/editing/Position.h" | 6 #include "core/editing/Position.h" |
| 7 | 7 |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 #include "core/editing/EditingUtilities.h" | |
| 10 | 9 |
| 11 namespace blink { | 10 namespace blink { |
| 12 | 11 |
| 13 class PositionTest : public EditingTestBase { | 12 class PositionTest : public EditingTestBase { |
| 14 }; | 13 }; |
| 15 | 14 |
| 16 // TODO(yoisn) We should move |NextNodeIndex| to "EditingUtilitiesTest.cpp". | |
| 17 TEST_F(PositionTest, NextNodeIndex) | |
| 18 { | |
| 19 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | |
| 20 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; | |
| 21 setBodyContent(bodyContent); | |
| 22 setShadowContent(shadowContent); | |
| 23 Node* host = document().getElementById("host"); | |
| 24 Node* two = document().getElementById("two"); | |
| 25 | |
| 26 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy
pe::CodePoint)); | |
| 27 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed
Tree(two, 2), PositionMoveType::CodePoint)); | |
| 28 } | |
| 29 | |
| 30 TEST_F(PositionTest, NodeAsRangeLastNodeNull) | 15 TEST_F(PositionTest, NodeAsRangeLastNodeNull) |
| 31 { | 16 { |
| 32 EXPECT_EQ(nullptr, Position().nodeAsRangeLastNode()); | 17 EXPECT_EQ(nullptr, Position().nodeAsRangeLastNode()); |
| 33 EXPECT_EQ(nullptr, PositionInComposedTree().nodeAsRangeLastNode()); | 18 EXPECT_EQ(nullptr, PositionInComposedTree().nodeAsRangeLastNode()); |
| 34 } | 19 } |
| 35 | 20 |
| 36 TEST_F(PositionTest, NodeAsRangeLastNode) | 21 TEST_F(PositionTest, NodeAsRangeLastNode) |
| 37 { | 22 { |
| 38 const char* bodyContent = "<p id='p1'>11</p><p id='p2'></p><p id='p3'>33</p>
"; | 23 const char* bodyContent = "<p id='p1'>11</p><p id='p2'></p><p id='p3'>33</p>
"; |
| 39 setBodyContent(bodyContent); | 24 setBodyContent(bodyContent); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 127 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 143 const char* shadowContent = ""; | 128 const char* shadowContent = ""; |
| 144 setBodyContent(bodyContent); | 129 setBodyContent(bodyContent); |
| 145 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); | 130 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
| 146 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 131 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
| 147 | 132 |
| 148 EXPECT_EQ(PositionInComposedTree(host, PositionAnchorType::AfterChildren), t
oPositionInComposedTree(Position(shadowRoot.get(), 0))); | 133 EXPECT_EQ(PositionInComposedTree(host, PositionAnchorType::AfterChildren), t
oPositionInComposedTree(Position(shadowRoot.get(), 0))); |
| 149 } | 134 } |
| 150 | 135 |
| 151 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |