| 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_next_e2e_test_base.js']); | 6 GEN_INCLUDE(['../../testing/chromevox_next_e2e_test_base.js']); |
| 7 | 7 |
| 8 GEN_INCLUDE(['../../testing/mock_tts.js']); | 8 GEN_INCLUDE(['../../testing/mock_tts.js']); |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 chrome.automation.getDesktop(function(root) { | 86 chrome.automation.getDesktop(function(root) { |
| 87 var testButton = findStatusTray(root); | 87 var testButton = findStatusTray(root); |
| 88 cvox.ChromeVox.tts.expectSpeech('Status tray', testDone); | 88 cvox.ChromeVox.tts.expectSpeech('Status tray', testDone); |
| 89 testButton.focus(); | 89 testButton.focus(); |
| 90 }); | 90 }); |
| 91 }); | 91 }); |
| 92 | 92 |
| 93 /** Tests feedback once a page loads. */ | 93 /** Tests feedback once a page loads. */ |
| 94 TEST_F('BackgroundTest', 'InitialFeedback', function() { | 94 TEST_F('BackgroundTest', 'InitialFeedback', function() { |
| 95 cvox.ChromeVox.tts.expectSpeech('start', function() { | 95 cvox.ChromeVox.tts.expectSpeech('start', testDone); |
| 96 global.backgroundObj.onGotCommand('nextLine'); | |
| 97 }, true); | |
| 98 cvox.ChromeVox.tts.expectSpeech('end', testDone, true); | |
| 99 | 96 |
| 100 this.runWithDocument(function() {/*! | 97 this.runWithTab(function() {/*! |
| 101 <p>start | 98 <p>start |
| 102 <p>end | 99 <p>end |
| 103 */}, | 100 */}); |
| 104 function() {}); | |
| 105 }); | 101 }); |
| 106 | 102 |
| 107 /** Tests consistency of navigating forward and backward. */ | 103 /** Tests consistency of navigating forward and backward. */ |
| 108 TEST_F('BackgroundTest', 'ForwardBackwardNavigation', function() { | 104 TEST_F('BackgroundTest', 'ForwardBackwardNavigation', function() { |
| 109 cvox.ChromeVox.tts.expectSpeech('start', null, true); | 105 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { |
| 110 this.runWithDocument(this.linksAndHeadingsDoc, function() { | |
| 111 var doCmd = this.doCmd.bind(this); | 106 var doCmd = this.doCmd.bind(this); |
| 112 var expectAfter = | 107 var expectAfter = |
| 113 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); | 108 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); |
| 114 | 109 |
| 115 expectAfter('alpha', doCmd('nextLink')); | 110 expectAfter('alpha', doCmd('nextLink')); |
| 116 expectAfter('beta', doCmd('nextLink')); | 111 expectAfter('beta', doCmd('nextLink')); |
| 117 expectAfter('delta', doCmd('nextLink')); | 112 expectAfter('delta', doCmd('nextLink')); |
| 118 expectAfter('beta', doCmd('previousLink')); | 113 expectAfter('beta', doCmd('previousLink')); |
| 119 | 114 |
| 120 expectAfter('charlie', doCmd('nextHeading')); | 115 expectAfter('charlie', doCmd('nextHeading')); |
| 121 expectAfter('foxtraut', doCmd('nextHeading')); | 116 expectAfter('foxtraut', doCmd('nextHeading')); |
| 122 expectAfter('charlie', doCmd('previousHeading')); | 117 expectAfter('charlie', doCmd('previousHeading')); |
| 123 | 118 |
| 124 expectAfter('delta', doCmd('nextElement')); | 119 expectAfter('delta', doCmd('nextElement')); |
| 125 expectAfter('echo', doCmd('nextElement')); | 120 expectAfter('echo', doCmd('nextElement')); |
| 126 expectAfter('foxtraut', doCmd('nextElement')); | 121 expectAfter('foxtraut', doCmd('nextElement')); |
| 127 expectAfter('end', doCmd('nextElement')); | 122 expectAfter('end', doCmd('nextElement')); |
| 128 expectAfter('foxtraut', doCmd('previousElement')); | 123 expectAfter('foxtraut', doCmd('previousElement')); |
| 129 expectAfter('end of test', doCmd('nextLine')); | 124 expectAfter('end of test', doCmd('nextLine')); |
| 130 | 125 |
| 131 expectAfter('start', doCmd('goToBeginning')); | 126 expectAfter('start', doCmd('goToBeginning')); |
| 132 expectAfter('of test', doCmd('goToEnd')); | 127 expectAfter('of test', doCmd('goToEnd')); |
| 133 | 128 |
| 134 cvox.ChromeVox.tts.finishExpectations(); | 129 cvox.ChromeVox.tts.finishExpectations(); |
| 135 }.bind(this) | 130 }.bind(this) |
| 136 ); | 131 ); |
| 137 }); | 132 }); |
| 138 | 133 |
| 139 TEST_F('BackgroundTest', 'CaretNavigation', function() { | 134 TEST_F('BackgroundTest', 'CaretNavigation', function() { |
| 140 cvox.ChromeVox.tts.expectSpeech('start', null, true); | 135 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { |
| 141 this.runWithDocument(this.linksAndHeadingsDoc, function() { | |
| 142 var doCmd = this.doCmd.bind(this); | 136 var doCmd = this.doCmd.bind(this); |
| 143 var expectAfter = | 137 var expectAfter = |
| 144 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); | 138 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); |
| 145 | 139 |
| 146 expectAfter('t', doCmd('nextCharacter'), true); | 140 expectAfter('t', doCmd('nextCharacter'), true); |
| 147 expectAfter('a', doCmd('nextCharacter'), true); | 141 expectAfter('a', doCmd('nextCharacter'), true); |
| 148 expectAfter('Link alpha', doCmd('nextWord'), true); | 142 expectAfter('Link alpha', doCmd('nextWord'), true); |
| 149 expectAfter('Link beta', doCmd('nextWord'), true); | 143 expectAfter('Link beta', doCmd('nextWord'), true); |
| 150 expectAfter('Heading charlie', doCmd('nextWord'), true); | 144 expectAfter('Heading charlie', doCmd('nextWord'), true); |
| 151 expectAfter('Link delta', doCmd('nextLine'), true); | 145 expectAfter('Link delta', doCmd('nextLine'), true); |
| 152 expectAfter('Link echo', doCmd('nextLine'), true); | 146 expectAfter('Link echo', doCmd('nextLine'), true); |
| 153 expectAfter('Heading foxtraut', doCmd('nextLine'), true); | 147 expectAfter('Heading foxtraut', doCmd('nextLine'), true); |
| 154 expectAfter( | 148 expectAfter( |
| 155 'end of test', doCmd('nextLine'), true); | 149 'end of test', doCmd('nextLine'), true); |
| 156 expectAfter('n', doCmd('nextCharacter'), true); | 150 expectAfter('n', doCmd('nextCharacter'), true); |
| 157 expectAfter('e', doCmd('previousCharacter'), true); | 151 expectAfter('e', doCmd('previousCharacter'), true); |
| 158 expectAfter('Heading t', doCmd('previousCharacter'), true); | 152 expectAfter('Heading t', doCmd('previousCharacter'), true); |
| 159 expectAfter('foxtraut', doCmd('previousWord'), true); | 153 expectAfter('foxtraut', doCmd('previousWord'), true); |
| 160 expectAfter('Link echo', doCmd('previousWord'), true); | 154 expectAfter('Link echo', doCmd('previousWord'), true); |
| 161 expectAfter('Link a', doCmd('previousCharacter'), true); | 155 expectAfter('Link a', doCmd('previousCharacter'), true); |
| 162 expectAfter('t', doCmd('previousCharacter'), true); | 156 expectAfter('t', doCmd('previousCharacter'), true); |
| 163 expectAfter('Link echo', doCmd('nextWord'), true); | 157 expectAfter('Link echo', doCmd('nextWord'), true); |
| 164 | 158 |
| 165 cvox.ChromeVox.tts.finishExpectations(); | 159 cvox.ChromeVox.tts.finishExpectations(); |
| 166 }.bind(this)); | 160 }.bind(this)); |
| 167 }); | 161 }); |
| 168 | 162 |
| 169 // Flaky: http://crbug.com/451362 | 163 // Flaky: http://crbug.com/451362 |
| 170 TEST_F('BackgroundTest', 'DISABLED_SelectSingleBasic', function() { | 164 TEST_F('BackgroundTest', 'DISABLED_SelectSingleBasic', function() { |
| 171 this.runWithDocument(this.formsDoc, function(tabId) { | 165 this.runWithLoadedTree(this.formsDoc, function(tabId) { |
| 172 var sendDownToSelect = | 166 var sendDownToSelect = |
| 173 this.sendKeyToElement.bind(this, tabId, 'Down', '#fruitSelect'); | 167 this.sendKeyToElement.bind(this, tabId, 'Down', '#fruitSelect'); |
| 174 var expect = cvox.ChromeVox.tts.expectSpeech.bind(cvox.ChromeVox.tts); | 168 var expect = cvox.ChromeVox.tts.expectSpeech.bind(cvox.ChromeVox.tts); |
| 175 expect('apple Menu item 1 of 3 ', sendDownToSelect, true); | 169 expect('apple Menu item 1 of 3 ', sendDownToSelect, true); |
| 176 expect('grape 2 of 3 ', sendDownToSelect, true); | 170 expect('grape 2 of 3 ', sendDownToSelect, true); |
| 177 expect('banana 3 of 3 ', testDone, true); | 171 expect('banana 3 of 3 ', testDone, true); |
| 178 cvox.ChromeVox.tts.finishExpectations(); | 172 cvox.ChromeVox.tts.finishExpectations(); |
| 179 }.bind(this)); | 173 }.bind(this)); |
| 180 }); | 174 }); |
| 181 | 175 |
| 182 TEST_F('BackgroundTest', 'ContinuousRead', function() { | 176 TEST_F('BackgroundTest', 'ContinuousRead', function() { |
| 183 cvox.ChromeVox.tts.expectSpeech('start', null, true); | 177 this.runWithLoadedTree(this.linksAndHeadingsDoc, function() { |
| 184 this.runWithDocument(this.linksAndHeadingsDoc, function() { | |
| 185 var doCmd = this.doCmd.bind(this); | 178 var doCmd = this.doCmd.bind(this); |
| 186 var expect = | 179 var expect = |
| 187 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); | 180 cvox.ChromeVox.tts.expectSpeechAfter.bind(cvox.ChromeVox.tts); |
| 188 var sendEndEvent = function() { | 181 var sendEndEvent = function() { |
| 189 window.setTimeout(function() { | 182 window.setTimeout(function() { |
| 190 this.sendEndEvent(); | 183 this.sendEndEvent(); |
| 191 }.bind(this), 0); | 184 }.bind(this), 0); |
| 192 }.bind(cvox.ChromeVox.tts); | 185 }.bind(cvox.ChromeVox.tts); |
| 193 | 186 |
| 194 expect('start', doCmd('continuousRead')); | 187 expect('start', doCmd('continuousRead')); |
| 195 expect('alpha Link', sendEndEvent); | 188 expect('alpha Link', sendEndEvent); |
| 196 expect('beta Link', sendEndEvent); | 189 expect('beta Link', sendEndEvent); |
| 197 expect('Heading charlie', sendEndEvent); | 190 expect('Heading charlie', sendEndEvent); |
| 198 cvox.ChromeVox.tts.finishExpectations(); | 191 cvox.ChromeVox.tts.finishExpectations(); |
| 199 }.bind(this)); | 192 }.bind(this)); |
| 200 }); | 193 }); |
| OLD | NEW |