Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp

Issue 2725603002: createFragmentFromMarkupWithContext() should use EphemeralRange. (Closed)
Patch Set: Addressed Review Comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/EphemeralRange.h" 5 #include "core/editing/EphemeralRange.h"
6 6
7 #include "core/dom/Range.h" 7 #include "core/dom/Range.h"
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Tree iterators have only |operator !=| ATM. 141 // Tree iterators have only |operator !=| ATM.
142 EXPECT_FALSE(iterable.begin() != iterable.end()); 142 EXPECT_FALSE(iterable.begin() != iterable.end());
143 143
144 const EphemeralRange singlePositionRange(getBodyRange()->startPosition()); 144 const EphemeralRange singlePositionRange(getBodyRange()->startPosition());
145 EXPECT_FALSE(singlePositionRange.isNull()); 145 EXPECT_FALSE(singlePositionRange.isNull());
146 EXPECT_EQ(std::string(), traverseRange(singlePositionRange)); 146 EXPECT_EQ(std::string(), traverseRange(singlePositionRange));
147 EXPECT_EQ(singlePositionRange.startPosition().nodeAsRangeFirstNode(), 147 EXPECT_EQ(singlePositionRange.startPosition().nodeAsRangeFirstNode(),
148 singlePositionRange.endPosition().nodeAsRangePastLastNode()); 148 singlePositionRange.endPosition().nodeAsRangePastLastNode());
149 } 149 }
150 150
151 TEST_F(EphemeralRangeTest, commonAncesstorDOM) {
152 const char* bodyContent =
153 "<p id='host'>00"
154 "<b id='one'>11</b>"
155 "<b id='two'>22</b>"
156 "<b id='three'>33</b>"
157 "</p>";
158 setBodyContent(bodyContent);
159
160 const Position startPosition(document().getElementById("one"), 0);
161 const Position endPosition(document().getElementById("two"), 0);
162 const EphemeralRange range(startPosition, endPosition);
163 EXPECT_EQ(document().getElementById("host"), range.commonAncestorContainer());
164 }
165
166 TEST_F(EphemeralRangeTest, commonAncesstorFlatTree) {
167 const char* bodyContent =
168 "<b id='zero'>0</b>"
169 "<p id='host'>"
170 "<b id='one'>1</b>"
171 "<b id='two'>22</b>"
172 "</p>"
173 "<b id='three'>333</b>";
174 const char* shadowContent =
175 "<p id='four'>4444</p>"
176 "<content select=#two></content>"
177 "<content select=#one></content>"
178 "<p id='five'>55555</p>";
179 setBodyContent(bodyContent);
180 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host");
181
182 const PositionInFlatTree startPosition(document().getElementById("one"), 0);
183 const PositionInFlatTree endPosition(shadowRoot->getElementById("five"), 0);
184 const EphemeralRangeInFlatTree range(startPosition, endPosition);
185 EXPECT_EQ(document().getElementById("host"), range.commonAncestorContainer());
186 }
187
151 } // namespace blink 188 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698