@@ -3,6 +3,7 @@ const SDL = require('../config.js').node;
33
44// Mocking framework used so that some RPCs are not actually sent to Core, but the response mimicked
55const sinon = require ( 'sinon' ) ;
6+ const { AppServiceManifest } = require ( '../../lib/js/src/rpc/structs/AppServiceManifest.js' ) ;
67const Test = require ( '../Test.js' ) ;
78const Validator = require ( '../Validator' ) ;
89
@@ -83,18 +84,79 @@ module.exports = function (appClient) {
8384
8485 function createDisplayCapabilities ( displayName , defaultMainWindow ) {
8586 const convertedCapabilities = new SDL . rpc . structs . DisplayCapabilities ( ) ;
86- convertedCapabilities . setDisplayType ( SDL . rpc . enums . DisplayType . SDL_GENERIC ) ; //deprecated but it is mandatory...
87+ convertedCapabilities . setDisplayType ( SDL . rpc . enums . DisplayType . SDL_GENERIC ) ; // deprecated but it is mandatory...
8788 convertedCapabilities . setDisplayName ( displayName ) ;
8889 convertedCapabilities . setTextFields ( defaultMainWindow . getTextFields ( ) ) ;
8990 convertedCapabilities . setImageFields ( defaultMainWindow . getImageFields ( ) ) ;
9091 convertedCapabilities . setTemplatesAvailable ( defaultMainWindow . getTemplatesAvailable ( ) ) ;
9192 convertedCapabilities . setNumCustomPresetsAvailable ( defaultMainWindow . getNumCustomPresetsAvailable ( ) ) ;
92- convertedCapabilities . setMediaClockFormats ( [ MediaClockFormat ] ) ; // mandatory field but can be empty
93- convertedCapabilities . setGraphicSupported ( defaultMainWindow . getImageTypeSupported ( ) . contains ( ImageType . DYNAMIC ) ) ;
93+ convertedCapabilities . setMediaClockFormats ( [ ] ) ; // mandatory field but can be empty
94+ convertedCapabilities . setGraphicSupported ( defaultMainWindow . getImageTypeSupported ( ) . contains ( SDL . rpc . enums . ImageType . DYNAMIC ) ) ;
9495
9596 return convertedCapabilities ;
9697 }
9798
99+ function createAppServiceCapability ( type , serviceName , serviceID , isActive , updateReason ) {
100+ const appServiceCapbility = new SDL . rpc . structs . AppServiceCapability ( )
101+ . setUpdatedAppServiceRecord (
102+ createAppServiceRecord ( type , serviceName , serviceID , isActive )
103+ )
104+ . setUpdateReason ( updateReason ) ;
105+ return appServiceCapbility ;
106+ }
107+
108+ function createAppServiceRecord ( type , serviceName , serviceID , isActive ) {
109+ const appServiceRecord = new SDL . rpc . structs . AppServiceRecord ( )
110+ . setServiceManifest (
111+ createAppServiceManifest ( type , serviceName )
112+ )
113+ . setServiceID ( serviceID )
114+ . setServiceActive ( isActive )
115+ . setServicePublish ( true ) ;
116+ return appServiceRecord ;
117+ }
118+
119+ function createAppServiceManifest ( type , serviceName ) {
120+ const manifest = new SDL . rpc . structs . AppServiceManifest ( )
121+ . setServiceName ( serviceName )
122+ . setRpcSpecVersion ( SDL . manager . lifecycle . _LifecycleManager . MAX_RPC_VERSION )
123+ . setAllowAppConsumers ( true ) ;
124+ const handledRPCs = [ ] ;
125+ const AppServiceType = SDL . rpc . enums . AppServiceType ;
126+
127+ switch ( type ) {
128+ case AppServiceType . MEDIA : {
129+ handledRPCs . push ( SDL . rpc . enums . FunctionID . ButtonPress ) ;
130+ manifest . setMediaServiceManifest ( new SDL . rpc . structs . MediaServiceManifest ( ) ) ;
131+ break ;
132+ }
133+ case AppServiceType . WEATHER : {
134+ const weatherServiceManifest = new SDL . rpc . structs . WeatherServiceManifest ( )
135+ . setCurrentForecastSupported ( true )
136+ . setMaxHourlyForecastAmount ( 6 )
137+ . setMaxMinutelyForecastAmount ( 30 )
138+ . setMaxMultidayForecastAmount ( 5 )
139+ . setWeatherForLocationSupported ( true ) ;
140+ manifest . setWeatherServiceManifest ( weatherServiceManifest ) ;
141+ break ;
142+ }
143+ case AppServiceType . NAVIGATION : {
144+ handledRPCs . push ( SDL . rpc . enums . FunctionID . SendLocation ) ;
145+ handledRPCs . push ( SDL . rpc . enums . FunctionID . GetWayPoints ) ;
146+ handledRPCs . push ( SDL . rpc . enums . FunctionID . SubscribeVehicleData ) ;
147+ handledRPCs . push ( SDL . rpc . enums . FunctionID . UnsubscribeVehicleData ) ;
148+
149+ const navigationServiceManifest = new SDL . rpc . structs . NavigationServiceManifest ( )
150+ . setAcceptsWaypoints ( true ) ;
151+ manifest . setNavigationServiceManifest ( navigationServiceManifest ) ;
152+ break ;
153+ }
154+ }
155+
156+ manifest . setHandledRPCs ( handledRPCs ) ;
157+ return manifest ;
158+ }
159+
98160 /**
99161 * Fires a GetSystemCapabilityResponse
100162 * @param {Boolean } success - Whether the request succeeds
@@ -117,7 +179,7 @@ module.exports = function (appClient) {
117179 . setSuccess ( success )
118180 . setSystemCapability ( systemCapability ) ;
119181 return response ;
120- }
182+ } ;
121183 }
122184
123185 /**
@@ -137,25 +199,25 @@ module.exports = function (appClient) {
137199 const displayCapabilityList = createDisplayCapabilityList ( Test . GENERAL_DISPLAYCAPABILITIES , Test . GENERAL_BUTTONCAPABILITIES_LIST , Test . GENERAL_SOFTBUTTONCAPABILITIES_LIST ) ;
138200
139201 Validator . assertTrue (
140- Validator . validateDisplayCapabilityList ( displayCapabilityList , scm . getCapability ( SDL . rpc . enums . SystemCapabilityType . DISPLAYS ) ) ) ;
202+ Validator . validateDisplayCapabilityList ( displayCapabilityList , scm . getCapability ( SDL . rpc . enums . SystemCapabilityType . DISPLAYS ) ) ) ;
141203 Validator . assertTrue (
142- Validator . validateHMICapabilities ( Test . GENERAL_HMICAPABILITIES , scm . getHmiCapabilities ( ) ) ) ;
204+ Validator . validateHMICapabilities ( Test . GENERAL_HMICAPABILITIES , scm . getHmiCapabilities ( ) ) ) ;
143205 Validator . assertTrue (
144- Validator . validateDisplayCapabilities ( Test . GENERAL_DISPLAYCAPABILITIES , scm . getDisplayCapabilities ( ) ) ) ;
206+ Validator . validateDisplayCapabilities ( Test . GENERAL_DISPLAYCAPABILITIES , scm . getDisplayCapabilities ( ) ) ) ;
145207 Validator . assertTrue (
146- Validator . validateAudioPassThruCapabilities ( Test . GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST , scm . getAudioPassThruCapabilities ( ) ) ) ;
208+ Validator . validateAudioPassThruCapabilities ( Test . GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST , scm . getAudioPassThruCapabilities ( ) ) ) ;
147209 Validator . assertTrue (
148- Validator . validateButtonCapabilities ( Test . GENERAL_BUTTONCAPABILITIES_LIST , scm . _buttonCapabilities ) ) ;
210+ Validator . validateButtonCapabilities ( Test . GENERAL_BUTTONCAPABILITIES_LIST , scm . _buttonCapabilities ) ) ;
149211 Validator . assertTrue (
150- Validator . validateHMIZoneCapabilities ( Test . GENERAL_HMIZONECAPABILITIES_LIST , scm . getHmiZoneCapabilities ( ) ) ) ;
212+ Validator . validateHMIZoneCapabilities ( Test . GENERAL_HMIZONECAPABILITIES_LIST , scm . getHmiZoneCapabilities ( ) ) ) ;
151213 Validator . assertTrue (
152- Validator . validatePresetBankCapabilities ( Test . GENERAL_PRESETBANKCAPABILITIES , scm . getPresetBankCapabilities ( ) ) ) ;
214+ Validator . validatePresetBankCapabilities ( Test . GENERAL_PRESETBANKCAPABILITIES , scm . getPresetBankCapabilities ( ) ) ) ;
153215 Validator . assertTrue (
154- Validator . validateSoftButtonCapabilities ( Test . GENERAL_SOFTBUTTONCAPABILITIES_LIST , scm . _softButtonCapabilities ) ) ;
216+ Validator . validateSoftButtonCapabilities ( Test . GENERAL_SOFTBUTTONCAPABILITIES_LIST , scm . _softButtonCapabilities ) ) ;
155217 Validator . assertTrue (
156- Validator . validateSpeechCapabilities ( Test . GENERAL_SPEECHCAPABILITIES_LIST , scm . getSpeechCapabilities ( ) ) ) ;
218+ Validator . validateSpeechCapabilities ( Test . GENERAL_SPEECHCAPABILITIES_LIST , scm . getSpeechCapabilities ( ) ) ) ;
157219 Validator . assertTrue (
158- Validator . validatePreRecordedSpeechCapabilities ( Test . GENERAL_PRERECORDEDSPEECH_LIST , scm . getPrerecordedSpeechCapabilities ( ) ) ) ;
220+ Validator . validatePreRecordedSpeechCapabilities ( Test . GENERAL_PRERECORDEDSPEECH_LIST , scm . getPrerecordedSpeechCapabilities ( ) ) ) ;
159221 done ( ) ;
160222 } ) ;
161223
@@ -935,7 +997,7 @@ module.exports = function (appClient) {
935997 const scmRpcListener = lifecycleManager . _rpcListeners . get ( SDL . rpc . enums . FunctionID . OnSystemCapabilityUpdated ) [ 0 ] ;
936998 Validator . assertNotNull ( scmRpcListener ) ;
937999
938- Validator . assertEquals ( scm . getCapability ( SDL . rpc . enums . SystemCapabilityType . APP_SERVICES ) . length , 0 ) ;
1000+ Validator . assertEquals ( scm . getCapability ( SDL . rpc . enums . SystemCapabilityType . APP_SERVICES ) . length , 0 ) ;
9391001
9401002 /* PERFORM A NOTIFICATION SEND THROUGH THE SCM */
9411003 const addServiceID = SDL . rpc . struct . AppServiceFactory . createAppServiceCapability ( AppServiceType . NAVIGATION , "test" , "3453" , true , null ) ;
0 commit comments