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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 AppListStartPageWebUITest.prototype = { | 31 AppListStartPageWebUITest.prototype = { |
32 __proto__: testing.Test.prototype, | 32 __proto__: testing.Test.prototype, |
33 | 33 |
34 /** | 34 /** |
35 * Browser to app launcher start page. | 35 * Browser to app launcher start page. |
36 */ | 36 */ |
37 browsePreload: 'chrome://app-list/', | 37 browsePreload: 'chrome://app-list/', |
38 | 38 |
39 /** | 39 /** |
40 * Recommend apps data. | |
41 * @private | |
42 */ | |
43 recommendedApps_: [ | |
44 { | |
45 'appId': 'app_id_1', | |
46 'textTitle': 'app 1', | |
47 'iconUrl': 'icon_url_1' | |
48 }, | |
49 { | |
50 'appId': 'app_id_2', | |
51 'textTitle': 'app 2', | |
52 'iconUrl': 'icon_url_2' | |
53 } | |
54 ], | |
55 | |
56 /** | |
57 * Placeholder for mock speech recognizer. | 40 * Placeholder for mock speech recognizer. |
58 */ | 41 */ |
59 speechRecognizer: null, | 42 speechRecognizer: null, |
60 | 43 |
61 /** | 44 /** |
62 * Sends the speech recognition result. | 45 * Sends the speech recognition result. |
63 * | 46 * |
64 * @param {string} result The testing result. | 47 * @param {string} result The testing result. |
65 * @param {boolean} isFinal Whether the result is final or not. | 48 * @param {boolean} isFinal Whether the result is final or not. |
66 */ | 49 */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 102 } |
120 success({getAudioTracks: function() { return audioTracks; }}); | 103 success({getAudioTracks: function() { return audioTracks; }}); |
121 }, | 104 }, |
122 | 105 |
123 /** @override */ | 106 /** @override */ |
124 preLoad: function() { | 107 preLoad: function() { |
125 this.makeAndRegisterMockHandler(['initialize', | 108 this.makeAndRegisterMockHandler(['initialize', |
126 'launchApp', | 109 'launchApp', |
127 'setSpeechRecognitionState', | 110 'setSpeechRecognitionState', |
128 'speechResult']); | 111 'speechResult']); |
129 this.mockHandler.stubs().initialize().will(callFunction(function() { | 112 this.mockHandler.stubs().initialize(); |
130 appList.startPage.setRecommendedApps(this.recommendedApps_); | |
131 }.bind(this))); | |
132 this.mockHandler.stubs().launchApp(ANYTHING); | 113 this.mockHandler.stubs().launchApp(ANYTHING); |
133 | 114 |
134 this.registerMockSpeechRecognition_(); | 115 this.registerMockSpeechRecognition_(); |
135 window.AudioContext = mockAudioContext; | 116 window.AudioContext = mockAudioContext; |
136 navigator.webkitGetUserMedia = this.mockGetUserMedia_.bind(this); | 117 navigator.webkitGetUserMedia = this.mockGetUserMedia_.bind(this); |
137 this.audioTrackMocks = [mock(MediaStreamTrack), mock(MediaStreamTrack)]; | 118 this.audioTrackMocks = [mock(MediaStreamTrack), mock(MediaStreamTrack)]; |
138 } | 119 } |
139 }; | 120 }; |
140 | 121 |
141 TEST_F('AppListStartPageWebUITest', 'Basic', function() { | 122 TEST_F('AppListStartPageWebUITest', 'Basic', function() { |
142 assertEquals(this.browsePreload, document.location.href); | 123 assertEquals(this.browsePreload, document.location.href); |
143 | |
144 var recommendedApp = $('start-page').querySelector('.recommended-apps'); | |
145 assertEquals(this.recommendedApps_.length, recommendedApp.childElementCount); | |
146 for (var i = 0; i < recommendedApp.childElementCount; ++i) { | |
147 assertEquals(this.recommendedApps_[i].appId, | |
148 recommendedApp.children[i].appId); | |
149 } | |
150 }); | |
151 | |
152 TEST_F('AppListStartPageWebUITest', 'ClickToLaunch', function() { | |
153 var recommendedApp = $('start-page').querySelector('.recommended-apps'); | |
154 for (var i = 0; i < recommendedApp.childElementCount; ++i) { | |
155 this.mockHandler.expects(once()).launchApp( | |
156 [this.recommendedApps_[i].appId]); | |
157 cr.dispatchSimpleEvent(recommendedApp.children[i], 'click'); | |
158 } | |
159 }); | 124 }); |
160 | 125 |
161 TEST_F('AppListStartPageWebUITest', 'SpeechRecognitionState', function() { | 126 TEST_F('AppListStartPageWebUITest', 'SpeechRecognitionState', function() { |
162 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); | 127 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); |
163 appList.startPage.onAppListShown(); | 128 appList.startPage.onAppListShown(); |
164 this.mockHandler.expects(once()).setSpeechRecognitionState('RECOGNIZING'); | 129 this.mockHandler.expects(once()).setSpeechRecognitionState('RECOGNIZING'); |
165 appList.startPage.toggleSpeechRecognition(); | 130 appList.startPage.toggleSpeechRecognition(); |
166 Mock4JS.verifyAllMocks(); | 131 Mock4JS.verifyAllMocks(); |
167 Mock4JS.clearMocksToVerify(); | 132 Mock4JS.clearMocksToVerify(); |
168 | 133 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 Mock4JS.verifyAllMocks(); | 170 Mock4JS.verifyAllMocks(); |
206 Mock4JS.clearMocksToVerify(); | 171 Mock4JS.clearMocksToVerify(); |
207 | 172 |
208 this.mockHandler.expects(once()).speechResult('test,true'); | 173 this.mockHandler.expects(once()).speechResult('test,true'); |
209 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); | 174 this.mockHandler.expects(once()).setSpeechRecognitionState('READY'); |
210 for (var i = 0; i < this.audioTrackMocks.length; ++i) { | 175 for (var i = 0; i < this.audioTrackMocks.length; ++i) { |
211 this.audioTrackMocks[i].expects(once()).stop(); | 176 this.audioTrackMocks[i].expects(once()).stop(); |
212 } | 177 } |
213 this.sendSpeechResult('test', true); | 178 this.sendSpeechResult('test', true); |
214 }); | 179 }); |
OLD | NEW |