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

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/editing_test.extjs

Issue 2903973002: Rich editable text implementation using spannables (Closed)
Patch Set: Make boolean expressions explicit. Created 3 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
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 test fixture. 5 // Include test fixture.
6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js', 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js',
7 '../../testing/assert_additions.js']); 7 '../../testing/assert_additions.js']);
8 8
9 GEN_INCLUDE(['../../testing/mock_feedback.js']); 9 GEN_INCLUDE(['../../testing/mock_feedback.js']);
10 10
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 */}, 205 */},
206 [ 206 [
207 {start: 0, end: 4, text: 'this'}, 207 {start: 0, end: 4, text: 'this'},
208 {start: 5, end: 5, text: ''}, 208 {start: 5, end: 5, text: ''},
209 {start: 6, end: 6, text: ''}, 209 {start: 6, end: 6, text: ''},
210 {start: 7, end: 8, text: 'I'}, 210 {start: 7, end: 8, text: 'I'},
211 {start: 9, end: 17, text: 'can test'}, 211 {start: 9, end: 17, text: 'can test'},
212 ]); 212 ]);
213 }); 213 });
214 214
215 // Fails flakily, see https://crbug.com/724847. 215 TEST_F('EditingTest', 'RichTextMoveByLine', function() {
216 TEST_F('EditingTest', 'DISABLED_RichTextMoveByLine', function() {
217 editing.useRichText = true; 216 editing.useRichText = true;
218 var mockFeedback = this.createMockFeedback(); 217 var mockFeedback = this.createMockFeedback();
219 this.runWithLoadedTree(function() {/*! 218 this.runWithLoadedTree(function() {/*!
220 <div id="go" role="textbox" contenteditable> 219 <div id="go" role="textbox" contenteditable>
221 <h2>hello</h2> 220 <h2>hello</h2>
222 <div><br></div> 221 <div><br></div>
223 <p>This is a <a href="#test">test</a> of rich text</p> 222 <p>This is a <a href="#test">test</a> of rich text</p>
224 </div> 223 </div>
225 <script> 224 <script>
226 var dir = 'forward'; 225 var dir = 'forward';
227 var line = 0; 226 var line = 0;
228 document.getElementById('go').addEventListener('click', function() { 227 document.getElementById('go').addEventListener('click', function() {
229 var sel = getSelection(); 228 var sel = getSelection();
230 sel.modify('move', dir, 'line'); 229 sel.modify('move', dir, 'line');
231 if (dir == 'forward') 230 if (dir == 'forward')
232 line++; 231 line++;
233 else 232 else
234 line--; 233 line--;
235 234
236 if (line == 0) 235 if (line == 0)
237 dir = 'forward'; 236 dir = 'forward';
238 if (line == 2) 237 if (line == 2)
239 dir = 'backward'; 238 dir = 'backward';
240 }, true); 239 }, true);
241 </script> 240 </script>
242 */}, function(root) { 241 */}, function(root) {
243 var input = root.find({role: RoleType.TEXT_FIELD}); 242 var input = root.find({role: RoleType.TEXT_FIELD});
244 var moveByLine = input.doDefault.bind(input); 243 var moveByLine = input.doDefault.bind(input);
245 mockFeedback.call(input.focus.bind(input)) 244 mockFeedback.call(input.focus.bind(input))
245 .expectSpeech('Text area')
246 .call(moveByLine) 246 .call(moveByLine)
247 .expectSpeech('blank') 247 .expectSpeech('\n')
248 .expectBraille('') 248 .expectBraille('\n')
249 .call(moveByLine) 249 .call(moveByLine)
250 .expectSpeech('This is a ', 'test', 'Link', ' of rich text') 250 .expectSpeech('This is a ', 'test', 'Link', ' of rich text')
251 .expectBraille('This is a test lnk of rich text') 251 .expectBraille('This is a test lnk of rich text')
252 .call(moveByLine) 252 .call(moveByLine)
253 .expectSpeech('blank') 253 .expectSpeech('\n')
254 .expectBraille('') 254 .expectBraille('\n')
255 .call(moveByLine) 255 .call(moveByLine)
256 .expectSpeech('hello', 'Heading 2') 256 .expectSpeech('hello', 'Heading 2')
257 .expectBraille('hello h2') 257 .expectBraille('hello h2')
258 .replay(); 258 .replay();
259 }); 259 });
260 }); 260 });
261
262 TEST_F('EditingTest', 'RichTextMoveByCharacter', function() {
263 editing.useRichText = true;
264 var mockFeedback = this.createMockFeedback();
265 this.runWithLoadedTree(function() {/*!
266 <div id="go" role="textbox" contenteditable>This <b>is</b> a test.</div>
267
268 <script>
269 var dir = 'forward';
270 var char = 0;
271 document.getElementById('go').addEventListener('click', function() {
272 var sel = getSelection();
273 sel.modify('move', dir, 'character');
274 if (dir == 'forward')
275 char++;
276 else
277 char--;
278
279 if (char == 0)
280 dir = 'forward';
281 if (line == 16)
282 dir = 'backward';
283 }, true);
284 </script>
285 */}, function(root) {
286 var input = root.find({role: RoleType.TEXT_FIELD});
287 var moveByChar = input.doDefault.bind(input)
288 var lineText = 'This is a test.';
289
290 mockFeedback.call(input.focus.bind(input))
291 .expectSpeech(lineText)
292 .expectSpeech('Text area')
293 .call(moveByChar)
294 .expectSpeech('h')
295 .expectBraille(lineText, { startIndex: 1, endIndex: 1 })
296 .call(moveByChar)
297 .expectSpeech('i')
298 .expectBraille(lineText, { startIndex: 2, endIndex: 2 })
299 .call(moveByChar)
300 .expectSpeech('s')
301 .expectBraille(lineText, { startIndex: 3, endIndex: 3 })
302 .call(moveByChar)
303 .expectSpeech(' ')
304 .expectBraille(lineText, { startIndex: 4, endIndex: 4 })
305
306 .call(moveByChar)
307 .expectSpeech('i')
308 .expectSpeech('Bold start')
309 .expectBraille(lineText, { startIndex: 5, endIndex: 5 })
310
311 .call(moveByChar)
312 .expectSpeech('s')
313 .expectSpeech('Bold end')
314 .expectBraille(lineText, { startIndex: 6, endIndex: 6 })
315
316 .call(moveByChar)
317 .expectSpeech(' ')
318 .expectBraille(lineText, { startIndex: 7, endIndex: 7 })
319
320 .call(moveByChar)
321 .expectSpeech('a')
322 .expectBraille(lineText, { startIndex: 8, endIndex: 8 })
323
324 .call(moveByChar)
325 .expectSpeech(' ')
326 .expectBraille(lineText, { startIndex: 9, endIndex: 9 })
327
328 .replay();
329 });
330 });
331
332 // Tests specifically for cursor workarounds.
333 TEST_F('EditingTest', 'RichTextMoveByCharacterNodeWorkaround', function() {
334 editing.useRichText = true;
335 var mockFeedback = this.createMockFeedback();
336 this.runWithLoadedTree(function() {/*!
337 <div id="go" role="textbox" contenteditable>hello <b>world</b></div>
338
339 <script>
340 document.getElementById('go').addEventListener('click', function() {
341 var sel = getSelection();
342 sel.modify('move', 'forward', 'character');
343 }, true);
344 </script>
345 */}, function(root) {
346 var input = root.find({role: RoleType.TEXT_FIELD});
347 var moveByChar = input.doDefault.bind(input)
348 var lineText = 'hello world';
349
350 mockFeedback.call(input.focus.bind(input))
351 .expectSpeech(lineText)
352 .expectSpeech('Text area')
353 .call(moveByChar)
354 .expectSpeech('e')
355 .expectBraille(lineText, { startIndex: 1, endIndex: 1 })
356 .call(moveByChar)
357 .expectSpeech('l')
358 .expectBraille(lineText, { startIndex: 2, endIndex: 2 })
359 .call(moveByChar)
360 .expectSpeech('l')
361 .expectBraille(lineText, { startIndex: 3, endIndex: 3 })
362 .call(moveByChar)
363 .expectSpeech('o')
364 .expectBraille(lineText, { startIndex: 4, endIndex: 4 })
365 .call(moveByChar)
366 .expectSpeech(' ')
367 .expectBraille(lineText, { startIndex: 5, endIndex: 5 })
368 .call(moveByChar)
369 .expectSpeech('w')
370 .expectBraille(lineText, { startIndex: 6, endIndex: 6 })
371 .replay();
372 });
373 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698