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

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

Issue 1201403002: Make VisiblePosition constructor to canonicalize a position in composed tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-25T17:29:10 Update use-events-crash.svg expectations Created 5 years, 6 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/VisiblePosition.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/VisiblePosition.h" 6 #include "core/editing/VisiblePosition.h"
7 7
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 class VisiblePositionTest : public EditingTestBase { 12 class VisiblePositionTest : public EditingTestBase {
13 }; 13 };
14 14
15 TEST_F(VisiblePositionTest, ShadowDistributedNodes) 15 TEST_F(VisiblePositionTest, ShadowDistributedNodes)
16 { 16 {
17 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; 17 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>";
18 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>"; 18 const char* shadowContent = "<a><span id='s4'>44</span><content select=#two> </content><span id='s5'>55</span><content select=#one></content><span id='s6'>66 </span></a>";
19 setBodyContent(bodyContent); 19 setBodyContent(bodyContent);
20 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); 20 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
21 21
22 RefPtrWillBeRawPtr<Element> body = document().body(); 22 RefPtrWillBeRawPtr<Element> body = document().body();
23 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION); 23 RefPtrWillBeRawPtr<Element> one = body->querySelector("#one", ASSERT_NO_EXCE PTION);
24 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION); 24 RefPtrWillBeRawPtr<Element> two = body->querySelector("#two", ASSERT_NO_EXCE PTION);
25 RefPtrWillBeRawPtr<Element> four = shadowRoot->querySelector("#s4", ASSERT_N O_EXCEPTION); 25 RefPtrWillBeRawPtr<Element> four = shadowRoot->querySelector("#s4", ASSERT_N O_EXCEPTION);
26 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N O_EXCEPTION); 26 RefPtrWillBeRawPtr<Element> five = shadowRoot->querySelector("#s5", ASSERT_N O_EXCEPTION);
27 27
28 EXPECT_EQ(positionInDOMTree(*one->firstChild(), 0), canonicalPositionOf(posi tionInDOMTree(*one, 0))); 28 EXPECT_EQ(positionInDOMTree(*one->firstChild(), 0), canonicalPositionOf(posi tionInDOMTree(*one, 0)));
29 EXPECT_EQ(positionInDOMTree(*one->firstChild(), 0), VisiblePosition(position InDOMTree(*one, 0)).deepEquivalent());
29 EXPECT_EQ(positionInDOMTree(*one->firstChild(), 2), canonicalPositionOf(posi tionInDOMTree(*two, 0))); 30 EXPECT_EQ(positionInDOMTree(*one->firstChild(), 2), canonicalPositionOf(posi tionInDOMTree(*two, 0)));
31 EXPECT_EQ(positionInDOMTree(*one->firstChild(), 2), VisiblePosition(position InDOMTree(*two, 0)).deepEquivalent());
30 32
31 EXPECT_EQ(positionInComposedTree(*five->firstChild(), 2), canonicalPositionO f(positionInComposedTree(*one, 0))); 33 EXPECT_EQ(positionInComposedTree(*five->firstChild(), 2), canonicalPositionO f(positionInComposedTree(*one, 0)));
34 EXPECT_EQ(positionInDOMTree(*five->firstChild(), 2), VisiblePosition(positio nInComposedTree(*one, 0)).deepEquivalent());
32 EXPECT_EQ(positionInComposedTree(*four->firstChild(), 2), canonicalPositionO f(positionInComposedTree(*two, 0))); 35 EXPECT_EQ(positionInComposedTree(*four->firstChild(), 2), canonicalPositionO f(positionInComposedTree(*two, 0)));
36 EXPECT_EQ(positionInDOMTree(*four->firstChild(), 2), VisiblePosition(positio nInComposedTree(*two, 0)).deepEquivalent());
33 } 37 }
34 38
35 } // namespace blink 39 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/VisiblePosition.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698