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

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

Issue 1309963003: Introduce composed tree version of isFirstPositionAfterTable() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-09-08T15:06:09 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host"); 72 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
73 updateLayoutAndStyleForPainting(); 73 updateLayoutAndStyleForPainting();
74 Node* host = document().getElementById("host"); 74 Node* host = document().getElementById("host");
75 Node* one = document().getElementById("one"); 75 Node* one = document().getElementById("one");
76 Node* three = shadowRoot->getElementById("three"); 76 Node* three = shadowRoot->getElementById("three");
77 77
78 EXPECT_EQ(host, enclosingNodeOfType(Position(one, 0), isEnclosingBlock)); 78 EXPECT_EQ(host, enclosingNodeOfType(Position(one, 0), isEnclosingBlock));
79 EXPECT_EQ(three, enclosingNodeOfType(PositionInComposedTree(one, 0), isEnclo singBlock)); 79 EXPECT_EQ(three, enclosingNodeOfType(PositionInComposedTree(one, 0), isEnclo singBlock));
80 } 80 }
81 81
82 TEST_F(EditingUtilitiesTest, isFirstPositionAfterTable)
83 {
84 const char* bodyContent = "<div contenteditable id=host><table id=table><tr> <td>1</td></tr></table><b id=two>22</b></div>";
85 const char* shadowContent = "<content select=#two></content><content select= #table></content>";
86 setBodyContent(bodyContent);
87 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = setShadowContent(shadowContent, "host");
88 updateLayoutAndStyleForPainting();
89 Node* host = document().getElementById("host");
90 Node* table = document().getElementById("table");
91
92 EXPECT_EQ(table, isFirstPositionAfterTable(createVisiblePosition(Position::a fterNode(table))));
93 EXPECT_EQ(table, isFirstPositionAfterTable(createVisiblePosition(PositionInC omposedTree::afterNode(table))));
94
95 EXPECT_EQ(table, isFirstPositionAfterTable(createVisiblePosition(Position::l astPositionInNode(table))));
96 EXPECT_EQ(table, isFirstPositionAfterTable(createVisiblePosition(PositionInC omposedTree::lastPositionInNode(table))));
97
98 EXPECT_EQ(nullptr, isFirstPositionAfterTable(createVisiblePosition(Position( host, 2))));
99 EXPECT_EQ(table, isFirstPositionAfterTable(createVisiblePosition(PositionInC omposedTree(host, 2))));
100
101 EXPECT_EQ(nullptr, isFirstPositionAfterTable(createVisiblePosition(Position: :afterNode(host))));
102 EXPECT_EQ(nullptr, isFirstPositionAfterTable(createVisiblePosition(PositionI nComposedTree::afterNode(host))));
103
104 EXPECT_EQ(nullptr, isFirstPositionAfterTable(createVisiblePosition(Position: :lastPositionInNode(host))));
105 EXPECT_EQ(table, isFirstPositionAfterTable(createVisiblePosition(PositionInC omposedTree::lastPositionInNode(host))));
106 }
107
82 TEST_F(EditingUtilitiesTest, NextNodeIndex) 108 TEST_F(EditingUtilitiesTest, NextNodeIndex)
83 { 109 {
84 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>"; 110 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b>33</p>";
85 const char* shadowContent = "<content select=#two></content><content select= #one></content>"; 111 const char* shadowContent = "<content select=#two></content><content select= #one></content>";
86 setBodyContent(bodyContent); 112 setBodyContent(bodyContent);
87 setShadowContent(shadowContent, "host"); 113 setShadowContent(shadowContent, "host");
88 Node* host = document().getElementById("host"); 114 Node* host = document().getElementById("host");
89 Node* two = document().getElementById("two"); 115 Node* two = document().getElementById("two");
90 116
91 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy pe::CodePoint)); 117 EXPECT_EQ(Position(host, 3), nextPositionOf(Position(two, 2), PositionMoveTy pe::CodePoint));
92 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed Tree(two, 2), PositionMoveType::CodePoint)); 118 EXPECT_EQ(PositionInComposedTree(host, 1), nextPositionOf(PositionInComposed Tree(two, 2), PositionMoveType::CodePoint));
93 } 119 }
94 120
95 TEST_F(EditingUtilitiesTest, NextVisuallyDistinctCandidate) 121 TEST_F(EditingUtilitiesTest, NextVisuallyDistinctCandidate)
96 { 122 {
97 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b><b id='three'>33</b></p>"; 123 const char* bodyContent = "<p id='host'>00<b id='one'>11</b><b id='two'>22</ b><b id='three'>33</b></p>";
98 const char* shadowContent = "<content select=#two></content><content select= #one></content><content select=#three></content>"; 124 const char* shadowContent = "<content select=#two></content><content select= #one></content><content select=#three></content>";
99 setBodyContent(bodyContent); 125 setBodyContent(bodyContent);
100 setShadowContent(shadowContent, "host"); 126 setShadowContent(shadowContent, "host");
101 updateLayoutAndStyleForPainting(); 127 updateLayoutAndStyleForPainting();
102 Node* one = document().getElementById("one"); 128 Node* one = document().getElementById("one");
103 Node* two = document().getElementById("two"); 129 Node* two = document().getElementById("two");
104 Node* three = document().getElementById("three"); 130 Node* three = document().getElementById("three");
105 131
106 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1))); 132 EXPECT_EQ(Position(two->firstChild(), 1), nextVisuallyDistinctCandidate(Posi tion(one, 1)));
107 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1))); 133 EXPECT_EQ(PositionInComposedTree(three->firstChild(), 1), nextVisuallyDistin ctCandidate(PositionInComposedTree(one, 1)));
108 } 134 }
109 135
110 } // namespace blink 136 } // 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