| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_unittest_base.js']); | 6 GEN_INCLUDE(['../testing/chromevox_unittest_base.js']); |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Test fixture. | 9 * Test fixture. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 * @export | 382 * @export |
| 383 */ | 383 */ |
| 384 TEST_F('CvoxBrailleUtilUnitTest', 'CreateValue', function() { | 384 TEST_F('CvoxBrailleUtilUnitTest', 'CreateValue', function() { |
| 385 var s; | 385 var s; |
| 386 var valueSpan; | 386 var valueSpan; |
| 387 var selectiponSpan; | 387 var selectiponSpan; |
| 388 | 388 |
| 389 // Value without a selection. | 389 // Value without a selection. |
| 390 s = cvox.BrailleUtil.createValue('value'); | 390 s = cvox.BrailleUtil.createValue('value'); |
| 391 assertEquals('value', s.toString()); | 391 assertEquals('value', s.toString()); |
| 392 assertUndefined(s.getSpanInstanceOf(cvox.BrailleUtil.ValueSelectionSpan)); | 392 assertUndefined(s.getSpanInstanceOf(cvox.ValueSelectionSpan)); |
| 393 valueSpan = s.getSpanInstanceOf(cvox.BrailleUtil.ValueSpan); | 393 valueSpan = s.getSpanInstanceOf(cvox.ValueSpan); |
| 394 assertEquals(0, s.getSpanStart(valueSpan)); | 394 assertEquals(0, s.getSpanStart(valueSpan)); |
| 395 assertEquals(s.getLength(), s.getSpanEnd(valueSpan)); | 395 assertEquals(s.getLength(), s.getSpanEnd(valueSpan)); |
| 396 | 396 |
| 397 // Value with a carret at the start of the text. | 397 // Value with a carret at the start of the text. |
| 398 s = cvox.BrailleUtil.createValue('value', 0); | 398 s = cvox.BrailleUtil.createValue('value', 0); |
| 399 selectionSpan = s.getSpanInstanceOf(cvox.BrailleUtil.ValueSelectionSpan); | 399 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); |
| 400 assertEquals(0, s.getSpanStart(selectionSpan)); | 400 assertEquals(0, s.getSpanStart(selectionSpan)); |
| 401 assertEquals(0, s.getSpanEnd(selectionSpan)); | 401 assertEquals(0, s.getSpanEnd(selectionSpan)); |
| 402 | 402 |
| 403 // Value with a carret inside the text. | 403 // Value with a carret inside the text. |
| 404 s = cvox.BrailleUtil.createValue('value', 1); | 404 s = cvox.BrailleUtil.createValue('value', 1); |
| 405 selectionSpan = s.getSpanInstanceOf(cvox.BrailleUtil.ValueSelectionSpan); | 405 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); |
| 406 assertEquals(1, s.getSpanStart(selectionSpan)); | 406 assertEquals(1, s.getSpanStart(selectionSpan)); |
| 407 assertEquals(1, s.getSpanEnd(selectionSpan)); | 407 assertEquals(1, s.getSpanEnd(selectionSpan)); |
| 408 | 408 |
| 409 // Value with a carret at the end of the text. | 409 // Value with a carret at the end of the text. |
| 410 s = cvox.BrailleUtil.createValue('value', 5); | 410 s = cvox.BrailleUtil.createValue('value', 5); |
| 411 selectionSpan = s.getSpanInstanceOf(cvox.BrailleUtil.ValueSelectionSpan); | 411 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); |
| 412 assertEquals(5, s.getSpanStart(selectionSpan)); | 412 assertEquals(5, s.getSpanStart(selectionSpan)); |
| 413 assertEquals(5, s.getSpanEnd(selectionSpan)); | 413 assertEquals(5, s.getSpanEnd(selectionSpan)); |
| 414 | 414 |
| 415 // All of the value selected selected with reversed start and end. | 415 // All of the value selected selected with reversed start and end. |
| 416 s = cvox.BrailleUtil.createValue('value', 5, 0); | 416 s = cvox.BrailleUtil.createValue('value', 5, 0); |
| 417 selectionSpan = s.getSpanInstanceOf(cvox.BrailleUtil.ValueSelectionSpan); | 417 selectionSpan = s.getSpanInstanceOf(cvox.ValueSelectionSpan); |
| 418 assertEquals(0, s.getSpanStart(selectionSpan)); | 418 assertEquals(0, s.getSpanStart(selectionSpan)); |
| 419 assertEquals(5, s.getSpanEnd(selectionSpan)); | 419 assertEquals(5, s.getSpanEnd(selectionSpan)); |
| 420 }); | 420 }); |
| OLD | NEW |