Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/braille/braille_display_manager_test.unitjs |
| diff --git a/chrome/browser/resources/chromeos/chromevox/braille/braille_display_manager_test.unitjs b/chrome/browser/resources/chromeos/chromevox/braille/braille_display_manager_test.unitjs |
| index db4b37fed45f2c875d940cf4dcc0ad4b52f0541b..d63a8b3e9f5e47abb9142248c55496aba9e510c5 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/braille/braille_display_manager_test.unitjs |
| +++ b/chrome/browser/resources/chromeos/chromevox/braille/braille_display_manager_test.unitjs |
| @@ -91,6 +91,15 @@ CvoxBrailleDisplayManagerUnitTest.prototype = { |
| this.writtenCells.length = 0; |
| assertTrue(content instanceof ArrayBuffer); |
| assertTrue(content.byteLength == 0); |
| + }, |
| + |
| + /** |
| + * Asserts that the last written display content is an empty buffer of |
|
dmazzoni
2016/10/04 22:34:30
Update this comment
ultimatedbz
2016/10/08 01:00:44
Done.
|
| + * of cells and clears the list of written cells. |
| + * There must be only one buffer in the list. |
| + */ |
| + assertGroupValid: function(groups, expected) { |
|
dmazzoni
2016/10/04 22:34:30
Maybe assertGroupsValid?
ultimatedbz
2016/10/08 01:00:44
Done.
|
| + assertEquals(JSON.stringify(groups), JSON.stringify(expected)); |
| } |
| }; |
| @@ -203,6 +212,7 @@ TEST_F('CvoxBrailleDisplayManagerUnitTest', 'BasicSetContent', function() { |
| }); |
| + |
|
dmazzoni
2016/10/04 22:34:30
Nit: get rid of extra blank line
|
| /** |
| * Tests that setting empty content clears the display. |
| */ |
| @@ -255,3 +265,89 @@ TEST_F('CvoxBrailleDisplayManagerUnitTest', 'CursorAndPanning', function() { |
| manager.setContent(createNavBrailleWithCursor(0, text.length)); |
| this.assertDisplayPositionAndClear(0, 0, this.DISPLAY_SIZE); |
| }); |
| + |
| +/** |
| + * Tests that the grouping algorithm works with one regular letter that maps |
| + * to one braille letter. |
|
dmazzoni
2016/10/04 22:34:30
Use "braille cell" instead of "braille letter", an
ultimatedbz
2016/10/08 01:00:44
Done.
|
| + */ |
| +TEST_F('CvoxBrailleDisplayManagerUnitTest', 'BasicGroup', function() { |
| + var text = 'a'; |
| + var translated = '1'; |
| + var mapping = [0]; |
| + var expected = [['a','1']]; |
| + |
| + var groups = cvox.BrailleCaptionsBackground.groupBrailleAndText(translated, text, mapping); |
|
dmazzoni
2016/10/04 22:34:30
Wrap to 80 chars, here and in one or two other pla
|
| + this.assertGroupValid(groups, expected); |
| +}); |
| + |
| +/** |
| + * Tests that the grouping algorithm works with one regular letter that maps |
| + * to multiple braille letters. |
| + */ |
| +TEST_F('CvoxBrailleDisplayManagerUnitTest', 'OneRtoManyB', function() { |
| + var text = 'A'; |
| + var translated = '11'; |
| + var mapping = [0,0]; |
| + var expected = [['A', '11']]; |
| + |
| + var groups = cvox.BrailleCaptionsBackground.groupBrailleAndText(translated, text, mapping); |
| + this.assertGroupValid(groups, expected); |
| +}); |
| + |
| +/** |
| + * Tests that the grouping algorithm works with one braille letter that maps |
| + * to multiple regular letters. |
| + */ |
| +TEST_F('CvoxBrailleDisplayManagerUnitTest', 'OneBtoManyR', function() { |
| + var text = 'knowledge'; |
| + var translated = '1'; |
| + var mapping = [0]; |
| + var expected = [['knowledge', '1']]; |
| + |
| + var groups = cvox.BrailleCaptionsBackground.groupBrailleAndText(translated, text, mapping); |
| + this.assertGroupValid(groups, expected); |
| +}); |
| + |
| +/** |
| + * Tests that the grouping algorithm works with one string that on both ends, |
| + * have regular letters that map to multiple braille letters. |
| + */ |
| +TEST_F('CvoxBrailleDisplayManagerUnitTest', 'OneRtoManyB_BothEnds', function() { |
| + var text = 'AbbC'; |
| + var translated = 'X122X3'; |
| + var mapping = [0,0,1,2,3,3]; |
| + var expected = [['A', 'X1'], ['b', '2'],['b', '2'], ['C', 'X3']]; |
| + |
| + var groups = cvox.BrailleCaptionsBackground.groupBrailleAndText(translated, text, mapping); |
| + this.assertGroupValid(groups, expected); |
| +}); |
| + |
| +/** |
| + * Tests that the grouping algorithm works with one string that on both ends, |
| + * have braille letters that map to multiple regular letters. |
| + */ |
| +TEST_F('CvoxBrailleDisplayManagerUnitTest', 'OneBtoManyR_BothEnds', function() { |
| + var text = 'knowledgehappych'; |
| + var translated = '1234456'; |
| + var mapping = [0, 9, 10, 11, 12, 13, 14]; |
| + var expected = [['knowledge', '1'], ['h', '2'], ['a', '3'], ['p', '4'], |
| + ['p', '4'], ['y', '5'], ['ch', '6']]; |
| + |
| + var groups = cvox.BrailleCaptionsBackground.groupBrailleAndText(translated, text, mapping); |
| + this.assertGroupValid(groups, expected); |
| +}); |
| + |
| +/** |
| + * Tests that the grouping algorithm works with one string that has both types |
| + * of mapping. |
| + */ |
| +TEST_F('CvoxBrailleDisplayManagerUnitTest', 'RandB_Random', function() { |
| + var text = 'knowledgeIsPower'; |
| + var translated = '1X23X45678'; |
| + var mapping = [0, 9, 9, 10, 11, 11, 12, 13, 14, 15]; |
| + var expected = [['knowledge', '1'], ['I', 'X2'], ['s', '3'], ['P', 'X4'], ['o', '5'], |
| + ['w', '6'], ['e', '7'], ['r', '8']]; |
| + |
| + var groups = cvox.BrailleCaptionsBackground.groupBrailleAndText(translated, text, mapping); |
| + this.assertGroupValid(groups, expected); |
| +}); |