| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs
|
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs
|
| index b8c7fda88edbc294839a32f069650ac4de763b3c..bbf93446f5ac65311dd5e771b81423f0b153ba5c 100644
|
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs
|
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/output_test.extjs
|
| @@ -17,7 +17,29 @@ function checkBrailleOutput(expectedText, expectedSpans, output) {
|
| var actualSpans = actualOutput.spans_.filter(function(span) {
|
| return (typeof span.value !== 'string');
|
| });
|
| - assertEquals(expectedText, actualOutput.toString());
|
| + checkOutput_(
|
| + expectedText, expectedSpans, actualOutput.toString(), actualSpans);
|
| +}
|
| +
|
| +function checkSpeechOutput(expectedText, expectedSpans, output) {
|
| + var actualOutput = output.speechOutputForTest;
|
| + checkOutput_(expectedText,
|
| + expectedSpans,
|
| + actualOutput.toString(),
|
| + actualOutput.spans_);
|
| +}
|
| +
|
| +/** @private */
|
| +function checkOutput_(expectedText, expectedSpans, actualText, actualSpans) {
|
| + assertEquals(expectedText, actualText);
|
| +
|
| + function describeSpanPrettyPrint(span) {
|
| + return describeSpan(span).replace(':', ': ')
|
| + .replace('"value":', 'value:')
|
| + .replace('"start":', 'start:')
|
| + .replace('"end":', 'end:')
|
| + .replace('"', '\'');
|
| + }
|
|
|
| function describeSpan(span) {
|
| var obj = {value: span.value, start: span.start, end: span.end};
|
| @@ -29,7 +51,8 @@ function checkBrailleOutput(expectedText, expectedSpans, output) {
|
| }
|
|
|
| function describeActualSpans() {
|
| - return '\nAll actual spans:\n' + actualSpans.map(describeSpan).join('\n');
|
| + return '\nAll actual spans:\n' +
|
| + actualSpans.map(describeSpanPrettyPrint).join('\n');
|
| }
|
|
|
| for (var i = 0, max = Math.max(expectedSpans.length, actualSpans.length);
|
| @@ -108,15 +131,13 @@ TEST_F('OutputE2ETest', 'Checkbox', function() {
|
| var el = root.firstChild.firstChild;
|
| var range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON({string_: '||Check box|not checked', 'spans_': [
|
| - // Checkbox earcon (based on the state).
|
| - {value: {earconId: 'CHECK_OFF'}, start: 0, end: 0},
|
| -
|
| - // Attributes.
|
| - {value: 'name', start: 1, end: 1},
|
| - {value: 'role', start: 2, end: 11},
|
| - {value: 'state', start: 12, end: 23}
|
| - ]}, o.speechOutputForTest);
|
| + checkSpeechOutput('|Check box|not checked',
|
| + [
|
| + {value: new Output.EarconAction('CHECK_OFF'), start: 0, end: 0},
|
| + {value: 'role', start: 1, end: 10},
|
| + {value: 'state', start: 11, end: 22}
|
| + ],
|
| + o);
|
| checkBrailleOutput(
|
| 'chk ( )',
|
| [{value: new Output.NodeSpan(el), start: 0, end: 7}],
|
| @@ -194,30 +215,32 @@ TEST_F('OutputE2ETest', 'Audio', function() {
|
| var el = root.firstChild.firstChild.firstChild.firstChild;
|
| var range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON(
|
| - {string_: 'play||Button|begin playback|audio|Tool bar|audio',
|
| - spans_:
|
| - [{value: {earconId: 'BUTTON'}, start: 0, end: 4},
|
| - {value: 'value', start: 5, end: 5},
|
| - {value: 'name', start: 28, end: 33},
|
| - {value: 'role', start: 34, end: 42},
|
| - {value: 'description', start: 43, end: 48}]
|
| - }, o.speechOutputForTest);
|
| +
|
| + checkSpeechOutput('play|Button|begin playback|audio|Tool bar',
|
| + [
|
| + {value: new Output.EarconAction('BUTTON'), start: 0, end: 4},
|
| + {value: 'description', start: 12, end: 26},
|
| + {value: 'name', start: 27, end: 32},
|
| + {value: 'role', start: 33, end: 41}
|
| + ],
|
| + o);
|
| +
|
| checkBrailleOutput(
|
| - 'play btn begin playback audio tlbar audio',
|
| + 'play btn begin playback audio tlbar',
|
| [{value: new Output.NodeSpan(el), start: 0, end: 23},
|
| - {value: new Output.NodeSpan(el.parent), start: 24, end: 41}],
|
| + {value: new Output.NodeSpan(el.parent), start: 24, end: 35}],
|
| o);
|
|
|
| el = el.nextSibling.nextSibling;
|
| var prevRange = range;
|
| range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, prevRange, 'navigate');
|
| - assertEqualsJSON({string_: '|0, , slider|audio time scrubber',
|
| - spans_:
|
| - [{value: {'earconId': 'SLIDER'}, start: 0, end: 0},
|
| - {value: 'description', start: 13, end: 32}]
|
| - }, o.speechOutputForTest);
|
| + checkSpeechOutput('|0, , slider|audio time scrubber',
|
| + [
|
| + {value: new Output.EarconAction('SLIDER'), start: 0, end: 0},
|
| + {value: 'description', start: 13, end: 32}
|
| + ],
|
| + o);
|
| // TODO(plundblad): Investigate this.
|
| checkBrailleOutput(
|
| '0, , slider audio time scrubber',
|
| @@ -239,41 +262,38 @@ TEST_F('OutputE2ETest', 'Input', function() {
|
| '<input type="search"</input>' +
|
| '<input type="invalidType"</input>',
|
| function(root) {
|
| - var expected = {string_: '', 'spans_': [
|
| - {value: 'name', start: 0, end: 0},
|
| -
|
| - // Earcon
|
| - {value: {earconId: 'EDITABLE_TEXT'}, start: 0, end: 0},
|
| -
|
| - // Selection span.
|
| - {value: {startIndex: 0, endIndex: 0, offset: 0},
|
| - start: 1, end: 1},
|
| -
|
| - {value: 'value', start: 1, end: 1},
|
| - {value: 'inputType', start: 2}
|
| - ]};
|
| + var expectedSpans = [
|
| + {value: 'name', start: 0, end: 0},
|
| + {value: new Output.EarconAction('EDITABLE_TEXT'), start: 0, end: 0},
|
| + {value: new Output.SelectionSpan(0, 0, 0), start: 1, end: 1},
|
| + {value: 'value', start: 1, end: 1},
|
| + {value: 'inputType', start: 2}
|
| + ];
|
|
|
| var expectedSpeechValues = [
|
| '||Edit text',
|
| '||Edit text, email entry',
|
| '||Password edit text',
|
| '||Edit text numeric only',
|
| - {string_: '||Spin button', spans_: [{value: 'name', start: 0, end: 0},
|
| - {value: {earconId:'LISTBOX'}, start: 0, end: 0},
|
| - {value: {startIndex: 0, endIndex: 0, offset: 0}, start: 1, end: 1},
|
| - {value: 'value', start: 1, end: 1},
|
| - {value: 'role', start: 2, end: 13}]},
|
| - {string_: '||Time control', spans_: [{value: 'name', start: 0, end: 0},
|
| - {value: 'value', start: 1, end: 1},
|
| - {value: 'role', start: 2, end: 14}]},
|
| - {string_: '||Date control', spans_: [{value: 'name', start: 0, end: 0},
|
| - {value: 'value', start: 1, end: 1},
|
| - {value: 'role', start: 2, end: 14}]},
|
| - {string_: 'Choose File|No file chosen|Button',
|
| - spans_: [{value: 'name', start: 0, end: 11},
|
| - {value: {earconId: "BUTTON"}, start: 0, end: 11},
|
| - {value: 'value', start: 12, end: 26},
|
| - {value: 'role', start: 27, end: 33}]},
|
| + ['||Spin button',
|
| + [{value: 'name', start: 0, end: 0},
|
| + {value: new Output.EarconAction('LISTBOX'), start: 0, end: 0},
|
| + {value: {startIndex: 0, endIndex: 0, offset: 0}, start: 1, end: 1},
|
| + {value: 'value', start: 1, end: 1},
|
| + {value: 'role', start: 2, end: 13}]
|
| + ],
|
| + ['Time control',
|
| + [{value: 'role', start: 0, end: 12}]
|
| + ],
|
| + ['Date control',
|
| + [{value: 'role', start: 0, end: 12}]
|
| + ],
|
| + ['Choose File|No file chosen|Button',
|
| + [{value: 'name', start: 0, end: 11},
|
| + {value: new Output.EarconAction("BUTTON"), start: 0, end: 11},
|
| + {value: 'value', start: 12, end: 26},
|
| + {value: 'role', start: 27, end: 33}]
|
| + ],
|
| '||Edit text, search entry',
|
| '||Edit text'
|
| ];
|
| @@ -298,11 +318,10 @@ TEST_F('OutputE2ETest', 'Input', function() {
|
| var range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| if (typeof expectedValue == 'object') {
|
| - assertEqualsJSON(expectedValue, o.speechOutputForTest);
|
| + checkSpeechOutput(expectedValue[0], expectedValue[1], o);
|
| } else {
|
| - expected.string_ = expectedValue;
|
| - expected.spans_[4].end = expectedValue.length;
|
| - assertEqualsJSON(expected, o.speechOutputForTest);
|
| + expectedSpans[4].end = expectedValue.length;
|
| + checkSpeechOutput(expectedValue, expectedSpans, o);
|
| }
|
| el = el.nextSibling;
|
| });
|
| @@ -338,11 +357,13 @@ TEST_F('OutputE2ETest', 'List', function() {
|
| var el = root.firstChild.firstChild;
|
| var range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON({string_: 'a||List item|list|with 3 items', spans_:
|
| - [{value: 'name', start: 0, end: 1},
|
| - {value: {earconId: 'LIST_ITEM'}, start: 0, end: 1},
|
| - {value: 'value', start: 2, end: 2},
|
| - {value: 'role', start: 13, end: 17}]}, o.speechOutputForTest);
|
| + checkSpeechOutput('a|List item|list|with 3 items',
|
| + [
|
| + {value: 'name', start: 0, end: 1},
|
| + {value: new Output.EarconAction('LIST_ITEM'), start: 0, end: 1},
|
| + {value: 'role', start: 12, end: 16}
|
| + ],
|
| + o);
|
| // TODO(plundblad): This output is wrong. Add special handling for
|
| // braille here.
|
| checkBrailleOutput(
|
| @@ -365,14 +386,14 @@ TEST_F('OutputE2ETest', 'Tree', function() {
|
| var el = root.firstChild.children[0].firstChild;
|
| var range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON(
|
| - {string_: 'a|Tree item|Expanded| 1 of 3 | level 1 ||Tree|with 3 items',
|
| - spans_: [
|
| - // TreeItem.
|
| + checkSpeechOutput(
|
| + 'a|Tree item|Expanded| 1 of 3 | level 1 |Tree|with 3 items',
|
| + [
|
| + {value: 'name', 'start': 0, end: 1},
|
| {value: 'state', start: 12, end: 20},
|
| - {value: 'name', 'start': 40, end: 40},
|
| - {value: 'role','start': 41, end: 45},
|
| - ]}, o.speechOutputForTest);
|
| + {value: 'role','start': 40, end: 44},
|
| + ],
|
| + o);
|
| // TODO(plundblad): Braille output is wrong.
|
| checkBrailleOutput(
|
| 'a tritm - 1/3 level 1 tree +3',
|
| @@ -384,13 +405,13 @@ TEST_F('OutputE2ETest', 'Tree', function() {
|
| el = root.firstChild.children[1].firstChild;
|
| range = cursors.Range.fromNode(el);
|
| o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON(
|
| - {string_: 'b|Tree item| 2 of 3 | level 1 ||Tree|with 3 items',
|
| - spans_: [
|
| - // TreeItem.
|
| - {value: 'name', start: 31, end: 31},
|
| - {value: 'role', 'start': 32, end: 36}
|
| - ]}, o.speechOutputForTest);
|
| + checkSpeechOutput(
|
| + 'b|Tree item| 2 of 3 | level 1 |Tree|with 3 items',
|
| + [
|
| + {value: 'name', start: 0, end: 1},
|
| + {value: 'role', 'start': 31, end: 35}
|
| + ],
|
| + o);
|
| // TODO(plundblad): Braille output is wrong.
|
| checkBrailleOutput(
|
| 'b tritm 2/3 level 1 tree +3',
|
| @@ -402,14 +423,14 @@ TEST_F('OutputE2ETest', 'Tree', function() {
|
| el = root.firstChild.children[2].firstChild;
|
| range = cursors.Range.fromNode(el);
|
| o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON(
|
| - {string_: 'c|Tree item|Collapsed| 3 of 3 | level 1 ||Tree|with 3 items',
|
| - spans_: [
|
| - // TreeItem.
|
| + checkSpeechOutput(
|
| + 'c|Tree item|Collapsed| 3 of 3 | level 1 |Tree|with 3 items',
|
| + [
|
| + {value: 'name', 'start': 0, end: 1},
|
| {value: 'state', start: 12, end: 21},
|
| - {value: 'name', 'start': 41, end: 41},
|
| - {value: 'role','start': 42, end: 46},
|
| - ]}, o.speechOutputForTest);
|
| + {value: 'role','start': 41, end: 45},
|
| + ],
|
| + o);
|
| // TODO(plundblad): Braille output is wrong.
|
| checkBrailleOutput(
|
| 'c tritm + 3/3 level 1 tree +3',
|
| @@ -454,11 +475,13 @@ TEST_F('OutputE2ETest', 'ListBox', function() {
|
| var el = root.firstChild.firstChild.firstChild;
|
| var range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON({string_: '1|List item| 1 of 2 ||List box|with 2 items',
|
| - spans_:
|
| - [{value: {earconId: 'LIST_ITEM'}, start: 0,end: 1},
|
| - {value: 'name', start: 21, end: 21},
|
| - {value: 'role', start: 22, end: 30}]}, o.speechOutputForTest);
|
| + checkSpeechOutput('1|List item| 1 of 2 |List box|with 2 items',
|
| + [
|
| + {value: 'name', start: 0, end: 1},
|
| + {value: new Output.EarconAction('LIST_ITEM'), start: 0,end: 1},
|
| + {value: 'role', start: 21, end: 29}
|
| + ],
|
| + o);
|
| checkBrailleOutput(
|
| '1 lstitm 1/2 lstbx +2',
|
| [{value: new Output.NodeSpan(el), start: 0, end: 12},
|
| @@ -505,10 +528,8 @@ TEST_F('OutputE2ETest', 'DivOmitsRole', function() {
|
| var el = root.firstChild.firstChild;
|
| var range = cursors.Range.fromNode(el);
|
| var o = new Output().withSpeechAndBraille(range, null, 'navigate');
|
| - assertEqualsJSON({string_: 'that has content|',
|
| - spans_: [
|
| - {value: 'name', start: 17, end: 17}
|
| - ]}, o.speechOutputForTest);
|
| + checkSpeechOutput('that has content',
|
| + [{value: 'name', start: 0, end: 16}], o);
|
| checkBrailleOutput(
|
| 'that has content',
|
| [{value: new Output.NodeSpan(el), start: 0, end: 16}],
|
| @@ -535,13 +556,13 @@ TEST_F('OutputE2ETest', 'LessVerboseAncestry', function() {
|
| new Output().withSpeech(secondRange, firstRange, 'navigate');
|
| var oWithPrevExit =
|
| new Output().withSpeech(thirdRange, secondRange, 'navigate');
|
| - assertEquals('inside||Article', oWithoutPrev.speechOutputForTest.string_);
|
| + assertEquals('inside|Article', oWithoutPrev.speechOutputForTest.string_);
|
|
|
| // Make sure we don't read the exited article ancestry change.
|
| - assertEquals('inside||Article', oWithPrev.speechOutputForTest.string_);
|
| + assertEquals('inside|Article', oWithPrev.speechOutputForTest.string_);
|
|
|
| // Different role; do read the exited article ancestry here.
|
| - assertEquals('inside|Exited Article.||Banner',
|
| + assertEquals('inside|Exited Article.|Banner',
|
| oWithPrevExit.speechOutputForTest.string_);
|
| });
|
| });
|
| @@ -556,7 +577,7 @@ TEST_F('OutputE2ETest', 'Brief', function() {
|
|
|
| localStorage['useVerboseMode'] = 'false';
|
| var oWithoutPrev = new Output().withSpeech(range, null, 'navigate');
|
| - assertEquals('inside|', oWithoutPrev.speechOutputForTest.string_);
|
| + assertEquals('inside', oWithoutPrev.speechOutputForTest.string_);
|
| });
|
| });
|
|
|
| @@ -627,7 +648,7 @@ TEST_F('OutputE2ETest', 'ComplexDiv', function() {
|
| function(root) {
|
| var div = root.find({role: 'div'});
|
| var o = new Output().withSpeech(cursors.Range.fromNode(div));
|
| - assertEquals('|ok||Button'
|
| + assertEquals('ok|Button'
|
| , o.speechOutputForTest.string_);
|
| });
|
| });
|
|
|