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" |
9 | 10 |
10 namespace blink { | 11 namespace blink { |
11 | 12 |
12 class PositionTest : public EditingTestBase { | 13 class PositionTest : public EditingTestBase { |
13 }; | 14 }; |
14 | 15 |
15 TEST_F(PositionTest, downstreamAfterAnchor) | |
16 { | |
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>"; | |
19 setBodyContent(bodyContent); | |
20 setShadowContent(shadowContent); | |
21 updateLayoutAndStyleForPainting(); | |
22 | |
23 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | |
24 | |
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()); | |
27 } | |
28 | |
29 // TODO(yoisn) We should move |NextNodeIndex| to "EditingUtilitiesTest.cpp". | 16 // TODO(yoisn) We should move |NextNodeIndex| to "EditingUtilitiesTest.cpp". |
30 TEST_F(PositionTest, NextNodeIndex) | 17 TEST_F(PositionTest, NextNodeIndex) |
31 { | 18 { |
32 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; | 19 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</
b>33</p>"; |
33 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; | 20 const char* shadowContent = "<content select=#two></content><content select=
#one></content>"; |
34 setBodyContent(bodyContent); | 21 setBodyContent(bodyContent); |
35 setShadowContent(shadowContent); | 22 setShadowContent(shadowContent); |
36 Node* host = document().getElementById("host"); | 23 Node* host = document().getElementById("host"); |
37 Node* two = document().getElementById("two"); | 24 Node* two = document().getElementById("two"); |
38 | 25 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 { | 141 { |
155 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; | 142 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; |
156 const char* shadowContent = ""; | 143 const char* shadowContent = ""; |
157 setBodyContent(bodyContent); | 144 setBodyContent(bodyContent); |
158 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); | 145 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); |
159 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | 146 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); |
160 | 147 |
161 EXPECT_EQ(PositionInComposedTree(host, PositionAnchorType::AfterChildren), t
oPositionInComposedTree(Position(shadowRoot.get(), 0))); | 148 EXPECT_EQ(PositionInComposedTree(host, PositionAnchorType::AfterChildren), t
oPositionInComposedTree(Position(shadowRoot.get(), 0))); |
162 } | 149 } |
163 | 150 |
164 TEST_F(PositionTest, upstreamAfterAnchor) | |
165 { | |
166 const char* bodyContent = "<p id='host'><b id='one'>1</b></p>"; | |
167 const char* shadowContent = "<b id='two'>22</b><content select=#one></conten
t><b id='three'>333</b>"; | |
168 setBodyContent(bodyContent); | |
169 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); | |
170 updateLayoutAndStyleForPainting(); | |
171 | |
172 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); | |
173 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | |
174 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); | |
175 | |
176 EXPECT_EQ(Position(one->firstChild(), 1), Position::afterNode(host.get()).up
stream()); | |
177 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), PositionInComposed
Tree::afterNode(host.get()).upstream()); | |
178 } | |
179 | |
180 } // namespace blink | 151 } // namespace blink |
OLD | NEW |