| 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 "core/editing/Position.h" | 5 #include "core/editing/Position.h" |
| 6 | 6 |
| 7 #include "core/editing/EditingTestBase.h" | 7 #include "core/editing/EditingTestBase.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRoot) | 132 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRoot) |
| 133 { | 133 { |
| 134 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 134 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 135 const char* shadowContent = "<a><content select=#one></content></a>"; | 135 const char* shadowContent = "<a><content select=#one></content></a>"; |
| 136 setBodyContent(bodyContent); | 136 setBodyContent(bodyContent); |
| 137 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 137 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| 138 Element* host = document().getElementById("host"); | 138 Element* host = document().getElementById("host"); |
| 139 | 139 |
| 140 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR
oot, 0))); | 140 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR
oot, 0))); |
| 141 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos
itionInFlatTree(Position(shadowRoot, 1))); | 141 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos
itionInFlatTree(Position(shadowRoot, 1))); |
| 142 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), |
| 143 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::AfterChild
ren))); |
| 144 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::BeforeChildren), |
| 145 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::BeforeChil
dren))); |
| 146 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterAnchor), |
| 147 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::AfterAncho
r))); |
| 148 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::BeforeAnchor), |
| 149 toPositionInFlatTree(Position(shadowRoot, PositionAnchorType::BeforeAnch
or))); |
| 142 } | 150 } |
| 143 | 151 |
| 144 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRootContainingSingleContent) | 152 TEST_F(PositionTest, ToPositionInFlatTreeWithShadowRootContainingSingleContent) |
| 145 { | 153 { |
| 146 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 154 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 147 const char* shadowContent = "<content select=#one></content>"; | 155 const char* shadowContent = "<content select=#one></content>"; |
| 148 setBodyContent(bodyContent); | 156 setBodyContent(bodyContent); |
| 149 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 157 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| 150 Element* host = document().getElementById("host"); | 158 Element* host = document().getElementById("host"); |
| 151 | 159 |
| 152 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR
oot, 0))); | 160 EXPECT_EQ(PositionInFlatTree(host, 0), toPositionInFlatTree(Position(shadowR
oot, 0))); |
| 153 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos
itionInFlatTree(Position(shadowRoot, 1))); | 161 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos
itionInFlatTree(Position(shadowRoot, 1))); |
| 154 } | 162 } |
| 155 | 163 |
| 156 TEST_F(PositionTest, ToPositionInFlatTreeWithEmptyShadowRoot) | 164 TEST_F(PositionTest, ToPositionInFlatTreeWithEmptyShadowRoot) |
| 157 { | 165 { |
| 158 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 166 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
| 159 const char* shadowContent = ""; | 167 const char* shadowContent = ""; |
| 160 setBodyContent(bodyContent); | 168 setBodyContent(bodyContent); |
| 161 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 169 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| 162 Element* host = document().getElementById("host"); | 170 Element* host = document().getElementById("host"); |
| 163 | 171 |
| 164 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos
itionInFlatTree(Position(shadowRoot, 0))); | 172 EXPECT_EQ(PositionInFlatTree(host, PositionAnchorType::AfterChildren), toPos
itionInFlatTree(Position(shadowRoot, 0))); |
| 165 } | 173 } |
| 166 | 174 |
| 167 } // namespace blink | 175 } // namespace blink |
| OLD | NEW |