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

Side by Side Diff: Source/core/dom/PositionTest.cpp

Issue 1272973002: Make rendersInDifferentPosition() to work with AfterAnchor and AfterChildren positions properly (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-06T13:43:05 Created 5 years, 4 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/dom/Position.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/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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode()); 95 EXPECT_EQ(t2, Position::inParentAfterNode(*n2).nodeAsRangeLastNode());
96 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode()); 96 EXPECT_EQ(t3, Position::afterNode(host).nodeAsRangeLastNode());
97 97
98 EXPECT_EQ(t2, PositionInComposedTree::inParentBeforeNode(*n1).nodeAsRangeLas tNode()); 98 EXPECT_EQ(t2, PositionInComposedTree::inParentBeforeNode(*n1).nodeAsRangeLas tNode());
99 EXPECT_EQ(a, PositionInComposedTree::inParentBeforeNode(*n2).nodeAsRangeLast Node()); 99 EXPECT_EQ(a, PositionInComposedTree::inParentBeforeNode(*n2).nodeAsRangeLast Node());
100 EXPECT_EQ(t1, PositionInComposedTree::inParentAfterNode(*n1).nodeAsRangeLast Node()); 100 EXPECT_EQ(t1, PositionInComposedTree::inParentAfterNode(*n1).nodeAsRangeLast Node());
101 EXPECT_EQ(t2, PositionInComposedTree::inParentAfterNode(*n2).nodeAsRangeLast Node()); 101 EXPECT_EQ(t2, PositionInComposedTree::inParentAfterNode(*n2).nodeAsRangeLast Node());
102 EXPECT_EQ(t1, PositionInComposedTree::afterNode(host).nodeAsRangeLastNode()) ; 102 EXPECT_EQ(t1, PositionInComposedTree::afterNode(host).nodeAsRangeLastNode()) ;
103 } 103 }
104 104
105 TEST_F(PositionTest, rendersInDifferentPositionAfterAnchor)
106 {
107 const char* bodyContent = "<p id='sample'>00</p>";
108 setBodyContent(bodyContent);
109 updateLayoutAndStyleForPainting();
110 RefPtrWillBeRawPtr<Element> sample = document().getElementById("sample");
111
112 EXPECT_FALSE(Position::afterNode(sample.get()).rendersInDifferentPosition(Po sition(sample.get(), 1)));
113 EXPECT_FALSE(Position::lastPositionInNode(sample.get()).rendersInDifferentPo sition(Position(sample.get(), 1)));
114 }
115
105 TEST_F(PositionTest, ToPositionInComposedTreeWithActiveInsertionPoint) 116 TEST_F(PositionTest, ToPositionInComposedTreeWithActiveInsertionPoint)
106 { 117 {
107 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>"; 118 const char* bodyContent = "<p id='host'>00<b id='one'>11</b>22</p>";
108 const char* shadowContent = "<a id='a'><content select=#one id='content'></c ontent><content></content></a>"; 119 const char* shadowContent = "<a id='a'><content select=#one id='content'></c ontent><content></content></a>";
109 setBodyContent(bodyContent); 120 setBodyContent(bodyContent);
110 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); 121 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
111 RefPtrWillBeRawPtr<Element> anchor = shadowRoot->getElementById("a"); 122 RefPtrWillBeRawPtr<Element> anchor = shadowRoot->getElementById("a");
112 123
113 EXPECT_EQ(PositionInComposedTree(anchor.get(), 0), toPositionInComposedTree( Position(anchor.get(), 0))); 124 EXPECT_EQ(PositionInComposedTree(anchor.get(), 0), toPositionInComposedTree( Position(anchor.get(), 0)));
114 EXPECT_EQ(PositionInComposedTree(anchor.get(), 1), toPositionInComposedTree( Position(anchor.get(), 1))); 125 EXPECT_EQ(PositionInComposedTree(anchor.get(), 1), toPositionInComposedTree( Position(anchor.get(), 1)));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 181
171 RefPtrWillBeRawPtr<Element> host = document().getElementById("host"); 182 RefPtrWillBeRawPtr<Element> host = document().getElementById("host");
172 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); 183 RefPtrWillBeRawPtr<Element> one = document().getElementById("one");
173 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three"); 184 RefPtrWillBeRawPtr<Element> three = shadowRoot->getElementById("three");
174 185
175 EXPECT_EQ(Position(one->firstChild(), 1), Position::afterNode(host.get()).up stream()); 186 EXPECT_EQ(Position(one->firstChild(), 1), Position::afterNode(host.get()).up stream());
176 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), PositionInComposed Tree::afterNode(host.get()).upstream()); 187 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 3), PositionInComposed Tree::afterNode(host.get()).upstream());
177 } 188 }
178 189
179 } // namespace blink 190 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698