Chromium Code Reviews| 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 GEN_INCLUDE([ | 5 GEN_INCLUDE([ |
| 6 'chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js']); | 6 'chrome/browser/resources/chromeos/chromevox/testing/assert_additions.js']); |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Shortcut for document.getElementById. | 9 * Shortcut for document.getElementById. |
| 10 * @param {string} id of the element. | 10 * @param {string} id of the element. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 * * /}); | 112 * * /}); |
| 113 * | 113 * |
| 114 * @param {Function} commentEncodedHtml The html , embedded as a | 114 * @param {Function} commentEncodedHtml The html , embedded as a |
| 115 * comment inside an anonymous function - see example, above. | 115 * comment inside an anonymous function - see example, above. |
| 116 @ @return {String} The html text. | 116 @ @return {String} The html text. |
| 117 */ | 117 */ |
| 118 extractHtmlFromCommentEncodedString_: function(commentEncodedHtml) { | 118 extractHtmlFromCommentEncodedString_: function(commentEncodedHtml) { |
| 119 return commentEncodedHtml.toString(). | 119 return commentEncodedHtml.toString(). |
| 120 replace(/^[^\/]+\/\*!?/, ''). | 120 replace(/^[^\/]+\/\*!?/, ''). |
| 121 replace(/\*\/[^\/]+$/, ''); | 121 replace(/\*\/[^\/]+$/, ''); |
| 122 }, | |
| 123 | |
| 124 /** | |
| 125 * Waits for the queued events in ChromeVoxEventWatcher to be | |
| 126 * handled. Very useful for asserting the results of events. | |
| 127 * | |
| 128 * @param {function()} func A function to call when ChromeVox is ready. | |
| 129 * @return {ChromeVoxUnitTestBase} this. | |
| 130 */ | |
| 131 waitForCalm_: function(func, var_args) { | |
| 132 // For convenience, execute the functions in the test case scope. | |
| 133 var me = this; | |
| 134 var calmArguments = Array.prototype.slice.call(arguments); | |
| 135 calmArguments.shift(); | |
| 136 cvox.ChromeVoxEventWatcher.addReadyCallback(function() { | |
| 137 func.apply(me, calmArguments); | |
| 138 }); | |
| 139 return this; // for chaining. | |
| 140 }, | |
| 141 | |
| 142 /** | |
| 143 * Asserts a list of utterances are in the correct queue mode. | |
| 144 * @param {cvox.SpokenListBuilder|Array} expectedList A list | |
| 145 * of [text, queueMode] tuples OR a SpokenListBuilder with the expected | |
| 146 * utterances. | |
| 147 * @return {ChromeVoxUnitTestBase} this. | |
| 148 */ | |
| 149 assertSpokenList_: function(expectedList) { | |
|
Peter Lundblad
2014/09/19 08:14:58
nit: not private, so shouldn't have _ at the end.
dmazzoni
2014/09/22 07:14:55
Done.
| |
| 150 if (expectedList instanceof cvox.SpokenListBuilder) { | |
| 151 expectedList = expectedList.build(); | |
| 152 } | |
| 153 | |
| 154 var ulist = cvox.ChromeVoxTester.testTts().getUtteranceInfoList(); | |
| 155 for (var i = 0; i < expectedList.length; i++) { | |
| 156 var text = expectedList[i][0]; | |
| 157 var queueMode = expectedList[i][1]; | |
| 158 this.assertSingleUtterance_(text, queueMode, | |
| 159 ulist[i].text, ulist[i].queueMode); | |
| 160 } | |
| 161 cvox.ChromeVoxTester.clearUtterances(); | |
| 162 return this; // for chaining. | |
| 163 }, | |
| 164 | |
| 165 assertSingleUtterance_: function( | |
| 166 expectedText, expectedQueueMode, text, queueMode) { | |
| 167 assertEquals(expectedQueueMode, queueMode); | |
| 168 assertEquals(expectedText, text); | |
| 122 } | 169 } |
| 123 }; | 170 }; |
| OLD | NEW |