| 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/dom/Position.h" | 6 #include "core/dom/Position.h" |
| 7 | 7 |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode()); | 68 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode()); |
| 69 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode()); | 69 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode()); |
| 70 | 70 |
| 71 EXPECT_EQ(t2, PositionInComposedTree::inParentBeforeNode(*n1).nodeAsRangeLas
tNode()); | 71 EXPECT_EQ(t2, PositionInComposedTree::inParentBeforeNode(*n1).nodeAsRangeLas
tNode()); |
| 72 EXPECT_EQ(a, PositionInComposedTree::inParentBeforeNode(*n2).nodeAsRangeLast
Node()); | 72 EXPECT_EQ(a, PositionInComposedTree::inParentBeforeNode(*n2).nodeAsRangeLast
Node()); |
| 73 EXPECT_EQ(t1, PositionInComposedTree::inParentAfterNode(*n1).nodeAsRangeLast
Node()); | 73 EXPECT_EQ(t1, PositionInComposedTree::inParentAfterNode(*n1).nodeAsRangeLast
Node()); |
| 74 EXPECT_EQ(t2, PositionInComposedTree::inParentAfterNode(*n2).nodeAsRangeLast
Node()); | 74 EXPECT_EQ(t2, PositionInComposedTree::inParentAfterNode(*n2).nodeAsRangeLast
Node()); |
| 75 EXPECT_EQ(t1, PositionInComposedTree::afterNode(host).nodeAsRangeLastNode())
; | 75 EXPECT_EQ(t1, PositionInComposedTree::afterNode(host).nodeAsRangeLastNode())
; |
| 76 } | 76 } |
| 77 | 77 |
| 78 TEST_F(PositionTest, ToPositionInComposedTreeWithActiveInsertionPoint) |
| 79 { |
| 80 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 81 const char* shadowContent = "<a id='a'><content select=#one id='content'></c
ontent><content></content></a>"; |
| 82 setBodyContent(bodyContent); |
| 83 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
| 84 RefPtrWillBeRawPtr<Element> anchor = shadowRoot->getElementById("a"); |
| 85 RefPtrWillBeRawPtr<Element> insertionPoint = shadowRoot->getElementById("con
tent"); |
| 86 |
| 87 EXPECT_EQ(positionInComposedTree(*anchor, 0), toPositionInComposedTree(posit
ionInDOMTree(*anchor, 0))); |
| 88 EXPECT_EQ(positionInComposedTree(*anchor, 1), toPositionInComposedTree(posit
ionInDOMTree(*anchor, 1))); |
| 89 EXPECT_EQ(PositionInComposedTree(anchor, PositionInComposedTree::PositionIsA
fterChildren), toPositionInComposedTree(positionInDOMTree(*anchor, 2))); |
| 90 } |
| 91 |
| 92 TEST_F(PositionTest, ToPositionInComposedTreeWithInactiveInsertionPoint) |
| 93 { |
| 94 const char* bodyContent = "<p id='p'><content></content></p>"; |
| 95 setBodyContent(bodyContent); |
| 96 RefPtrWillBeRawPtr<Element> anchor = document().getElementById("p"); |
| 97 |
| 98 EXPECT_EQ(positionInComposedTree(*anchor, 0), toPositionInComposedTree(posit
ionInDOMTree(*anchor, 0))); |
| 99 EXPECT_EQ(PositionInComposedTree(anchor, PositionInComposedTree::PositionIsA
fterChildren), toPositionInComposedTree(positionInDOMTree(*anchor, 1))); |
| 100 } |
| 101 |
| 78 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |