Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
| 6 * TestFixture for kiosk app settings WebUI testing. | 6 * TestFixture for kiosk app settings WebUI testing. |
| 7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
| 8 * @constructor | 8 * @constructor |
| 9 */ | 9 */ |
| 10 function AppListStartPageWebUITest() {} | 10 function AppListStartPageWebUITest() {} |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 createScriptProcessor: function(bufSize, in_channels, out_channels) { | 25 createScriptProcessor: function(bufSize, in_channels, out_channels) { |
| 26 return {connect: function(destination) {}, | 26 return {connect: function(destination) {}, |
| 27 disconnect: function() {}}; | 27 disconnect: function() {}}; |
| 28 } | 28 } |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 AppListStartPageWebUITest.prototype = { | 31 AppListStartPageWebUITest.prototype = { |
| 32 __proto__: testing.Test.prototype, | 32 __proto__: testing.Test.prototype, |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Sample doodle data. | |
| 36 */ | |
| 37 doodleData_: { | |
| 38 'ddljson': { | |
| 39 'transparent_large_image': { | |
| 40 'url': 'doodle.png' | |
| 41 } | |
| 42 } | |
| 43 }, | |
| 44 | |
| 45 /** | |
| 46 * Browser to app launcher start page. | 35 * Browser to app launcher start page. |
| 47 */ | 36 */ |
| 48 browsePreload: 'chrome://app-list/', | 37 browsePreload: 'chrome://app-list/', |
| 49 | 38 |
| 50 /** | 39 /** |
| 51 * Placeholder for mock speech recognizer. | 40 * Placeholder for mock speech recognizer. |
| 52 */ | 41 */ |
| 53 speechRecognizer: null, | 42 speechRecognizer: null, |
| 54 | 43 |
| 55 /** | 44 /** |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 navigator.webkitGetUserMedia = this.mockGetUserMedia_.bind(this); | 117 navigator.webkitGetUserMedia = this.mockGetUserMedia_.bind(this); |
| 129 this.audioTrackMocks = [mock(MediaStreamTrack), mock(MediaStreamTrack)]; | 118 this.audioTrackMocks = [mock(MediaStreamTrack), mock(MediaStreamTrack)]; |
| 130 } | 119 } |
| 131 }; | 120 }; |
| 132 | 121 |
| 133 TEST_F('AppListStartPageWebUITest', 'Basic', function() { | 122 TEST_F('AppListStartPageWebUITest', 'Basic', function() { |
| 134 assertEquals(this.browsePreload, document.location.href); | 123 assertEquals(this.browsePreload, document.location.href); |
| 135 }); | 124 }); |
| 136 | 125 |
| 137 TEST_F('AppListStartPageWebUITest', 'LoadDoodle', function() { | 126 TEST_F('AppListStartPageWebUITest', 'LoadDoodle', function() { |
| 138 var doodle = $('doodle'); | 127 var doodleData = { |
| 139 assertEquals('', doodle.src); | 128 'ddljson': { |
| 140 appList.startPage.onAppListDoodleUpdated(this.doodleData_, | 129 'transparent_large_image': { |
| 130 'url': 'doodle.png' | |
| 131 }, | |
| 132 'alt_text': 'Doodle alt text', | |
| 133 'target_url': '/target.html' | |
| 134 } | |
| 135 }; | |
| 136 | |
| 137 assertEquals(null, $('doodle')); | |
| 138 | |
| 139 // Load the doodle with a target url and alt text. | |
| 140 appList.startPage.onAppListDoodleUpdated(doodleData, | |
| 141 'http://example.com/'); | 141 'http://example.com/'); |
|
Matt Giuca
2015/02/03 07:08:50
Can you make this http://example.com/x/.
Then you
calamity
2015/02/04 03:16:22
Done.
| |
| 142 assertEquals('http://example.com/doodle.png', doodle.src); | 142 assertNotEquals(null, $('doodle')); |
| 143 assertEquals('http://example.com/doodle.png', $('doodle_image').src); | |
| 144 assertEquals(doodleData.ddljson.alt_text, $('doodle_image').title); | |
| 145 assertEquals('http://example.com/target.html', $('doodle_link').href); | |
| 146 | |
| 147 // Reload the doodle without a target url and alt text. | |
| 148 doodleData.ddljson.alt_text = undefined; | |
| 149 doodleData.ddljson.target_url = undefined; | |
| 150 appList.startPage.onAppListDoodleUpdated(doodleData, | |
| 151 'http://example.com/'); | |
| 152 assertNotEquals(null, $('doodle')); | |
| 153 assertEquals('http://example.com/doodle.png', $('doodle_image').src); | |
| 154 assertEquals('', $('doodle_image').title); | |
| 155 assertEquals(null, $('doodle_link')); | |
| 156 | |
| 157 | |
| 158 appList.startPage.onAppListDoodleUpdated({}, | |
| 159 'http://example.com/'); | |
| 160 assertEquals(null, $('doodle')); | |
| 143 }); | 161 }); |
| 144 | 162 |
| 145 TEST_F('AppListStartPageWebUITest', 'SpeechRecognitionState', function() { | 163 TEST_F('AppListStartPageWebUITest', 'SpeechRecognitionState', function() { |
| 146 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); | 164 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); |
| 147 appList.startPage.onAppListShown(); | 165 appList.startPage.onAppListShown(); |
| 148 this.mockHandler.expects(once()).setSpeechRecognitionState('RECOGNIZING'); | 166 this.mockHandler.expects(once()).setSpeechRecognitionState('RECOGNIZING'); |
| 149 appList.startPage.toggleSpeechRecognition(); | 167 appList.startPage.toggleSpeechRecognition(); |
| 150 Mock4JS.verifyAllMocks(); | 168 Mock4JS.verifyAllMocks(); |
| 151 Mock4JS.clearMocksToVerify(); | 169 Mock4JS.clearMocksToVerify(); |
| 152 | 170 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 Mock4JS.verifyAllMocks(); | 207 Mock4JS.verifyAllMocks(); |
| 190 Mock4JS.clearMocksToVerify(); | 208 Mock4JS.clearMocksToVerify(); |
| 191 | 209 |
| 192 this.mockHandler.expects(once()).speechResult('test,true'); | 210 this.mockHandler.expects(once()).speechResult('test,true'); |
| 193 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); | 211 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); |
| 194 for (var i = 0; i < this.audioTrackMocks.length; ++i) { | 212 for (var i = 0; i < this.audioTrackMocks.length; ++i) { |
| 195 this.audioTrackMocks[i].expects(once()).stop(); | 213 this.audioTrackMocks[i].expects(once()).stop(); |
| 196 } | 214 } |
| 197 this.sendSpeechResult('test', true); | 215 this.sendSpeechResult('test', true); |
| 198 }); | 216 }); |
| OLD | NEW |