OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "core/editing/EditingTestBase.h" | 33 #include "core/editing/EditingTestBase.h" |
34 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 struct DOMTree : NodeTraversal { | 38 struct DOMTree : NodeTraversal { |
39 using PositionType = Position; | 39 using PositionType = Position; |
40 using TextIteratorType = TextIterator; | 40 using TextIteratorType = TextIterator; |
41 }; | 41 }; |
42 | 42 |
43 struct ComposedTree : ComposedTreeTraversal { | 43 struct FlatTree : FlatTreeTraversal { |
44 using PositionType = PositionInComposedTree; | 44 using PositionType = PositionInFlatTree; |
45 using TextIteratorType = TextIteratorInComposedTree; | 45 using TextIteratorType = TextIteratorInFlatTree; |
46 }; | 46 }; |
47 | 47 |
48 class TextIteratorTest : public EditingTestBase { | 48 class TextIteratorTest : public EditingTestBase { |
49 protected: | 49 protected: |
50 template <typename Tree> | 50 template <typename Tree> |
51 std::string iterate(TextIteratorBehavior = TextIteratorDefaultBehavior); | 51 std::string iterate(TextIteratorBehavior = TextIteratorDefaultBehavior); |
52 | 52 |
53 template <typename Tree> | 53 template <typename Tree> |
54 std::string iteratePartial(const typename Tree::PositionType& start, const t
ypename Tree::PositionType& end, TextIteratorBehavior = TextIteratorDefaultBehav
ior); | 54 std::string iteratePartial(const typename Tree::PositionType& start, const t
ypename Tree::PositionType& end, TextIteratorBehavior = TextIteratorDefaultBehav
ior); |
55 | 55 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 bs.pop(); | 108 bs.pop(); |
109 | 109 |
110 EXPECT_TRUE(bs.top()); | 110 EXPECT_TRUE(bs.top()); |
111 } | 111 } |
112 | 112 |
113 TEST_F(TextIteratorTest, BasicIteration) | 113 TEST_F(TextIteratorTest, BasicIteration) |
114 { | 114 { |
115 static const char* input = "<p>Hello, \ntext</p><p>iterator.</p>"; | 115 static const char* input = "<p>Hello, \ntext</p><p>iterator.</p>"; |
116 setBodyContent(input); | 116 setBodyContent(input); |
117 EXPECT_EQ("[Hello, ][text][\n][\n][iterator.]", iterate<DOMTree>()); | 117 EXPECT_EQ("[Hello, ][text][\n][\n][iterator.]", iterate<DOMTree>()); |
118 EXPECT_EQ("[Hello, ][text][\n][\n][iterator.]", iterate<ComposedTree>()); | 118 EXPECT_EQ("[Hello, ][text][\n][\n][iterator.]", iterate<FlatTree>()); |
119 } | 119 } |
120 | 120 |
121 TEST_F(TextIteratorTest, IgnoreAltTextInTextControls) | 121 TEST_F(TextIteratorTest, IgnoreAltTextInTextControls) |
122 { | 122 { |
123 static const char* input = "<p>Hello <input type='text' value='value'>!</p>"
; | 123 static const char* input = "<p>Hello <input type='text' value='value'>!</p>"
; |
124 setBodyContent(input); | 124 setBodyContent(input); |
125 EXPECT_EQ("[Hello ][][!]", iterate<DOMTree>(TextIteratorEmitsImageAltText)); | 125 EXPECT_EQ("[Hello ][][!]", iterate<DOMTree>(TextIteratorEmitsImageAltText)); |
126 EXPECT_EQ("[Hello ][][\n][value][\n][!]", iterate<ComposedTree>(TextIterator
EmitsImageAltText)); | 126 EXPECT_EQ("[Hello ][][\n][value][\n][!]", iterate<FlatTree>(TextIteratorEmit
sImageAltText)); |
127 } | 127 } |
128 | 128 |
129 TEST_F(TextIteratorTest, DisplayAltTextInImageControls) | 129 TEST_F(TextIteratorTest, DisplayAltTextInImageControls) |
130 { | 130 { |
131 static const char* input = "<p>Hello <input type='image' alt='alt'>!</p>"; | 131 static const char* input = "<p>Hello <input type='image' alt='alt'>!</p>"; |
132 setBodyContent(input); | 132 setBodyContent(input); |
133 EXPECT_EQ("[Hello ][alt][!]", iterate<DOMTree>(TextIteratorEmitsImageAltText
)); | 133 EXPECT_EQ("[Hello ][alt][!]", iterate<DOMTree>(TextIteratorEmitsImageAltText
)); |
134 EXPECT_EQ("[Hello ][alt][!]", iterate<ComposedTree>(TextIteratorEmitsImageAl
tText)); | 134 EXPECT_EQ("[Hello ][alt][!]", iterate<FlatTree>(TextIteratorEmitsImageAltTex
t)); |
135 } | 135 } |
136 | 136 |
137 TEST_F(TextIteratorTest, NotEnteringTextControls) | 137 TEST_F(TextIteratorTest, NotEnteringTextControls) |
138 { | 138 { |
139 static const char* input = "<p>Hello <input type='text' value='input'>!</p>"
; | 139 static const char* input = "<p>Hello <input type='text' value='input'>!</p>"
; |
140 setBodyContent(input); | 140 setBodyContent(input); |
141 EXPECT_EQ("[Hello ][][!]", iterate<DOMTree>()); | 141 EXPECT_EQ("[Hello ][][!]", iterate<DOMTree>()); |
142 EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<ComposedTree>()); | 142 EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<FlatTree>()); |
143 } | 143 } |
144 | 144 |
145 TEST_F(TextIteratorTest, EnteringTextControlsWithOption) | 145 TEST_F(TextIteratorTest, EnteringTextControlsWithOption) |
146 { | 146 { |
147 static const char* input = "<p>Hello <input type='text' value='input'>!</p>"
; | 147 static const char* input = "<p>Hello <input type='text' value='input'>!</p>"
; |
148 setBodyContent(input); | 148 setBodyContent(input); |
149 EXPECT_EQ("[Hello ][\n][input][!]", iterate<DOMTree>(TextIteratorEntersTextC
ontrols)); | 149 EXPECT_EQ("[Hello ][\n][input][!]", iterate<DOMTree>(TextIteratorEntersTextC
ontrols)); |
150 EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<ComposedTree>(TextIterator
EntersTextControls)); | 150 EXPECT_EQ("[Hello ][][\n][input][\n][!]", iterate<FlatTree>(TextIteratorEnte
rsTextControls)); |
151 } | 151 } |
152 | 152 |
153 TEST_F(TextIteratorTest, EnteringTextControlsWithOptionComplex) | 153 TEST_F(TextIteratorTest, EnteringTextControlsWithOptionComplex) |
154 { | 154 { |
155 static const char* input = "<input type='text' value='Beginning of range'><d
iv><div><input type='text' value='Under DOM nodes'></div></div><input type='text
' value='End of range'>"; | 155 static const char* input = "<input type='text' value='Beginning of range'><d
iv><div><input type='text' value='Under DOM nodes'></div></div><input type='text
' value='End of range'>"; |
156 setBodyContent(input); | 156 setBodyContent(input); |
157 EXPECT_EQ("[\n][Beginning of range][\n][Under DOM nodes][\n][End of range]",
iterate<DOMTree>(TextIteratorEntersTextControls)); | 157 EXPECT_EQ("[\n][Beginning of range][\n][Under DOM nodes][\n][End of range]",
iterate<DOMTree>(TextIteratorEntersTextControls)); |
158 EXPECT_EQ("[][\n][Beginning of range][\n][][\n][Under DOM nodes][\n][][\n][E
nd of range]", iterate<ComposedTree>(TextIteratorEntersTextControls)); | 158 EXPECT_EQ("[][\n][Beginning of range][\n][][\n][Under DOM nodes][\n][][\n][E
nd of range]", iterate<FlatTree>(TextIteratorEntersTextControls)); |
159 } | 159 } |
160 | 160 |
161 TEST_F(TextIteratorTest, NotEnteringTextControlHostingShadowTreeEvenWithOption) | 161 TEST_F(TextIteratorTest, NotEnteringTextControlHostingShadowTreeEvenWithOption) |
162 { | 162 { |
163 static const char* bodyContent = "<div>Hello, <input type='text' value='inpu
t' id='input'> iterator.</div>"; | 163 static const char* bodyContent = "<div>Hello, <input type='text' value='inpu
t' id='input'> iterator.</div>"; |
164 static const char* shadowContent = "<span>shadow</span>"; | 164 static const char* shadowContent = "<span>shadow</span>"; |
165 // TextIterator doesn't emit "input" nor "shadow" since (1) the layoutObject
for <input> is not created; and | 165 // TextIterator doesn't emit "input" nor "shadow" since (1) the layoutObject
for <input> is not created; and |
166 // (2) we don't (yet) recurse into shadow trees. | 166 // (2) we don't (yet) recurse into shadow trees. |
167 setBodyContent(bodyContent); | 167 setBodyContent(bodyContent); |
168 createShadowRootForElementWithIDAndSetInnerHTML(document(), "input", shadowC
ontent); | 168 createShadowRootForElementWithIDAndSetInnerHTML(document(), "input", shadowC
ontent); |
169 // FIXME: Why is an empty string emitted here? | 169 // FIXME: Why is an empty string emitted here? |
170 EXPECT_EQ("[Hello, ][][ iterator.]", iterate<DOMTree>()); | 170 EXPECT_EQ("[Hello, ][][ iterator.]", iterate<DOMTree>()); |
171 EXPECT_EQ("[Hello, ][][shadow][ iterator.]", iterate<ComposedTree>()); | 171 EXPECT_EQ("[Hello, ][][shadow][ iterator.]", iterate<FlatTree>()); |
172 } | 172 } |
173 | 173 |
174 TEST_F(TextIteratorTest, NotEnteringShadowTree) | 174 TEST_F(TextIteratorTest, NotEnteringShadowTree) |
175 { | 175 { |
176 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; | 176 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; |
177 static const char* shadowContent = "<span>shadow</span>"; | 177 static const char* shadowContent = "<span>shadow</span>"; |
178 setBodyContent(bodyContent); | 178 setBodyContent(bodyContent); |
179 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 179 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
180 // TextIterator doesn't emit "text" since its layoutObject is not created. T
he shadow tree is ignored. | 180 // TextIterator doesn't emit "text" since its layoutObject is not created. T
he shadow tree is ignored. |
181 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); | 181 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); |
182 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<ComposedTree>()); | 182 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<FlatTree>()); |
183 } | 183 } |
184 | 184 |
185 TEST_F(TextIteratorTest, NotEnteringShadowTreeWithMultipleShadowTrees) | 185 TEST_F(TextIteratorTest, NotEnteringShadowTreeWithMultipleShadowTrees) |
186 { | 186 { |
187 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; | 187 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; |
188 static const char* shadowContent1 = "<span>first shadow</span>"; | 188 static const char* shadowContent1 = "<span>first shadow</span>"; |
189 static const char* shadowContent2 = "<span>second shadow</span>"; | 189 static const char* shadowContent2 = "<span>second shadow</span>"; |
190 setBodyContent(bodyContent); | 190 setBodyContent(bodyContent); |
191 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent1); | 191 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent1); |
192 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent2); | 192 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent2); |
193 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); | 193 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); |
194 EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<ComposedTree>()); | 194 EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<FlatTree>()); |
195 } | 195 } |
196 | 196 |
197 TEST_F(TextIteratorTest, NotEnteringShadowTreeWithNestedShadowTrees) | 197 TEST_F(TextIteratorTest, NotEnteringShadowTreeWithNestedShadowTrees) |
198 { | 198 { |
199 static const char* bodyContent = "<div>Hello, <span id='host-in-document'>te
xt</span> iterator.</div>"; | 199 static const char* bodyContent = "<div>Hello, <span id='host-in-document'>te
xt</span> iterator.</div>"; |
200 static const char* shadowContent1 = "<span>first <span id='host-in-shadow'>s
hadow</span></span>"; | 200 static const char* shadowContent1 = "<span>first <span id='host-in-shadow'>s
hadow</span></span>"; |
201 static const char* shadowContent2 = "<span>second shadow</span>"; | 201 static const char* shadowContent2 = "<span>second shadow</span>"; |
202 setBodyContent(bodyContent); | 202 setBodyContent(bodyContent); |
203 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = createShadowRootForElementWithI
DAndSetInnerHTML(document(), "host-in-document", shadowContent1); | 203 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = createShadowRootForElementWithI
DAndSetInnerHTML(document(), "host-in-document", shadowContent1); |
204 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host-in-shado
w", shadowContent2); | 204 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host-in-shado
w", shadowContent2); |
205 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); | 205 EXPECT_EQ("[Hello, ][ iterator.]", iterate<DOMTree>()); |
206 EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<ComposedTr
ee>()); | 206 EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<FlatTree>(
)); |
207 } | 207 } |
208 | 208 |
209 TEST_F(TextIteratorTest, NotEnteringShadowTreeWithContentInsertionPoint) | 209 TEST_F(TextIteratorTest, NotEnteringShadowTreeWithContentInsertionPoint) |
210 { | 210 { |
211 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; | 211 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; |
212 static const char* shadowContent = "<span>shadow <content>content</content><
/span>"; | 212 static const char* shadowContent = "<span>shadow <content>content</content><
/span>"; |
213 setBodyContent(bodyContent); | 213 setBodyContent(bodyContent); |
214 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 214 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
215 // In this case a layoutObject for "text" is created, so it shows up here. | 215 // In this case a layoutObject for "text" is created, so it shows up here. |
216 EXPECT_EQ("[Hello, ][text][ iterator.]", iterate<DOMTree>()); | 216 EXPECT_EQ("[Hello, ][text][ iterator.]", iterate<DOMTree>()); |
217 EXPECT_EQ("[Hello, ][shadow ][text][ iterator.]", iterate<ComposedTree>()); | 217 EXPECT_EQ("[Hello, ][shadow ][text][ iterator.]", iterate<FlatTree>()); |
218 } | 218 } |
219 | 219 |
220 TEST_F(TextIteratorTest, EnteringShadowTreeWithOption) | 220 TEST_F(TextIteratorTest, EnteringShadowTreeWithOption) |
221 { | 221 { |
222 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; | 222 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; |
223 static const char* shadowContent = "<span>shadow</span>"; | 223 static const char* shadowContent = "<span>shadow</span>"; |
224 setBodyContent(bodyContent); | 224 setBodyContent(bodyContent); |
225 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 225 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
226 // TextIterator emits "shadow" since TextIteratorEntersOpenShadowRoots is sp
ecified. | 226 // TextIterator emits "shadow" since TextIteratorEntersOpenShadowRoots is sp
ecified. |
227 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<DOMTree>(TextIteratorEnte
rsOpenShadowRoots)); | 227 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<DOMTree>(TextIteratorEnte
rsOpenShadowRoots)); |
228 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<ComposedTree>(TextIterato
rEntersOpenShadowRoots)); | 228 EXPECT_EQ("[Hello, ][shadow][ iterator.]", iterate<FlatTree>(TextIteratorEnt
ersOpenShadowRoots)); |
229 } | 229 } |
230 | 230 |
231 TEST_F(TextIteratorTest, EnteringShadowTreeWithMultipleShadowTreesWithOption) | 231 TEST_F(TextIteratorTest, EnteringShadowTreeWithMultipleShadowTreesWithOption) |
232 { | 232 { |
233 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; | 233 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; |
234 static const char* shadowContent1 = "<span>first shadow</span>"; | 234 static const char* shadowContent1 = "<span>first shadow</span>"; |
235 static const char* shadowContent2 = "<span>second shadow</span>"; | 235 static const char* shadowContent2 = "<span>second shadow</span>"; |
236 setBodyContent(bodyContent); | 236 setBodyContent(bodyContent); |
237 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent1); | 237 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent1); |
238 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent2); | 238 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent2); |
239 // The first isn't emitted because a layoutObject for the first is not creat
ed. | 239 // The first isn't emitted because a layoutObject for the first is not creat
ed. |
240 EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<DOMTree>(TextItera
torEntersOpenShadowRoots)); | 240 EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<DOMTree>(TextItera
torEntersOpenShadowRoots)); |
241 EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<ComposedTree>(Text
IteratorEntersOpenShadowRoots)); | 241 EXPECT_EQ("[Hello, ][second shadow][ iterator.]", iterate<FlatTree>(TextIter
atorEntersOpenShadowRoots)); |
242 } | 242 } |
243 | 243 |
244 TEST_F(TextIteratorTest, EnteringShadowTreeWithNestedShadowTreesWithOption) | 244 TEST_F(TextIteratorTest, EnteringShadowTreeWithNestedShadowTreesWithOption) |
245 { | 245 { |
246 static const char* bodyContent = "<div>Hello, <span id='host-in-document'>te
xt</span> iterator.</div>"; | 246 static const char* bodyContent = "<div>Hello, <span id='host-in-document'>te
xt</span> iterator.</div>"; |
247 static const char* shadowContent1 = "<span>first <span id='host-in-shadow'>s
hadow</span></span>"; | 247 static const char* shadowContent1 = "<span>first <span id='host-in-shadow'>s
hadow</span></span>"; |
248 static const char* shadowContent2 = "<span>second shadow</span>"; | 248 static const char* shadowContent2 = "<span>second shadow</span>"; |
249 setBodyContent(bodyContent); | 249 setBodyContent(bodyContent); |
250 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = createShadowRootForElementWithI
DAndSetInnerHTML(document(), "host-in-document", shadowContent1); | 250 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = createShadowRootForElementWithI
DAndSetInnerHTML(document(), "host-in-document", shadowContent1); |
251 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host-in-shado
w", shadowContent2); | 251 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host-in-shado
w", shadowContent2); |
252 EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<DOMTree>(T
extIteratorEntersOpenShadowRoots)); | 252 EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<DOMTree>(T
extIteratorEntersOpenShadowRoots)); |
253 EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<ComposedTr
ee>(TextIteratorEntersOpenShadowRoots)); | 253 EXPECT_EQ("[Hello, ][first ][second shadow][ iterator.]", iterate<FlatTree>(
TextIteratorEntersOpenShadowRoots)); |
254 } | 254 } |
255 | 255 |
256 TEST_F(TextIteratorTest, EnteringShadowTreeWithContentInsertionPointWithOption) | 256 TEST_F(TextIteratorTest, EnteringShadowTreeWithContentInsertionPointWithOption) |
257 { | 257 { |
258 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; | 258 static const char* bodyContent = "<div>Hello, <span id='host'>text</span> it
erator.</div>"; |
259 static const char* shadowContent = "<span><content>content</content> shadow<
/span>"; | 259 static const char* shadowContent = "<span><content>content</content> shadow<
/span>"; |
260 // In this case a layoutObject for "text" is created, and emitted AFTER any
nodes in the shadow tree. | 260 // In this case a layoutObject for "text" is created, and emitted AFTER any
nodes in the shadow tree. |
261 // This order does not match the order of the rendered texts, but at this mo
ment it's the expected behavior. | 261 // This order does not match the order of the rendered texts, but at this mo
ment it's the expected behavior. |
262 // FIXME: Fix this. We probably need pure-renderer-based implementation of T
extIterator to achieve this. | 262 // FIXME: Fix this. We probably need pure-renderer-based implementation of T
extIterator to achieve this. |
263 setBodyContent(bodyContent); | 263 setBodyContent(bodyContent); |
264 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 264 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
265 EXPECT_EQ("[Hello, ][ shadow][text][ iterator.]", iterate<DOMTree>(TextItera
torEntersOpenShadowRoots)); | 265 EXPECT_EQ("[Hello, ][ shadow][text][ iterator.]", iterate<DOMTree>(TextItera
torEntersOpenShadowRoots)); |
266 EXPECT_EQ("[Hello, ][text][ shadow][ iterator.]", iterate<ComposedTree>(Text
IteratorEntersOpenShadowRoots)); | 266 EXPECT_EQ("[Hello, ][text][ shadow][ iterator.]", iterate<FlatTree>(TextIter
atorEntersOpenShadowRoots)); |
267 } | 267 } |
268 | 268 |
269 TEST_F(TextIteratorTest, StartingAtNodeInShadowRoot) | 269 TEST_F(TextIteratorTest, StartingAtNodeInShadowRoot) |
270 { | 270 { |
271 static const char* bodyContent = "<div id='outer'>Hello, <span id='host'>tex
t</span> iterator.</div>"; | 271 static const char* bodyContent = "<div id='outer'>Hello, <span id='host'>tex
t</span> iterator.</div>"; |
272 static const char* shadowContent = "<span><content>content</content> shadow<
/span>"; | 272 static const char* shadowContent = "<span><content>content</content> shadow<
/span>"; |
273 setBodyContent(bodyContent); | 273 setBodyContent(bodyContent); |
274 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootForElementWithID
AndSetInnerHTML(document(), "host", shadowContent); | 274 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootForElementWithID
AndSetInnerHTML(document(), "host", shadowContent); |
275 Node* outerDiv = document().getElementById("outer"); | 275 Node* outerDiv = document().getElementById("outer"); |
276 Node* spanInShadow = shadowRoot->firstChild(); | 276 Node* spanInShadow = shadowRoot->firstChild(); |
277 Position start(spanInShadow, PositionAnchorType::BeforeChildren); | 277 Position start(spanInShadow, PositionAnchorType::BeforeChildren); |
278 Position end(outerDiv, PositionAnchorType::AfterChildren); | 278 Position end(outerDiv, PositionAnchorType::AfterChildren); |
279 EXPECT_EQ("[ shadow][text][ iterator.]", iteratePartial<DOMTree>(start, end,
TextIteratorEntersOpenShadowRoots)); | 279 EXPECT_EQ("[ shadow][text][ iterator.]", iteratePartial<DOMTree>(start, end,
TextIteratorEntersOpenShadowRoots)); |
280 | 280 |
281 PositionInComposedTree startInComposedTree(spanInShadow, PositionAnchorType:
:BeforeChildren); | 281 PositionInFlatTree startInFlatTree(spanInShadow, PositionAnchorType::BeforeC
hildren); |
282 PositionInComposedTree endInComposedTree(outerDiv, PositionAnchorType::After
Children); | 282 PositionInFlatTree endInFlatTree(outerDiv, PositionAnchorType::AfterChildren
); |
283 EXPECT_EQ("[text][ shadow][ iterator.]", iteratePartial<ComposedTree>(startI
nComposedTree, endInComposedTree, TextIteratorEntersOpenShadowRoots)); | 283 EXPECT_EQ("[text][ shadow][ iterator.]", iteratePartial<FlatTree>(startInFla
tTree, endInFlatTree, TextIteratorEntersOpenShadowRoots)); |
284 } | 284 } |
285 | 285 |
286 TEST_F(TextIteratorTest, FinishingAtNodeInShadowRoot) | 286 TEST_F(TextIteratorTest, FinishingAtNodeInShadowRoot) |
287 { | 287 { |
288 static const char* bodyContent = "<div id='outer'>Hello, <span id='host'>tex
t</span> iterator.</div>"; | 288 static const char* bodyContent = "<div id='outer'>Hello, <span id='host'>tex
t</span> iterator.</div>"; |
289 static const char* shadowContent = "<span><content>content</content> shadow<
/span>"; | 289 static const char* shadowContent = "<span><content>content</content> shadow<
/span>"; |
290 setBodyContent(bodyContent); | 290 setBodyContent(bodyContent); |
291 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootForElementWithID
AndSetInnerHTML(document(), "host", shadowContent); | 291 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRootForElementWithID
AndSetInnerHTML(document(), "host", shadowContent); |
292 Node* outerDiv = document().getElementById("outer"); | 292 Node* outerDiv = document().getElementById("outer"); |
293 Node* spanInShadow = shadowRoot->firstChild(); | 293 Node* spanInShadow = shadowRoot->firstChild(); |
294 Position start(outerDiv, PositionAnchorType::BeforeChildren); | 294 Position start(outerDiv, PositionAnchorType::BeforeChildren); |
295 Position end(spanInShadow, PositionAnchorType::AfterChildren); | 295 Position end(spanInShadow, PositionAnchorType::AfterChildren); |
296 EXPECT_EQ("[Hello, ][ shadow]", iteratePartial<DOMTree>(start, end, TextIter
atorEntersOpenShadowRoots)); | 296 EXPECT_EQ("[Hello, ][ shadow]", iteratePartial<DOMTree>(start, end, TextIter
atorEntersOpenShadowRoots)); |
297 | 297 |
298 PositionInComposedTree startInComposedTree(outerDiv, PositionAnchorType::Bef
oreChildren); | 298 PositionInFlatTree startInFlatTree(outerDiv, PositionAnchorType::BeforeChild
ren); |
299 PositionInComposedTree endInComposedTree(spanInShadow, PositionAnchorType::A
fterChildren); | 299 PositionInFlatTree endInFlatTree(spanInShadow, PositionAnchorType::AfterChil
dren); |
300 EXPECT_EQ("[Hello, ][text][ shadow]", iteratePartial<ComposedTree>(startInCo
mposedTree, endInComposedTree, TextIteratorEntersOpenShadowRoots)); | 300 EXPECT_EQ("[Hello, ][text][ shadow]", iteratePartial<FlatTree>(startInFlatTr
ee, endInFlatTree, TextIteratorEntersOpenShadowRoots)); |
301 } | 301 } |
302 | 302 |
303 TEST_F(TextIteratorTest, FullyClipsContents) | 303 TEST_F(TextIteratorTest, FullyClipsContents) |
304 { | 304 { |
305 static const char* bodyContent = | 305 static const char* bodyContent = |
306 "<div style='overflow: hidden; width: 200px; height: 0;'>" | 306 "<div style='overflow: hidden; width: 200px; height: 0;'>" |
307 "I'm invisible" | 307 "I'm invisible" |
308 "</div>"; | 308 "</div>"; |
309 setBodyContent(bodyContent); | 309 setBodyContent(bodyContent); |
310 EXPECT_EQ("", iterate<DOMTree>()); | 310 EXPECT_EQ("", iterate<DOMTree>()); |
311 EXPECT_EQ("", iterate<ComposedTree>()); | 311 EXPECT_EQ("", iterate<FlatTree>()); |
312 } | 312 } |
313 | 313 |
314 TEST_F(TextIteratorTest, IgnoresContainerClip) | 314 TEST_F(TextIteratorTest, IgnoresContainerClip) |
315 { | 315 { |
316 static const char* bodyContent = | 316 static const char* bodyContent = |
317 "<div style='overflow: hidden; width: 200px; height: 0;'>" | 317 "<div style='overflow: hidden; width: 200px; height: 0;'>" |
318 "<div>I'm not visible</div>" | 318 "<div>I'm not visible</div>" |
319 "<div style='position: absolute; width: 200px; height: 200px; top: 0; ri
ght: 0;'>" | 319 "<div style='position: absolute; width: 200px; height: 200px; top: 0; ri
ght: 0;'>" |
320 "but I am!" | 320 "but I am!" |
321 "</div>" | 321 "</div>" |
322 "</div>"; | 322 "</div>"; |
323 setBodyContent(bodyContent); | 323 setBodyContent(bodyContent); |
324 EXPECT_EQ("[but I am!]", iterate<DOMTree>()); | 324 EXPECT_EQ("[but I am!]", iterate<DOMTree>()); |
325 EXPECT_EQ("[but I am!]", iterate<ComposedTree>()); | 325 EXPECT_EQ("[but I am!]", iterate<FlatTree>()); |
326 } | 326 } |
327 | 327 |
328 TEST_F(TextIteratorTest, FullyClippedContentsDistributed) | 328 TEST_F(TextIteratorTest, FullyClippedContentsDistributed) |
329 { | 329 { |
330 static const char* bodyContent = | 330 static const char* bodyContent = |
331 "<div id='host'>" | 331 "<div id='host'>" |
332 "<div>Am I visible?</div>" | 332 "<div>Am I visible?</div>" |
333 "</div>"; | 333 "</div>"; |
334 static const char* shadowContent = | 334 static const char* shadowContent = |
335 "<div style='overflow: hidden; width: 200px; height: 0;'>" | 335 "<div style='overflow: hidden; width: 200px; height: 0;'>" |
336 "<content></content>" | 336 "<content></content>" |
337 "</div>"; | 337 "</div>"; |
338 setBodyContent(bodyContent); | 338 setBodyContent(bodyContent); |
339 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 339 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
340 // FIXME: The text below is actually invisible but TextIterator currently th
inks it's visible. | 340 // FIXME: The text below is actually invisible but TextIterator currently th
inks it's visible. |
341 EXPECT_EQ("[\n][Am I visible?]", iterate<DOMTree>(TextIteratorEntersOpenShad
owRoots)); | 341 EXPECT_EQ("[\n][Am I visible?]", iterate<DOMTree>(TextIteratorEntersOpenShad
owRoots)); |
342 EXPECT_EQ("", iterate<ComposedTree>(TextIteratorEntersOpenShadowRoots)); | 342 EXPECT_EQ("", iterate<FlatTree>(TextIteratorEntersOpenShadowRoots)); |
343 } | 343 } |
344 | 344 |
345 TEST_F(TextIteratorTest, IgnoresContainersClipDistributed) | 345 TEST_F(TextIteratorTest, IgnoresContainersClipDistributed) |
346 { | 346 { |
347 static const char* bodyContent = | 347 static const char* bodyContent = |
348 "<div id='host' style='overflow: hidden; width: 200px; height: 0;'>" | 348 "<div id='host' style='overflow: hidden; width: 200px; height: 0;'>" |
349 "<div>Nobody can find me!</div>" | 349 "<div>Nobody can find me!</div>" |
350 "</div>"; | 350 "</div>"; |
351 static const char* shadowContent = | 351 static const char* shadowContent = |
352 "<div style='position: absolute; width: 200px; height: 200px; top: 0; ri
ght: 0;'>" | 352 "<div style='position: absolute; width: 200px; height: 200px; top: 0; ri
ght: 0;'>" |
353 "<content></content>" | 353 "<content></content>" |
354 "</div>"; | 354 "</div>"; |
355 setBodyContent(bodyContent); | 355 setBodyContent(bodyContent); |
356 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); | 356 createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowCo
ntent); |
357 // FIXME: The text below is actually visible but TextIterator currently thin
ks it's invisible. | 357 // FIXME: The text below is actually visible but TextIterator currently thin
ks it's invisible. |
358 // [\n][Nobody can find me!] | 358 // [\n][Nobody can find me!] |
359 EXPECT_EQ("", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots)); | 359 EXPECT_EQ("", iterate<DOMTree>(TextIteratorEntersOpenShadowRoots)); |
360 EXPECT_EQ("[Nobody can find me!]", iterate<ComposedTree>(TextIteratorEntersO
penShadowRoots)); | 360 EXPECT_EQ("[Nobody can find me!]", iterate<FlatTree>(TextIteratorEntersOpenS
hadowRoots)); |
361 } | 361 } |
362 | 362 |
363 TEST_F(TextIteratorTest, EmitsReplacementCharForInput) | 363 TEST_F(TextIteratorTest, EmitsReplacementCharForInput) |
364 { | 364 { |
365 static const char* bodyContent = | 365 static const char* bodyContent = |
366 "<div contenteditable='true'>" | 366 "<div contenteditable='true'>" |
367 "Before" | 367 "Before" |
368 "<img src='foo.png'>" | 368 "<img src='foo.png'>" |
369 "After" | 369 "After" |
370 "</div>"; | 370 "</div>"; |
371 setBodyContent(bodyContent); | 371 setBodyContent(bodyContent); |
372 EXPECT_EQ("[Before][\xEF\xBF\xBC][After]", iterate<DOMTree>(TextIteratorEmit
sObjectReplacementCharacter)); | 372 EXPECT_EQ("[Before][\xEF\xBF\xBC][After]", iterate<DOMTree>(TextIteratorEmit
sObjectReplacementCharacter)); |
373 EXPECT_EQ("[Before][\xEF\xBF\xBC][After]", iterate<ComposedTree>(TextIterato
rEmitsObjectReplacementCharacter)); | 373 EXPECT_EQ("[Before][\xEF\xBF\xBC][After]", iterate<FlatTree>(TextIteratorEmi
tsObjectReplacementCharacter)); |
374 } | 374 } |
375 | 375 |
376 TEST_F(TextIteratorTest, RangeLengthWithReplacedElements) | 376 TEST_F(TextIteratorTest, RangeLengthWithReplacedElements) |
377 { | 377 { |
378 static const char* bodyContent = | 378 static const char* bodyContent = |
379 "<div id='div' contenteditable='true'>1<img src='foo.png'>3</div>"; | 379 "<div id='div' contenteditable='true'>1<img src='foo.png'>3</div>"; |
380 setBodyContent(bodyContent); | 380 setBodyContent(bodyContent); |
381 document().view()->updateAllLifecyclePhases(); | 381 document().view()->updateAllLifecyclePhases(); |
382 | 382 |
383 Node* divNode = document().getElementById("div"); | 383 Node* divNode = document().getElementById("div"); |
384 RefPtrWillBeRawPtr<Range> range = Range::create(document(), divNode, 0, divN
ode, 3); | 384 RefPtrWillBeRawPtr<Range> range = Range::create(document(), divNode, 0, divN
ode, 3); |
385 | 385 |
386 EXPECT_EQ(3, TextIterator::rangeLength(range->startPosition(), range->endPos
ition())); | 386 EXPECT_EQ(3, TextIterator::rangeLength(range->startPosition(), range->endPos
ition())); |
387 } | 387 } |
388 | 388 |
389 TEST_F(TextIteratorTest, WhitespaceCollapseForReplacedElements) | 389 TEST_F(TextIteratorTest, WhitespaceCollapseForReplacedElements) |
390 { | 390 { |
391 static const char* bodyContent = "<span>Some text </span> <input type='butto
n' value='Button text'/><span>Some more text</span>"; | 391 static const char* bodyContent = "<span>Some text </span> <input type='butto
n' value='Button text'/><span>Some more text</span>"; |
392 setBodyContent(bodyContent); | 392 setBodyContent(bodyContent); |
393 EXPECT_EQ("[Some text ][][Some more text]", iterate<DOMTree>(TextIteratorCol
lapseTrailingSpace)); | 393 EXPECT_EQ("[Some text ][][Some more text]", iterate<DOMTree>(TextIteratorCol
lapseTrailingSpace)); |
394 EXPECT_EQ("[Some text ][][Button text][Some more text]", iterate<ComposedTre
e>(TextIteratorCollapseTrailingSpace)); | 394 EXPECT_EQ("[Some text ][][Button text][Some more text]", iterate<FlatTree>(T
extIteratorCollapseTrailingSpace)); |
395 } | 395 } |
396 | 396 |
397 TEST_F(TextIteratorTest, copyTextTo) | 397 TEST_F(TextIteratorTest, copyTextTo) |
398 { | 398 { |
399 const char* bodyContent = "<a id=host><b id=one>one</b> not appeared <b id=t
wo>two</b></a>"; | 399 const char* bodyContent = "<a id=host><b id=one>one</b> not appeared <b id=t
wo>two</b></a>"; |
400 const char* shadowContent = "three <content select=#two></content> <content
select=#one></content> zero"; | 400 const char* shadowContent = "three <content select=#two></content> <content
select=#one></content> zero"; |
401 setBodyContent(bodyContent); | 401 setBodyContent(bodyContent); |
402 setShadowContent(shadowContent, "host"); | 402 setShadowContent(shadowContent, "host"); |
403 updateLayoutAndStyleForPainting(); | 403 updateLayoutAndStyleForPainting(); |
404 | 404 |
405 Element* host = document().getElementById("host"); | 405 Element* host = document().getElementById("host"); |
406 const char* message = "|iter%d| should have emitted '%s'."; | 406 const char* message = "|iter%d| should have emitted '%s'."; |
407 | 407 |
408 EphemeralRangeTemplate<EditingStrategy> range1(EphemeralRangeTemplate<Editin
gStrategy>::rangeOfContents(*host)); | 408 EphemeralRangeTemplate<EditingStrategy> range1(EphemeralRangeTemplate<Editin
gStrategy>::rangeOfContents(*host)); |
409 TextIteratorAlgorithm<EditingStrategy> iter1(range1.startPosition(), range1.
endPosition()); | 409 TextIteratorAlgorithm<EditingStrategy> iter1(range1.startPosition(), range1.
endPosition()); |
410 ForwardsTextBuffer output1; | 410 ForwardsTextBuffer output1; |
411 iter1.copyTextTo(&output1, 0, 2); | 411 iter1.copyTextTo(&output1, 0, 2); |
412 EXPECT_EQ("on", String(output1.data(), output1.size())) << String::format(me
ssage, 1, "on").utf8().data(); | 412 EXPECT_EQ("on", String(output1.data(), output1.size())) << String::format(me
ssage, 1, "on").utf8().data(); |
413 iter1.copyTextTo(&output1, 2, 1); | 413 iter1.copyTextTo(&output1, 2, 1); |
414 EXPECT_EQ("one", String(output1.data(), output1.size())) << String::format(m
essage, 1, "one").utf8().data(); | 414 EXPECT_EQ("one", String(output1.data(), output1.size())) << String::format(m
essage, 1, "one").utf8().data(); |
415 iter1.advance(); | 415 iter1.advance(); |
416 iter1.copyTextTo(&output1, 0, 1); | 416 iter1.copyTextTo(&output1, 0, 1); |
417 EXPECT_EQ("onet", String(output1.data(), output1.size())) << String::format(
message, 1, "onet").utf8().data(); | 417 EXPECT_EQ("onet", String(output1.data(), output1.size())) << String::format(
message, 1, "onet").utf8().data(); |
418 iter1.copyTextTo(&output1, 1, 2); | 418 iter1.copyTextTo(&output1, 1, 2); |
419 EXPECT_EQ("onetwo", String(output1.data(), output1.size())) << String::forma
t(message, 1, "onetwo").utf8().data(); | 419 EXPECT_EQ("onetwo", String(output1.data(), output1.size())) << String::forma
t(message, 1, "onetwo").utf8().data(); |
420 | 420 |
421 EphemeralRangeTemplate<EditingInComposedTreeStrategy> range2(EphemeralRangeT
emplate<EditingInComposedTreeStrategy>::rangeOfContents(*host)); | 421 EphemeralRangeTemplate<EditingInFlatTreeStrategy> range2(EphemeralRangeTempl
ate<EditingInFlatTreeStrategy>::rangeOfContents(*host)); |
422 TextIteratorAlgorithm<EditingInComposedTreeStrategy> iter2(range2.startPosit
ion(), range2.endPosition()); | 422 TextIteratorAlgorithm<EditingInFlatTreeStrategy> iter2(range2.startPosition(
), range2.endPosition()); |
423 ForwardsTextBuffer output2; | 423 ForwardsTextBuffer output2; |
424 iter2.copyTextTo(&output2, 0, 3); | 424 iter2.copyTextTo(&output2, 0, 3); |
425 EXPECT_EQ("thr", String(output2.data(), output2.size())) << String::format(m
essage, 2, "thr").utf8().data(); | 425 EXPECT_EQ("thr", String(output2.data(), output2.size())) << String::format(m
essage, 2, "thr").utf8().data(); |
426 iter2.copyTextTo(&output2, 3, 3); | 426 iter2.copyTextTo(&output2, 3, 3); |
427 EXPECT_EQ("three ", String(output2.data(), output2.size())) << String::forma
t(message, 2, "three ").utf8().data(); | 427 EXPECT_EQ("three ", String(output2.data(), output2.size())) << String::forma
t(message, 2, "three ").utf8().data(); |
428 iter2.advance(); | 428 iter2.advance(); |
429 iter2.copyTextTo(&output2, 0, 2); | 429 iter2.copyTextTo(&output2, 0, 2); |
430 EXPECT_EQ("three tw", String(output2.data(), output2.size())) << String::for
mat(message, 2, "three tw").utf8().data(); | 430 EXPECT_EQ("three tw", String(output2.data(), output2.size())) << String::for
mat(message, 2, "three tw").utf8().data(); |
431 iter2.copyTextTo(&output2, 2, 1); | 431 iter2.copyTextTo(&output2, 2, 1); |
432 EXPECT_EQ("three two", String(output2.data(), output2.size())) << String::fo
rmat(message, 2, "three two").utf8().data(); | 432 EXPECT_EQ("three two", String(output2.data(), output2.size())) << String::fo
rmat(message, 2, "three two").utf8().data(); |
(...skipping 26 matching lines...) Expand all Loading... |
459 TextIteratorAlgorithm<EditingStrategy> iter1(range1.startPosition(), range1.
endPosition()); | 459 TextIteratorAlgorithm<EditingStrategy> iter1(range1.startPosition(), range1.
endPosition()); |
460 const char* message1 = "|iter1| should emit 'one' and 'two'."; | 460 const char* message1 = "|iter1| should emit 'one' and 'two'."; |
461 EXPECT_EQ('o', iter1.characterAt(0)) << message1; | 461 EXPECT_EQ('o', iter1.characterAt(0)) << message1; |
462 EXPECT_EQ('n', iter1.characterAt(1)) << message1; | 462 EXPECT_EQ('n', iter1.characterAt(1)) << message1; |
463 EXPECT_EQ('e', iter1.characterAt(2)) << message1; | 463 EXPECT_EQ('e', iter1.characterAt(2)) << message1; |
464 iter1.advance(); | 464 iter1.advance(); |
465 EXPECT_EQ('t', iter1.characterAt(0)) << message1; | 465 EXPECT_EQ('t', iter1.characterAt(0)) << message1; |
466 EXPECT_EQ('w', iter1.characterAt(1)) << message1; | 466 EXPECT_EQ('w', iter1.characterAt(1)) << message1; |
467 EXPECT_EQ('o', iter1.characterAt(2)) << message1; | 467 EXPECT_EQ('o', iter1.characterAt(2)) << message1; |
468 | 468 |
469 EphemeralRangeTemplate<EditingInComposedTreeStrategy> range2(EphemeralRangeT
emplate<EditingInComposedTreeStrategy>::rangeOfContents(*host)); | 469 EphemeralRangeTemplate<EditingInFlatTreeStrategy> range2(EphemeralRangeTempl
ate<EditingInFlatTreeStrategy>::rangeOfContents(*host)); |
470 TextIteratorAlgorithm<EditingInComposedTreeStrategy> iter2(range2.startPosit
ion(), range2.endPosition()); | 470 TextIteratorAlgorithm<EditingInFlatTreeStrategy> iter2(range2.startPosition(
), range2.endPosition()); |
471 const char* message2 = "|iter2| should emit 'three ', 'two', ' ', 'one' and
' zero'."; | 471 const char* message2 = "|iter2| should emit 'three ', 'two', ' ', 'one' and
' zero'."; |
472 EXPECT_EQ('t', iter2.characterAt(0)) << message2; | 472 EXPECT_EQ('t', iter2.characterAt(0)) << message2; |
473 EXPECT_EQ('h', iter2.characterAt(1)) << message2; | 473 EXPECT_EQ('h', iter2.characterAt(1)) << message2; |
474 EXPECT_EQ('r', iter2.characterAt(2)) << message2; | 474 EXPECT_EQ('r', iter2.characterAt(2)) << message2; |
475 EXPECT_EQ('e', iter2.characterAt(3)) << message2; | 475 EXPECT_EQ('e', iter2.characterAt(3)) << message2; |
476 EXPECT_EQ('e', iter2.characterAt(4)) << message2; | 476 EXPECT_EQ('e', iter2.characterAt(4)) << message2; |
477 EXPECT_EQ(' ', iter2.characterAt(5)) << message2; | 477 EXPECT_EQ(' ', iter2.characterAt(5)) << message2; |
478 iter2.advance(); | 478 iter2.advance(); |
479 EXPECT_EQ('t', iter2.characterAt(0)) << message2; | 479 EXPECT_EQ('t', iter2.characterAt(0)) << message2; |
480 EXPECT_EQ('w', iter2.characterAt(1)) << message2; | 480 EXPECT_EQ('w', iter2.characterAt(1)) << message2; |
(...skipping 26 matching lines...) Expand all Loading... |
507 EXPECT_EQ(2, iter.copyTextTo(&buffer, 0, 1)) << "Should emit 2 UChars for 'U
+13000'."; | 507 EXPECT_EQ(2, iter.copyTextTo(&buffer, 0, 1)) << "Should emit 2 UChars for 'U
+13000'."; |
508 EXPECT_EQ(4, iter.copyTextTo(&buffer, 2, 3)) << "Should emit 4 UChars for 'U
+13001U+13002'."; | 508 EXPECT_EQ(4, iter.copyTextTo(&buffer, 2, 3)) << "Should emit 4 UChars for 'U
+13001U+13002'."; |
509 EXPECT_EQ(3, iter.copyTextTo(&buffer, 6, 2)) << "Should emit 3 UChars for '
U+13140'."; | 509 EXPECT_EQ(3, iter.copyTextTo(&buffer, 6, 2)) << "Should emit 3 UChars for '
U+13140'."; |
510 EXPECT_EQ(2, iter.copyTextTo(&buffer, 9, 2)) << "Should emit 2 UChars for 'U
+13141'."; | 510 EXPECT_EQ(2, iter.copyTextTo(&buffer, 9, 2)) << "Should emit 2 UChars for 'U
+13141'."; |
511 EXPECT_EQ(1, iter.copyTextTo(&buffer, 11, 1)) << "Should emit 1 UChar for '.
'."; | 511 EXPECT_EQ(1, iter.copyTextTo(&buffer, 11, 1)) << "Should emit 1 UChar for '.
'."; |
512 for (int i = 0; i < 12; i++) | 512 for (int i = 0; i < 12; i++) |
513 EXPECT_EQ(expected[i], buffer[i]); | 513 EXPECT_EQ(expected[i], buffer[i]); |
514 } | 514 } |
515 | 515 |
516 } // namespace blink | 516 } // namespace blink |
OLD | NEW |