| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 TEST_F(PositionTest, ToPositionInComposedTreeWithInactiveInsertionPoint) | 92 TEST_F(PositionTest, ToPositionInComposedTreeWithInactiveInsertionPoint) |
| 93 { | 93 { |
| 94 const char* bodyContent = "<p id='p'><content></content></p>"; | 94 const char* bodyContent = "<p id='p'><content></content></p>"; |
| 95 setBodyContent(bodyContent); | 95 setBodyContent(bodyContent); |
| 96 RefPtrWillBeRawPtr<Element> anchor = document().getElementById("p"); | 96 RefPtrWillBeRawPtr<Element> anchor = document().getElementById("p"); |
| 97 | 97 |
| 98 EXPECT_EQ(positionInComposedTree(*anchor, 0), toPositionInComposedTree(posit
ionInDOMTree(*anchor, 0))); | 98 EXPECT_EQ(positionInComposedTree(*anchor, 0), toPositionInComposedTree(posit
ionInDOMTree(*anchor, 0))); |
| 99 EXPECT_EQ(PositionInComposedTree(anchor, PositionInComposedTree::PositionIsA
fterChildren), toPositionInComposedTree(positionInDOMTree(*anchor, 1))); | 99 EXPECT_EQ(PositionInComposedTree(anchor, PositionInComposedTree::PositionIsA
fterChildren), toPositionInComposedTree(positionInDOMTree(*anchor, 1))); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST_F(PositionTest, ToPositionInComposedTreeWithShadowRoot) |
| 103 { |
| 104 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 105 const char* shadowContent = "<a><content select=#one></content></a>"; |
| 106 setBodyContent(bodyContent); |
| 107 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
| 108 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
| 109 |
| 110 EXPECT_EQ(positionInComposedTree(*host, 0), toPositionInComposedTree(positio
nInDOMTree(*shadowRoot, 0))); |
| 111 EXPECT_EQ(PositionInComposedTree(host, PositionInComposedTree::PositionIsAft
erChildren), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 1))); |
| 112 } |
| 113 |
| 114 TEST_F(PositionTest, ToPositionInComposedTreeWithShadowRootContainingSingleConte
nt) |
| 115 { |
| 116 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 117 const char* shadowContent = "<content select=#one></content>"; |
| 118 setBodyContent(bodyContent); |
| 119 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
| 120 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
| 121 |
| 122 EXPECT_EQ(positionInComposedTree(*host, 0), toPositionInComposedTree(positio
nInDOMTree(*shadowRoot, 0))); |
| 123 EXPECT_EQ(PositionInComposedTree(host, PositionInComposedTree::PositionIsAft
erChildren), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 1))); |
| 124 } |
| 125 |
| 126 TEST_F(PositionTest, ToPositionInComposedTreeWithEmptyShadowRoot) |
| 127 { |
| 128 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 129 const char* shadowContent = ""; |
| 130 setBodyContent(bodyContent); |
| 131 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
| 132 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
| 133 |
| 134 EXPECT_EQ(PositionInComposedTree(host, PositionInComposedTree::PositionIsAft
erChildren), toPositionInComposedTree(positionInDOMTree(*shadowRoot, 0))); |
| 135 } |
| 136 |
| 102 } // namespace blink | 137 } // namespace blink |
| OLD | NEW |