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

Side by Side Diff: Source/core/editing/VisibleUnitsTest.cpp

Issue 1311803004: Introduce composed tree version of rightPositionOf() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-09T17:18:38 Rebase Created 5 years, 3 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
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/VisibleUnits.h" 6 #include "core/editing/VisibleUnits.h"
7 7
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include "core/editing/VisiblePosition.h" 9 #include "core/editing/VisiblePosition.h"
10 10
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 const char* bodyContent = "<div contenteditable><span id='sample1'>1</span>< span id='sample2'>22</span></div>"; 284 const char* bodyContent = "<div contenteditable><span id='sample1'>1</span>< span id='sample2'>22</span></div>";
285 setBodyContent(bodyContent); 285 setBodyContent(bodyContent);
286 updateLayoutAndStyleForPainting(); 286 updateLayoutAndStyleForPainting();
287 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1"); 287 RefPtrWillBeRawPtr<Element> sample1 = document().getElementById("sample1");
288 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2"); 288 RefPtrWillBeRawPtr<Element> sample2 = document().getElementById("sample2");
289 289
290 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0))); 290 EXPECT_FALSE(rendersInDifferentPosition(Position::afterNode(sample1->firstCh ild()), Position(sample2->firstChild(), 0)));
291 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0))); 291 EXPECT_FALSE(rendersInDifferentPosition(Position::lastPositionInNode(sample1 ->firstChild()), Position(sample2->firstChild(), 0)));
292 } 292 }
293 293
294 TEST_F(VisibleUnitsTest, rightPositionOf)
295 {
296 const char* bodyContent = "<b id=zero>0</b><p id=host><b id=one>1</b><b id=t wo>22</b></p><b id=three>333</b>";
297 const char* shadowContent = "<p id=four>4444</p><content select=#two></conte nt><content select=#one></content><p id=five>55555</p>";
298 setBodyContent(bodyContent);
299 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
300 updateLayoutAndStyleForPainting();
301
302 Node* one = document().getElementById("one")->firstChild();
303 Node* two = document().getElementById("two")->firstChild();
304 Node* three = document().getElementById("three")->firstChild();
305 Node* four = shadowRoot->getElementById("four")->firstChild();
306 Node* five = shadowRoot->getElementById("five")->firstChild();
307
308 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(one, 1) )).deepEquivalent());
309 EXPECT_EQ(PositionInComposedTree(five, 0), rightPositionOf(createVisiblePosi tion(PositionInComposedTree(one, 1))).deepEquivalent());
310
311 EXPECT_EQ(Position(one, 1), rightPositionOf(createVisiblePosition(Position(t wo, 2))).deepEquivalent());
312 EXPECT_EQ(PositionInComposedTree(one, 1), rightPositionOf(createVisiblePosit ion(PositionInComposedTree(two, 2))).deepEquivalent());
313
314 EXPECT_EQ(Position(five, 0), rightPositionOf(createVisiblePosition(Position( four, 4))).deepEquivalent());
315 EXPECT_EQ(PositionInComposedTree(two, 0), rightPositionOf(createVisiblePosit ion(PositionInComposedTree(four, 4))).deepEquivalent());
316
317 EXPECT_EQ(Position(), rightPositionOf(createVisiblePosition(Position(five, 5 ))).deepEquivalent());
318 EXPECT_EQ(PositionInComposedTree(three, 0), rightPositionOf(createVisiblePos ition(PositionInComposedTree(five, 5))).deepEquivalent());
319 }
320
294 } // namespace blink 321 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698