| 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 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 class PositionTest : public EditingTestBase { | 12 class PositionTest : public EditingTestBase { |
| 13 }; | 13 }; |
| 14 | 14 |
| 15 TEST_F(PositionTest, downstreamAfterAnchor) | 15 TEST_F(PositionTest, downstreamAfterAnchor) |
| 16 { | 16 { |
| 17 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22<
/b>"; | 17 const char* bodyContent = "<p id='host'><b id='one'>1</b></p><b id='two'>22<
/b>"; |
| 18 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten
t><b id='three'>333</b>"; | 18 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten
t><b id='three'>333</b>"; |
| 19 setBodyContent(bodyContent); | 19 setBodyContent(bodyContent); |
| 20 setShadowContent(shadowContent); | 20 setShadowContent(shadowContent); |
| 21 updateLayoutAndStyleForPainting(); | 21 updateLayoutAndStyleForPainting(); |
| 22 | 22 |
| 23 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 23 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
| 24 | 24 |
| 25 EXPECT_EQ(Position::lastPositionInNode(host.get()), Position::afterNode(host
.get()).downstream()); | 25 EXPECT_EQ(Position::lastPositionInNode(host.get()), Position::afterNode(host
.get()).downstream()); |
| 26 EXPECT_EQ(PositionInComposedTree::lastPositionInNode(host.get()), PositionIn
ComposedTree::afterNode(host.get()).downstream()); | 26 EXPECT_EQ(PositionInComposedTree::lastPositionInNode(host.get()), PositionIn
ComposedTree::afterNode(host.get()).downstream()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // TODO(yoisn) We should move |NextNodeIndex| to "EditingUtilitiesTest.cpp". |
| 29 TEST_F(PositionTest, NextNodeIndex) | 30 TEST_F(PositionTest, NextNodeIndex) |
| 30 { | 31 { |
| 31 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 32 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
| 32 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; | 33 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; |
| 33 setBodyContent(bodyContent); | 34 setBodyContent(bodyContent); |
| 34 setShadowContent(shadowContent); | 35 setShadowContent(shadowContent); |
| 35 Node* host = document().getElementById("host"); | 36 Node* host = document().getElementById("host"); |
| 36 Node* two = document().getElementById("two"); | 37 Node* two = document().getElementById("two"); |
| 37 | 38 |
| 38 EXPECT_EQ(Position(host, 3), Position(two, 2).next()); | 39 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy
pe::CodePoint)); |
| 39 EXPECT_EQ(PositionInComposedTree(host, 1), PositionInComposedTree(two, 2).ne
xt()); | 40 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed
Tree(two, 2), PositionMoveType::CodePoint)); |
| 40 } | 41 } |
| 41 | 42 |
| 42 TEST_F(PositionTest, NodeAsRangeLastNodeNull) | 43 TEST_F(PositionTest, NodeAsRangeLastNodeNull) |
| 43 { | 44 { |
| 44 EXPECT_EQ(nullptr, Position().nodeAsRangeLastNode()); | 45 EXPECT_EQ(nullptr, Position().nodeAsRangeLastNode()); |
| 45 EXPECT_EQ(nullptr, PositionInComposedTree().nodeAsRangeLastNode()); | 46 EXPECT_EQ(nullptr, PositionInComposedTree().nodeAsRangeLastNode()); |
| 46 } | 47 } |
| 47 | 48 |
| 48 TEST_F(PositionTest, NodeAsRangeLastNode) | 49 TEST_F(PositionTest, NodeAsRangeLastNode) |
| 49 { | 50 { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 171 |
| 171 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 172 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
| 172 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 173 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
| 173 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); | 174 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); |
| 174 | 175 |
| 175 EXPECT_EQ(Position(one->firstChild(), 1), Position::afterNode(host.get()).up
stream()); | 176 EXPECT_EQ(Position(one->firstChild(), 1), Position::afterNode(host.get()).up
stream()); |
| 176 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), PositionInComposed
Tree::afterNode(host.get()).upstream()); | 177 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), PositionInComposed
Tree::afterNode(host.get()).upstream()); |
| 177 } | 178 } |
| 178 | 179 |
| 179 } // namespace blink | 180 } // namespace blink |
| OLD | NEW |