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

Side by Side Diff: third_party/WebKit/Source/core/editing/EphemeralRangeTest.cpp

Issue 2282683002: Use Node stream printer in Node::showNode(). (Closed)
Patch Set: Do not print addresses Created 4 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 | « third_party/WebKit/Source/core/dom/Node.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "core/editing/EphemeralRange.h" 5 #include "core/editing/EphemeralRange.h"
6 6
7 #include "core/dom/Range.h" 7 #include "core/dom/Range.h"
8 #include "core/editing/EditingTestBase.h" 8 #include "core/editing/EditingTestBase.h"
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 const char* bodyContent = "<p id='host'><b id='one'></b><input type='text' v alue='some'></p>"; 76 const char* bodyContent = "<p id='host'><b id='one'></b><input type='text' v alue='some'></p>";
77 setBodyContent(bodyContent); 77 setBodyContent(bodyContent);
78 78
79 EXPECT_EQ( 79 EXPECT_EQ(
80 "[BODY][P id=\"host\"][B id=\"one\"][INPUT]", 80 "[BODY][P id=\"host\"][B id=\"one\"][INPUT]",
81 traverseRange<>(getBodyRange())); 81 traverseRange<>(getBodyRange()));
82 EXPECT_EQ(traverseRange<>(getBodyRange()), traverseRange(EphemeralRange(getB odyRange()))); 82 EXPECT_EQ(traverseRange<>(getBodyRange()), traverseRange(EphemeralRange(getB odyRange())));
83 83
84 // In this case FlatTree traverse should differs from DOM tree traverse. 84 // In this case FlatTree traverse should differs from DOM tree traverse.
85 EXPECT_EQ( 85 EXPECT_EQ(
86 "[BODY][P id=\"host\"][B id=\"one\"][INPUT][DIV id=\"inner-editor\"][#te xt \"some\"]", 86 "[BODY][P id=\"host\"][B id=\"one\"][INPUT][DIV id=\"inner-editor\" (edi table)][#text \"some\"]",
87 traverseRange<FlatTreeTraversal>(getBodyRange())); 87 traverseRange<FlatTreeTraversal>(getBodyRange()));
88 EXPECT_EQ( 88 EXPECT_EQ(
89 traverseRange<FlatTreeTraversal>(getBodyRange()), 89 traverseRange<FlatTreeTraversal>(getBodyRange()),
90 traverseRange(EphemeralRangeInFlatTree(getBodyRange()))); 90 traverseRange(EphemeralRangeInFlatTree(getBodyRange())));
91 } 91 }
92 92
93 // Limit a range and check that it will be traversed correctly. 93 // Limit a range and check that it will be traversed correctly.
94 TEST_F(EphemeralRangeTest, rangeTraversalLimited) 94 TEST_F(EphemeralRangeTest, rangeTraversalLimited)
95 { 95 {
96 const char* bodyContent = "<p id='host'><b id='one'></b><input type='text' v alue='some'><span id='two'></p>"; 96 const char* bodyContent = "<p id='host'><b id='one'></b><input type='text' v alue='some'><span id='two'></p>";
(...skipping 19 matching lines...) Expand all
116 Range* fromBToSpan = getBodyRange(); 116 Range* fromBToSpan = getBodyRange();
117 fromBToSpan->setStart(document().getElementById("one"), 0, IGNORE_EXCEPTION) ; 117 fromBToSpan->setStart(document().getElementById("one"), 0, IGNORE_EXCEPTION) ;
118 fromBToSpan->setEnd(document().getElementById("two"), 0, IGNORE_EXCEPTION); 118 fromBToSpan->setEnd(document().getElementById("two"), 0, IGNORE_EXCEPTION);
119 119
120 EXPECT_EQ( 120 EXPECT_EQ(
121 "[B id=\"one\"][INPUT][SPAN id=\"two\"]", 121 "[B id=\"one\"][INPUT][SPAN id=\"two\"]",
122 traverseRange<>(fromBToSpan)); 122 traverseRange<>(fromBToSpan));
123 EXPECT_EQ(traverseRange<>(fromBToSpan), traverseRange(EphemeralRange(fromBTo Span))); 123 EXPECT_EQ(traverseRange<>(fromBToSpan), traverseRange(EphemeralRange(fromBTo Span)));
124 124
125 EXPECT_EQ( 125 EXPECT_EQ(
126 "[B id=\"one\"][INPUT][DIV id=\"inner-editor\"][#text \"some\"][SPAN id= \"two\"]", 126 "[B id=\"one\"][INPUT][DIV id=\"inner-editor\" (editable)][#text \"some\ "][SPAN id=\"two\"]",
127 traverseRange<FlatTreeTraversal>(fromBToSpan)); 127 traverseRange<FlatTreeTraversal>(fromBToSpan));
128 EXPECT_EQ( 128 EXPECT_EQ(
129 traverseRange<FlatTreeTraversal>(fromBToSpan), 129 traverseRange<FlatTreeTraversal>(fromBToSpan),
130 traverseRange(EphemeralRangeInFlatTree(fromBToSpan))); 130 traverseRange(EphemeralRangeInFlatTree(fromBToSpan)));
131 } 131 }
132 132
133 TEST_F(EphemeralRangeTest, traversalEmptyRanges) 133 TEST_F(EphemeralRangeTest, traversalEmptyRanges)
134 { 134 {
135 const char* bodyContent = "<p id='host'><b id='one'></b></p>"; 135 const char* bodyContent = "<p id='host'><b id='one'></b></p>";
136 setBodyContent(bodyContent); 136 setBodyContent(bodyContent);
137 137
138 // Expect no iterations in loop for an empty EphemeralRange. 138 // Expect no iterations in loop for an empty EphemeralRange.
139 EXPECT_EQ(std::string(), traverseRange(EphemeralRange())); 139 EXPECT_EQ(std::string(), traverseRange(EphemeralRange()));
140 140
141 auto iterable = EphemeralRange().nodes(); 141 auto iterable = EphemeralRange().nodes();
142 // Tree iterators have only |operator !=| ATM. 142 // Tree iterators have only |operator !=| ATM.
143 EXPECT_FALSE(iterable.begin() != iterable.end()); 143 EXPECT_FALSE(iterable.begin() != iterable.end());
144 144
145 const EphemeralRange singlePositionRange(getBodyRange()->startPosition()); 145 const EphemeralRange singlePositionRange(getBodyRange()->startPosition());
146 EXPECT_FALSE(singlePositionRange.isNull()); 146 EXPECT_FALSE(singlePositionRange.isNull());
147 EXPECT_EQ(std::string(), traverseRange(singlePositionRange)); 147 EXPECT_EQ(std::string(), traverseRange(singlePositionRange));
148 EXPECT_EQ( 148 EXPECT_EQ(
149 singlePositionRange.startPosition().nodeAsRangeFirstNode(), 149 singlePositionRange.startPosition().nodeAsRangeFirstNode(),
150 singlePositionRange.endPosition().nodeAsRangePastLastNode()); 150 singlePositionRange.endPosition().nodeAsRangePastLastNode());
151 } 151 }
152 152
153 } // namespace blink 153 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698