| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Include test fixture. | |
| 6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']); | |
| 7 | |
| 8 /** | |
| 9 * Test fixture. | |
| 10 * @constructor | |
| 11 * @extends {ChromeVoxUnitTestBase} | |
| 12 */ | |
| 13 function CvoxShadowUnitTest() {} | |
| 14 | |
| 15 CvoxShadowUnitTest.prototype = { | |
| 16 __proto__: ChromeVoxUnitTestBase.prototype, | |
| 17 | |
| 18 /** @override */ | |
| 19 closureModuleDeps: [ | |
| 20 'cvox.EditableTextAreaShadow' | |
| 21 ] | |
| 22 }; | |
| 23 | |
| 24 TEST_F('CvoxShadowUnitTest', 'MultilineLines', function() { | |
| 25 this.loadDoc(function() {/*! | |
| 26 <div><textarea id="area"> | |
| 27 one | |
| 28 | |
| 29 two | |
| 30 | |
| 31 three | |
| 32 </textarea></div> */}); | |
| 33 | |
| 34 var area = $('area'); | |
| 35 | |
| 36 var shadow = new cvox.EditableTextAreaShadow(); | |
| 37 shadow.update(area); | |
| 38 assertEquals(0, shadow.getLineIndex(0)); | |
| 39 assertEquals(0, shadow.getLineIndex(3)); | |
| 40 assertEquals(1, shadow.getLineIndex(4)); | |
| 41 assertEquals(2, shadow.getLineIndex(5)); | |
| 42 assertEquals(2, shadow.getLineIndex(8)); | |
| 43 assertEquals(3, shadow.getLineIndex(9)); | |
| 44 assertEquals(4, shadow.getLineIndex(10)); | |
| 45 assertEquals(4, shadow.getLineIndex(14)); | |
| 46 }); | |
| 47 | |
| 48 /** | |
| 49 * Test the get line of a multiline textarea with wrapping instead of | |
| 50 * explicit newlines. | |
| 51 */ | |
| 52 TEST_F('CvoxShadowUnitTest', 'MultilineWrap', function() { | |
| 53 this.loadDoc(function() {/*! | |
| 54 <div><textarea id="area" | |
| 55 cols=4 rows=20>One two thr fou fiv six sev eig</textarea> | |
| 56 </div> */}); | |
| 57 | |
| 58 var area = $('area'); | |
| 59 | |
| 60 var shadow = new cvox.EditableTextAreaShadow(); | |
| 61 shadow.update(area); | |
| 62 for (var i = 0; i < 32; i++) { | |
| 63 assertEquals(Math.floor(i / 4), shadow.getLineIndex(i)); | |
| 64 } | |
| 65 }); | |
| OLD | NEW |