@@ -27,9 +27,10 @@ module.exports = function (appClient) {
2727 /**
2828 * Gets the windowCapability
2929 * @param {Number } numberOfAlertFields - number of lines
30+ * @param {Boolean } supportsAlertIcon - whether alert icon is supported by the capability
3031 * @returns {WindowCapability } - the capability
3132 */
32- function getWindowCapability ( numberOfAlertFields ) {
33+ function getWindowCapability ( numberOfAlertFields , supportsAlertIcon ) {
3334 const alertText1 = new SDL . rpc . structs . TextField ( ) ;
3435 alertText1 . setNameParam ( SDL . rpc . enums . TextFieldName . alertText1 ) ;
3536 const alertText2 = new SDL . rpc . structs . TextField ( ) ;
@@ -56,13 +57,13 @@ module.exports = function (appClient) {
5657 const windowCapability = new SDL . rpc . structs . WindowCapability ( ) ;
5758 windowCapability . setTextFields ( returnList ) ;
5859
59- const imageField = new SDL . rpc . structs . ImageField ( ) ;
60- imageField . setNameParam ( SDL . rpc . enums . ImageFieldName . alertIcon ) ;
61- const imageFieldList = [ ] ;
62- imageFieldList . push ( imageField ) ;
63- windowCapability . setImageFields ( imageFieldList ) ;
64-
65- windowCapability . setImageFields ( imageFieldList ) ;
60+ if ( supportsAlertIcon ) {
61+ const imageField = new SDL . rpc . structs . ImageField ( ) ;
62+ imageField . setNameParam ( SDL . rpc . enums . ImageFieldName . alertIcon ) ;
63+ const imageFieldList = [ ] ;
64+ imageFieldList . push ( imageField ) ;
65+ windowCapability . setImageFields ( imageFieldList ) ;
66+ }
6667
6768 const softButtonCapabilities = new SDL . rpc . structs . SoftButtonCapabilities ( ) ;
6869 softButtonCapabilities . setImageSupported ( true ) ;
@@ -136,7 +137,7 @@ module.exports = function (appClient) {
136137 alertView . setShowWaitIndicator ( true ) ;
137138 alertView . canceledListener = ( ) => { } ;
138139
139- defaultMainWindowCapability = getWindowCapability ( 3 ) ;
140+ defaultMainWindowCapability = getWindowCapability ( 3 , true ) ;
140141 speechCapabilities = [ ] ;
141142 speechCapabilities . push ( SDL . rpc . enums . SpeechCapabilities . FILE ) ;
142143 alertCompletionListener = new SDL . manager . screen . utils . AlertCompletionListener ( ) . setOnComplete ( ( success , tryAgainTime ) => { } ) ;
@@ -159,13 +160,13 @@ module.exports = function (appClient) {
159160 . setMinorVersion ( 0 )
160161 . setPatchVersion ( 0 ) ;
161162 } ) ;
162- let windowCapability = getWindowCapability ( 1 ) ;
163+ let windowCapability = getWindowCapability ( 1 , true ) ;
163164 let presentAlertOperation = new SDL . manager . screen . utils . _PresentAlertOperation ( lifecycleManager , alertView , windowCapability , speechCapabilities , fileManager , 1 , ( ) => { } , new SDL . manager . screen . _AlertManagerBase . _AlertSoftButtonClearListener ( ) . setOnButtonClear ( ( ) => { } ) ) ;
164165 let alert = presentAlertOperation . alertRpc ( ) ;
165166
166167 Validator . assertEquals ( alert . getAlertText1 ( ) , `${ alertView . getText ( ) } - ${ alertView . getSecondaryText ( ) } - ${ alertView . getTertiaryText ( ) } ` ) ;
167168
168- windowCapability = getWindowCapability ( 2 ) ;
169+ windowCapability = getWindowCapability ( 2 , true ) ;
169170
170171 presentAlertOperation = new SDL . manager . screen . utils . _PresentAlertOperation ( lifecycleManager , alertView , windowCapability , speechCapabilities , fileManager , 1 , ( ) => { } , new SDL . manager . screen . _AlertManagerBase . _AlertSoftButtonClearListener ( ) . setOnButtonClear ( ( ) => { } ) ) ;
171172 alert = presentAlertOperation . alertRpc ( ) ;
@@ -200,7 +201,7 @@ module.exports = function (appClient) {
200201 // Test Images need to be uploaded, sending text and uploading images
201202 await presentAlertOperation . onExecute ( ) ;
202203
203- // Verifies that uploadArtworks gets called only with the fist presentAlertOperation.onExecute call
204+ // Verifies that uploadArtworks gets called only with the first presentAlertOperation.onExecute call
204205 Validator . assertTrue ( artStub . calledOnce ) ;
205206 Validator . assertTrue ( fileStub . calledOnce ) ;
206207 Validator . assertTrue ( alertStub . calledOnce ) ;
@@ -235,7 +236,7 @@ module.exports = function (appClient) {
235236 // Test Images need to be uploaded, sending text and uploading images
236237 await presentAlertOperation . _start ( ) ;
237238
238- // Verifies that uploadArtworks gets called only with the fist presentAlertOperation.onExecute call
239+ // Verifies that uploadArtworks gets called only with the first presentAlertOperation.onExecute call
239240 Validator . assertTrue ( artStub . notCalled ) ;
240241 Validator . assertTrue ( fileStub . notCalled ) ;
241242 Validator . assertTrue ( alertStub . calledOnce ) ;
@@ -263,7 +264,7 @@ module.exports = function (appClient) {
263264 // Test Images need to be uploaded, sending text and uploading images
264265 await presentAlertOperation . _start ( ) ;
265266
266- // Verifies that uploadArtworks gets called only with the fist presentAlertOperation.onExecute call
267+ // Verifies that uploadArtworks gets called only with the first presentAlertOperation.onExecute call
267268 Validator . assertTrue ( artStub . calledOnce ) ;
268269 Validator . assertTrue ( alertStub . calledOnce ) ;
269270
@@ -289,9 +290,44 @@ module.exports = function (appClient) {
289290 } ) ;
290291
291292 it ( 'testImageSetOnSuccessfulUpload' , async function ( ) {
292- presentAlertOperation . _uploadedImageNames . add ( alertView . getIcon ( ) . getName ( ) ) ;
293+ presentAlertOperation . _alertIconUploaded = true ;
293294 const alertRpc = presentAlertOperation . alertRpc ( ) ;
294295 Validator . assertEquals ( alertRpc . getAlertIcon ( ) . getValueParam ( ) , alertView . getIcon ( ) . getName ( ) ) ;
295296 } ) ;
297+
298+ it ( 'testPresentStaticIcon' , async function ( ) {
299+ const alertStub = sinon . stub ( lifecycleManager , 'sendRpcResolve' )
300+ . callsFake ( onAlertSuccess ) ;
301+ const artStub = sinon . stub ( fileManager , 'uploadArtworks' )
302+ . callsFake ( onArtworkUploadSuccess ) ;
303+ const fileStub = sinon . stub ( fileManager , 'uploadFiles' )
304+ . callsFake ( onArtworkUploadSuccess ) ;
305+ const versionStub = sinon . stub ( lifecycleManager , 'getSdlMsgVersion' )
306+ . callsFake ( function ( ) {
307+ return new SDL . rpc . structs . SdlMsgVersion ( )
308+ . setMajorVersion ( 6 )
309+ . setMinorVersion ( 0 )
310+ . setPatchVersion ( 0 ) ;
311+ } ) ;
312+
313+
314+ testAlertArtwork = new SDL . manager . file . filetypes . SdlArtwork ( SDL . manager . file . enums . StaticIconName . LEFT ) ;
315+ testAlertArtwork . setStaticIcon ( true ) ;
316+ alertView . setIcon ( testAlertArtwork ) ;
317+ alertView . setSoftButtons ( [ ] ) ;
318+
319+ presentAlertOperation = new SDL . manager . screen . utils . _PresentAlertOperation ( lifecycleManager , alertView , defaultMainWindowCapability , speechCapabilities , fileManager , 1 , alertCompletionListener , alertSoftButtonClearListener ) ;
320+ // Test Images need to be uploaded, sending text and uploading images
321+ await presentAlertOperation . _start ( ) ;
322+
323+ // upload artworks should not be called since this is a static icon
324+ Validator . assertTrue ( artStub . notCalled ) ;
325+ Validator . assertTrue ( alertStub . calledOnce ) ;
326+
327+ versionStub . restore ( ) ;
328+ fileStub . restore ( ) ;
329+ artStub . restore ( ) ;
330+ alertStub . restore ( ) ;
331+ } ) ;
296332 } ) ;
297333} ;
0 commit comments