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

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

Issue 1310073006: Introduce PositionInComposedTree version of enclosingBlock() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-27T15:40:36 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/EditingUtilities.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/EditingUtilities.h" 6 #include "core/editing/EditingUtilities.h"
7 7
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 13 matching lines...) Expand all
24 Node* three = shadowRoot->getElementById("three"); 24 Node* three = shadowRoot->getElementById("three");
25 25
26 EXPECT_EQ(Position(one, 0), firstEditablePositionAfterPositionInRoot(Positio n(one, 0), host)); 26 EXPECT_EQ(Position(one, 0), firstEditablePositionAfterPositionInRoot(Positio n(one, 0), host));
27 27
28 EXPECT_EQ(PositionInComposedTree(one, 0), firstEditablePositionAfterPosition InRoot(PositionInComposedTree(one, 0), host)); 28 EXPECT_EQ(PositionInComposedTree(one, 0), firstEditablePositionAfterPosition InRoot(PositionInComposedTree(one, 0), host));
29 29
30 EXPECT_EQ(Position::firstPositionInNode(host), firstEditablePositionAfterPos itionInRoot(Position(three, 0), host)); 30 EXPECT_EQ(Position::firstPositionInNode(host), firstEditablePositionAfterPos itionInRoot(Position(three, 0), host));
31 EXPECT_EQ(PositionInComposedTree::afterNode(host), firstEditablePositionAfte rPositionInRoot(PositionInComposedTree(three, 0), host)); 31 EXPECT_EQ(PositionInComposedTree::afterNode(host), firstEditablePositionAfte rPositionInRoot(PositionInComposedTree(three, 0), host));
32 } 32 }
33 33
34 TEST_F(EditingUtilitiesTest, enclosingBlock)
35 {
36 const char* bodyContent = "<p id='host'><b id='one'>11</b></p>";
37 const char* shadowContent = "<content select=#two></content><div id='three'> <content select=#one></content></div>";
38 setBodyContent(bodyContent);
39 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
40 updateLayoutAndStyleForPainting();
41 Node* host = document().getElementById("host");
42 Node* one = document().getElementById("one");
43 Node* three = shadowRoot->getElementById("three");
44
45 EXPECT_EQ(host, enclosingBlock(Position(one, 0), CannotCrossEditingBoundary) );
46 EXPECT_EQ(three, enclosingBlock(PositionInComposedTree(one, 0), CannotCrossE ditingBoundary));
47 }
48
34 TEST_F(EditingUtilitiesTest, enclosingNodeOfType) 49 TEST_F(EditingUtilitiesTest, enclosingNodeOfType)
35 { 50 {
36 const char* bodyContent = "<p id='host'><b id='one'>11</b></p>"; 51 const char* bodyContent = "<p id='host'><b id='one'>11</b></p>";
37 const char* shadowContent = "<content select=#two></content><div id='three'> <content select=#one></div></content>"; 52 const char* shadowContent = "<content select=#two></content><div id='three'> <content select=#one></div></content>";
38 setBodyContent(bodyContent); 53 setBodyContent(bodyContent);
39 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent); 54 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent);
40 updateLayoutAndStyleForPainting(); 55 updateLayoutAndStyleForPainting();
41 Node* host = document().getElementById("host"); 56 Node* host = document().getElementById("host");
42 Node* one = document().getElementById("one"); 57 Node* one = document().getElementById("one");
43 Node* three = shadowRoot->getElementById("three"); 58 Node* three = shadowRoot->getElementById("three");
(...skipping 24 matching lines...) Expand all
68 updateLayoutAndStyleForPainting(); 83 updateLayoutAndStyleForPainting();
69 Node* one = document().getElementById("one"); 84 Node* one = document().getElementById("one");
70 Node* two = document().getElementById("two"); 85 Node* two = document().getElementById("two");
71 Node* three = document().getElementById("three"); 86 Node* three = document().getElementById("three");
72 87
73 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1))); 88 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1)));
74 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1))); 89 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1)));
75 } 90 }
76 91
77 } // namespace blink 92 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/EditingUtilities.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698