diff --git a/test_scripts/API/VehicleData/AudioSource/001_Success_deviceStatus_primaryAudioSource.lua b/test_scripts/API/VehicleData/AudioSource/001_Success_deviceStatus_primaryAudioSource.lua deleted file mode 100644 index 6c54ec2a30..0000000000 --- a/test_scripts/API/VehicleData/AudioSource/001_Success_deviceStatus_primaryAudioSource.lua +++ /dev/null @@ -1,80 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0182-audio-source-am-fm-xm.md --- --- Description: --- In case: --- 1) Mobile app sends GetVehicleData request with deviceStatus=true --- 2) SDL transfers this request to HMI --- 3) HMI responds with value from PrimaryAudioSource enum in deviceStatus.primaryAudioSource --- SDL must: --- 1) Process GetVehicleData response and transfer it to mobile ---------------------------------------------------------------------------------------------------- - ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local audioSources = { - "NO_SOURCE_SELECTED", - "CD", - "BLUETOOTH_STEREO_BTST", - "USB", - "USB2", - "LINE_IN", - "IPOD", - "MOBILE_APP", - "AM", - "FM", - "XM", - "DAB" -} - -local rpc = { - name = "GetVehicleData", - params = { - deviceStatus = true - } -} - ---[[ Local Functions ]] -local function processRPCSuccess(pAudioSource) - local cid = common.getMobileSession():SendRPC(rpc.name, rpc.params) - local vehicleDataValues = { - deviceStatus = { - primaryAudioSource = pAudioSource, - voiceRecOn = false, - btIconOn = false, - callActive = false, - phoneRoaming = false, - textMsgAvailable = false, - battLevelStatus = "TWO_LEVEL_BARS", - stereoAudioOutputMuted = false, - monoAudioOutputMuted = false, - signalLevelStatus = "ONE_LEVEL_BARS", - eCallEventActive = false - } - } - common.getHMIConnection():ExpectRequest("VehicleInfo." .. rpc.name, rpc.params) - :Do(function(_, data) - common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", vehicleDataValues) - end) - local responseParams = vehicleDataValues - responseParams.success = true - responseParams.resultCode = "SUCCESS" - common.getMobileSession():ExpectResponse(cid, responseParams) - common.wait(300) -end - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("RAI", common.registerApp) - -common.Title("Test") -for _, source in pairs(audioSources) do - common.Step("RPC " .. rpc.name .. " source " .. source, processRPCSuccess, { source }) -end - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/AudioSource/002_Success_flow_deviceStatus_primaryAudioSource.lua b/test_scripts/API/VehicleData/AudioSource/002_Success_flow_deviceStatus_primaryAudioSource.lua deleted file mode 100644 index 2909f543c0..0000000000 --- a/test_scripts/API/VehicleData/AudioSource/002_Success_flow_deviceStatus_primaryAudioSource.lua +++ /dev/null @@ -1,97 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0182-audio-source-am-fm-xm.md --- --- Description: --- In case: --- 1) Mobile app is subscribed to get deviceStatus vehicle data --- 2) HMI sends OnVehicleData with value from PrimaryAudioSource enum in deviceStatus.primaryAudioSource --- SDL must: --- 1) Process OnVehicleData notification and transfer it to mobile ---------------------------------------------------------------------------------------------------- - ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local audioSources = { - "NO_SOURCE_SELECTED", - "CD", - "BLUETOOTH_STEREO_BTST", - "USB", - "USB2", - "LINE_IN", - "IPOD", - "MOBILE_APP", - "AM", - "FM", - "XM", - "DAB" -} - -local rpc1 = { - name = "SubscribeVehicleData", - params = { - deviceStatus = true - } -} - -local vehicleDataResults = { - deviceStatus = { - dataType = "VEHICLEDATA_DEVICESTATUS", - resultCode = "SUCCESS" - } -} - -local rpc2 = { - name = "OnVehicleData", - params = { - deviceStatus = { - primaryAudioSource = "CD", - voiceRecOn = false, - btIconOn = false, - callActive = false, - phoneRoaming = false, - textMsgAvailable = false, - battLevelStatus = "TWO_LEVEL_BARS", - stereoAudioOutputMuted = false, - monoAudioOutputMuted = false, - signalLevelStatus = "ONE_LEVEL_BARS", - eCallEventActive = false - } - } -} - ---[[ Local Functions ]] -local function processRPCSubscribeSuccess() - local cid = common.getMobileSession():SendRPC(rpc1.name, rpc1.params) - common.getHMIConnection():ExpectRequest("VehicleInfo." .. rpc1.name, rpc1.params) - :Do(function(_, data) - common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", vehicleDataResults) - end) - - local responseParams = vehicleDataResults - responseParams.success = true - responseParams.resultCode = "SUCCESS" - common.getMobileSession():ExpectResponse(cid, responseParams) -end - -local function checkNotificationSuccess(pAudioSource) - rpc2.params.deviceStatus.primaryAudioSource = pAudioSource - common.getHMIConnection():SendNotification("VehicleInfo." .. rpc2.name, rpc2.params) - common.getMobileSession():ExpectNotification("OnVehicleData", rpc2.params) -end - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("RAI", common.registerApp) - -common.Title("Test") -common.Step("RPC " .. rpc1.name, processRPCSubscribeSuccess) -for _, source in pairs(audioSources) do - common.Step("RPC " .. rpc2.name .. " source " .. source, checkNotificationSuccess, { source }) -end - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GearStatus/001_GetVehicleData_with_one_param_in_gearStatus_structure.lua b/test_scripts/API/VehicleData/GearStatus/001_GetVehicleData_with_one_param_in_gearStatus_structure.lua deleted file mode 100644 index 267601273e..0000000000 --- a/test_scripts/API/VehicleData/GearStatus/001_GetVehicleData_with_one_param_in_gearStatus_structure.lua +++ /dev/null @@ -1,75 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0266-New-vehicle-data-GearStatus.md --- --- Description: SDL successfully processes GetVehicleData response if 'gearStatus' structure contains one parameter. --- --- In case: --- 1) App sends GetVehicleData(gearStatus=true) request. --- SDL does: --- a) transfer this request to HMI. --- 2) HMI sends the 'gearStatus' structure with only one parameter in GetVehicleData response. --- SDL does: --- a) respond with resultCode:'SUCCESS' to app with only one parameter. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - --- [[ Local Variables ]] -local param = "gearStatus" - -local transmissionTypeEnumValues = { - "MANUAL", - "AUTOMATIC", - "SEMI_AUTOMATIC", - "DUAL_CLUTCH", - "CONTINUOUSLY_VARIABLE", - "INFINITELY_VARIABLE", - "ELECTRIC_VARIABLE", - "DIRECT_DRIVE" -} - -local prndlEnumValues = { - "PARK", - "REVERSE", - "NEUTRAL", - "DRIVE", - "SPORT", - "LOWGEAR", - "FIRST", - "SECOND", - "THIRD", - "FOURTH", - "FIFTH", - "SIXTH", - "SEVENTH", - "EIGHTH", - "NINTH", - "TENTH", - "UNKNOWN", - "FAULT" -} - -local gearStatusData = { - userSelectedGear = prndlEnumValues, - actualGear = prndlEnumValues, - transmissionType = transmissionTypeEnumValues -} - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for sub_param, data in common.spairs(gearStatusData) do - for _, value in common.spairs(data) do - common.Step("RPC " .. common.rpc.get .. " param " .. sub_param .. "=" .. value, - common.getVehicleData, { param, { [sub_param] = value } }) - end -end - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GearStatus/002_OnVehicleData_with_only_one_param_in_gearStatus_structure.lua b/test_scripts/API/VehicleData/GearStatus/002_OnVehicleData_with_only_one_param_in_gearStatus_structure.lua deleted file mode 100644 index 2507ec028f..0000000000 --- a/test_scripts/API/VehicleData/GearStatus/002_OnVehicleData_with_only_one_param_in_gearStatus_structure.lua +++ /dev/null @@ -1,75 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0266-New-vehicle-data-GearStatus.md --- --- Description: SDL transfers OnVehicleData notification to app if HMI sends it with only one parameter --- in 'gearStatus' structure. --- --- In case: --- 1) App is subscribed to 'gearStatus' data. --- 2) HMI sends valid OnVehicleData notification with only one parameter in 'gearStatus' structure. --- SDL does: --- a) process this notification and transfer it to mobile app. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local param = "gearStatus" - -local transmissionTypeEnumValues = { - "MANUAL", - "AUTOMATIC", - "SEMI_AUTOMATIC", - "DUAL_CLUTCH", - "CONTINUOUSLY_VARIABLE", - "INFINITELY_VARIABLE", - "ELECTRIC_VARIABLE", - "DIRECT_DRIVE" -} - -local prndlEnumValues = { - "PARK", - "REVERSE", - "NEUTRAL", - "DRIVE", - "SPORT", - "LOWGEAR", - "FIRST", - "SECOND", - "THIRD", - "FOURTH", - "FIFTH", - "SIXTH", - "SEVENTH", - "EIGHTH", - "NINTH", - "TENTH", - "UNKNOWN", - "FAULT" -} - -local gearStatusData = { - userSelectedGear = prndlEnumValues, - actualGear = prndlEnumValues, - transmissionType = transmissionTypeEnumValues -} - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) -common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for sub_param, data in common.spairs(gearStatusData) do - for _, value in common.spairs(data) do - common.Step("RPC " .. common.rpc.on .. " param " .. sub_param .. "=" .. value, - common.sendOnVehicleData, { param, common.isExpected, { [sub_param] = value } }) - end -end - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GetVehicleData/001_GetVD_Success_flow.lua b/test_scripts/API/VehicleData/GetVehicleData/001_GetVD_Success_flow.lua index 31d29b4bb5..1cc958d9de 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/001_GetVD_Success_flow.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/001_GetVD_Success_flow.lua @@ -1,5 +1,6 @@ --------------------------------------------------------------------------------------------------- -- Description: Check that SDL processes GetVehicleData RPC with parameter +-- Positive cases for all VD parameters and sub-parameters -- -- Preconditions: -- 1) SDL and HMI are started @@ -18,17 +19,21 @@ --[[ Required Shared libraries ]] local common = require('test_scripts/API/VehicleData/common') +--[[ Local Constants ]] +local testTypes = { + common.testType.VALID_RANDOM_ALL, + common.testType.VALID_RANDOM_SUB +} + --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) -common.Title("Test") -for param in common.spairs(common.getVDParams()) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.get, common.getVehicleData, { param }) -end +common.runner.Title("Test") +common.runner.getTestsForGetVD(testTypes) -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GetVehicleData/002_GetVD_disallowed.lua b/test_scripts/API/VehicleData/GetVehicleData/002_GetVD_disallowed.lua index fd63a11aae..7297b402b6 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/002_GetVD_disallowed.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/002_GetVD_disallowed.lua @@ -37,16 +37,16 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams()) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) - common.Title("Test") - common.Step("RPC " .. common.rpc.get .. " DISALLOWED", common.processRPCFailure, + common.runner.Title("Test") + common.runner.Step("RPC " .. common.rpc.get .. " DISALLOWED", common.processRPCFailure, { common.rpc.get, param, result }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/GetVehicleData/003_GetVD_disallowed_after_PTU.lua b/test_scripts/API/VehicleData/GetVehicleData/003_GetVD_disallowed_after_PTU.lua index 4ff52c6933..82006170fa 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/003_GetVD_disallowed_after_PTU.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/003_GetVD_disallowed_after_PTU.lua @@ -33,6 +33,7 @@ local function getVDGroup(pDisallowedParam) for param in pairs(common.getVDParams()) do if param ~= pDisallowedParam then table.insert(params, param) end end + if #params == 0 then params = common.json.EMPTY_ARRAY end return { rpcs = { [common.rpc.get] = { @@ -53,18 +54,18 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams()) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) - common.Step("RPC GetVehicleData, SUCCESS", common.getVehicleData, { param }) + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) + common.runner.Step("RPC GetVehicleData, SUCCESS", common.getVehicleData, { param }) - common.Title("Test") - common.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) - common.Step("RPC " .. common.rpc.get .. " DISALLOWED after PTU", common.processRPCFailure, + common.runner.Title("Test") + common.runner.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) + common.runner.Step("RPC " .. common.rpc.get .. " DISALLOWED after PTU", common.processRPCFailure, { common.rpc.get, param, result }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/GetVehicleData/004_GetVD_HMI_responds_with_invalid_data.lua b/test_scripts/API/VehicleData/GetVehicleData/004_GetVD_HMI_responds_with_invalid_data.lua index f208568c27..b19df67fe1 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/004_GetVD_HMI_responds_with_invalid_data.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/004_GetVD_HMI_responds_with_invalid_data.lua @@ -18,18 +18,21 @@ --[[ Required Shared libraries ]] local common = require('test_scripts/API/VehicleData/common') +--[[ Local Constants ]] +local testTypes = { + common.testType.INVALID_TYPE +} + --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) + +common.runner.Title("Test") +common.runner.getTestsForGetVD(testTypes) -common.Title("Test") -for param, value in common.spairs(common.getVDParams()) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.get .. " invalid HMI response", common.processRPCgenericError, - { common.rpc.get, param, common.getInvalidData(value) }) -end +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GetVehicleData/005_GetVD_App_sends_invalid_request.lua b/test_scripts/API/VehicleData/GetVehicleData/005_GetVD_App_sends_invalid_request.lua index 38abe7d0af..60993ba38d 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/005_GetVD_App_sends_invalid_request.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/005_GetVD_App_sends_invalid_request.lua @@ -21,17 +21,17 @@ local result = "INVALID_DATA" local value = 123 --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams()) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.get .. " invalid App request", + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.get .. " invalid App request", common.processRPCFailure, { common.rpc.get, param, result, value }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GetVehicleData/006_GetVD_mandatory_parameters.lua b/test_scripts/API/VehicleData/GetVehicleData/006_GetVD_mandatory_parameters.lua index 66f7329864..d049b0b7f5 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/006_GetVD_mandatory_parameters.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/006_GetVD_mandatory_parameters.lua @@ -29,43 +29,21 @@ --[[ Required Shared libraries ]] local common = require('test_scripts/API/VehicleData/common') ---[[ Local Functions ]] -local function processRPC(pRPC, pParam, pValue, pIsSuccess) - local cid = common.getMobileSession():SendRPC(pRPC, { [pParam] = true }) - common.getHMIConnection():ExpectRequest("VehicleInfo." .. pRPC, { [pParam] = true }) - :Do(function(_, data) - common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", { [pParam] = pValue }) - end) - if pIsSuccess == true then - local responseParams = {} - responseParams[pParam] = pValue - responseParams.success = true - responseParams.resultCode = "SUCCESS" - common.getMobileSession():ExpectResponse(cid, responseParams) - else - common.getMobileSession():ExpectResponse(cid, - { success = false, resultCode = "GENERIC_ERROR", info = "Invalid message received from vehicle" }) - end -end +--[[ Local Constants ]] +local testTypes = { + common.testType.MANDATORY_ONLY, + common.testType.MANDATORY_MISSING +} --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("RAI", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) -common.Title("Test") -for param in pairs(common.mandatoryVD) do - common.Title("VD parameter: " .. param) - for caseName, value in pairs(common.getMandatoryOnlyCases(param)) do - common.Step("RPC " .. common.rpc.get .. " with " .. caseName .. " SUCCESS", processRPC, - { common.rpc.get, param, value, true }) - end - for caseName, value in pairs(common.getMandatoryMissingCases(param)) do - common.Step("RPC " .. common.rpc.get .. " with " .. caseName .. " GENERIC_ERROR", processRPC, - { common.rpc.get, param, value, false }) - end -end +common.runner.Title("Test") +common.runner.getTestsForGetVD(testTypes) -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GetVehicleData/007_GetVD_app_version_is_greater_than_parameter_version.lua b/test_scripts/API/VehicleData/GetVehicleData/007_GetVD_app_version_is_greater_than_parameter_version.lua index 594f26f7b9..30dda7e585 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/007_GetVD_app_version_is_greater_than_parameter_version.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/007_GetVD_app_version_is_greater_than_parameter_version.lua @@ -23,20 +23,20 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] -for param, version in common.spairs(common.versioningVD) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Set App version", common.setAppVersion, { version, common.operator.increase }) - common.Step("Register App", common.registerApp) +for _, test in common.spairs(common.getTests(common.rpc.get, common.testType.PARAM_VERSION)) do + common.runner.Title("VD parameter: " .. test.param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Set App version", common.setAppVersion, { test.version, common.operator.increase }) + common.runner.Step("Register App", common.registerApp) - common.Title("Test") - common.Step("RPC " .. common.rpc.get, common.getVehicleData, { param }) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isExpected }) - common.Step("RPC " .. common.rpc.unsub, common.processSubscriptionRPC, { common.rpc.unsub, param }) + common.runner.Title("Test") + common.runner.Step("RPC " .. common.rpc.get, common.getVehicleData, { test.param }) + common.runner.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, test.param }) + common.runner.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { test.param, common.isExpected }) + common.runner.Step("RPC " .. common.rpc.unsub, common.processSubscriptionRPC, { common.rpc.unsub, test.param }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/GetVehicleData/008_GetVD_app_version_is_less_than_parameter_version.lua b/test_scripts/API/VehicleData/GetVehicleData/008_GetVD_app_version_is_less_than_parameter_version.lua index 2cb4ca48d0..9f2119183f 100644 --- a/test_scripts/API/VehicleData/GetVehicleData/008_GetVD_app_version_is_less_than_parameter_version.lua +++ b/test_scripts/API/VehicleData/GetVehicleData/008_GetVD_app_version_is_less_than_parameter_version.lua @@ -26,20 +26,20 @@ local common = require('test_scripts/API/VehicleData/common') local result = "INVALID_DATA" --[[ Scenario ]] -for param, version in common.spairs(common.versioningVD) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Set App version", common.setAppVersion, { version, common.operator.decrease }) - common.Step("Register App", common.registerApp) +for _, test in common.spairs(common.getTests(common.rpc.get, common.testType.PARAM_VERSION)) do + common.runner.Title("VD parameter: " .. test.param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Set App version", common.setAppVersion, { test.version, common.operator.decrease }) + common.runner.Step("Register App", common.registerApp) - common.Title("Test") - common.Step("RPC " .. common.rpc.get, common.processRPCFailure, { common.rpc.get, param, result }) - common.Step("RPC " .. common.rpc.sub, common.processRPCFailure, { common.rpc.sub, param, result }) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isNotExpected }) - common.Step("RPC " .. common.rpc.unsub, common.processRPCFailure, { common.rpc.unsub, param, result }) + common.runner.Title("Test") + common.runner.Step("RPC " .. common.rpc.get, common.processRPCFailure, { common.rpc.get, test.param, result }) + common.runner.Step("RPC " .. common.rpc.sub, common.processRPCFailure, { common.rpc.sub, test.param, result }) + common.runner.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { test.param, common.isNotExpected }) + common.runner.Step("RPC " .. common.rpc.unsub, common.processRPCFailure, { common.rpc.unsub, test.param, result }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/GetVehicleData/009_GetVD_min_max_boundary_values.lua b/test_scripts/API/VehicleData/GetVehicleData/009_GetVD_min_max_boundary_values.lua new file mode 100644 index 0000000000..d00ace32fd --- /dev/null +++ b/test_scripts/API/VehicleData/GetVehicleData/009_GetVD_min_max_boundary_values.lua @@ -0,0 +1,49 @@ +---------------------------------------------------------------------------------------------------- +-- Description: Check that SDL processes GetVehicleData RPC with parameter +-- Positive/Negative cases for boundary values for all VD parameters and sub-parameters +-- +-- Preconditions: +-- 1) SDL and HMI are started +-- 2) GetVehicleData RPC and parameter are allowed by policies +-- 3) App is registered +-- +-- In case: +-- 1) App sends valid GetVehicleData(=true) request to SDL +-- SDL does: +-- - a) transfer this request to HMI +-- 2) HMI sends VI.GetVehicleData response with valid data for to SDL +-- (closest lower/upper values to the defined boundary) +-- SDL does: +-- - a) send GetVehicleData response with (success = true, resultCode = "SUCCESS", +-- = ) to App +-- 3) App sends valid GetVehicleData(=true) request to SDL +-- SDL does: +-- - a) transfer this request to HMI +-- 4) HMI sends VI.GetVehicleData response with invalid data for to SDL +-- (closest lower/upper values to the defined boundary) +-- SDL does: +-- - a) send GetVehicleData response with (success = false, resultCode = "GENERIC_ERROR") +---------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local common = require('test_scripts/API/VehicleData/common') + +--[[ Local Constants ]] +local testTypes = { + common.testType.LOWER_IN_BOUND, + common.testType.UPPER_IN_BOUND, + common.testType.LOWER_OUT_OF_BOUND, + common.testType.UPPER_OUT_OF_BOUND +} + +--[[ Scenario ]] +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) + +common.runner.Title("Test") +common.runner.getTestsForGetVD(testTypes) + +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/GetVehicleData/010_GetVD_enum_and_bool_values.lua b/test_scripts/API/VehicleData/GetVehicleData/010_GetVD_enum_and_bool_values.lua new file mode 100644 index 0000000000..8dd8567129 --- /dev/null +++ b/test_scripts/API/VehicleData/GetVehicleData/010_GetVD_enum_and_bool_values.lua @@ -0,0 +1,40 @@ +---------------------------------------------------------------------------------------------------- +-- Description: Check that SDL processes GetVehicleData RPC with parameter +-- Positive cases for all possible values for Enum and Boolean VD parameters and sub-parameters +-- +-- Preconditions: +-- 1) SDL and HMI are started +-- 2) GetVehicleData RPC and parameter are allowed by policies +-- 3) App is registered +-- +-- In case: +-- 1) App sends valid GetVehicleData(=true) request to SDL +-- SDL does: +-- - a) transfer this request to HMI +-- 2) HMI sends VI.GetVehicleData response with valid data to SDL +-- (iterate trough all possible enum and boolean values of applicable parameters) +-- SDL does: +-- - a) send GetVehicleData response with (success = true, resultCode = "SUCCESS", +-- = ) to App +---------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local common = require('test_scripts/API/VehicleData/common') + +--[[ Local Constants ]] +local testTypes = { + common.testType.ENUM_ITEMS, + common.testType.BOOL_ITEMS +} + +--[[ Scenario ]] +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) + +common.runner.Title("Test") +common.runner.getTestsForGetVD(testTypes) + +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/OnVehicleData/001_OnVD_Success.lua b/test_scripts/API/VehicleData/OnVehicleData/001_OnVD_Success.lua index a76b312a20..7fcd6ff2e8 100644 --- a/test_scripts/API/VehicleData/OnVehicleData/001_OnVD_Success.lua +++ b/test_scripts/API/VehicleData/OnVehicleData/001_OnVD_Success.lua @@ -1,5 +1,6 @@ --------------------------------------------------------------------------------------------------- -- Description: Check that SDL processes OnVehicleData notification with parameter +-- Positive cases for all VD parameters and sub-parameters -- -- Preconditions: -- 1) SDL and HMI are started @@ -16,22 +17,21 @@ --[[ Required Shared libraries ]] local common = require('test_scripts/API/VehicleData/common') +--[[ Local Constants ]] +local testTypes = { + common.testType.VALID_RANDOM_ALL, + common.testType.VALID_RANDOM_SUB +} + --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) -common.Title("Test") -for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isExpected }) -end -for param in common.spairs(common.getVDParams(false)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isNotExpected }) -end +common.runner.Title("Test") +common.runner.getTestsForOnVD(testTypes) -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/OnVehicleData/002_OnVD_disallowed.lua b/test_scripts/API/VehicleData/OnVehicleData/002_OnVD_disallowed.lua index 840e939679..a80476df51 100644 --- a/test_scripts/API/VehicleData/OnVehicleData/002_OnVD_disallowed.lua +++ b/test_scripts/API/VehicleData/OnVehicleData/002_OnVD_disallowed.lua @@ -40,16 +40,16 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) - common.Title("Test") - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.on .. " ignored", common.sendOnVehicleData, { param, common.isNotExpected }) + common.runner.Title("Test") + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) + common.runner.Step("RPC " .. common.rpc.on .. " ignored", common.sendOnVehicleData, { param, common.isNotExpected }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/OnVehicleData/003_OnVD_disallowed_after_PTU.lua b/test_scripts/API/VehicleData/OnVehicleData/003_OnVD_disallowed_after_PTU.lua index e13cb8503a..9f5a7da4a5 100644 --- a/test_scripts/API/VehicleData/OnVehicleData/003_OnVD_disallowed_after_PTU.lua +++ b/test_scripts/API/VehicleData/OnVehicleData/003_OnVD_disallowed_after_PTU.lua @@ -27,6 +27,8 @@ local function getVDGroup(pDisallowedParam) if param ~= pDisallowedParam then table.insert(params, param) end table.insert(all_params, param) end + if #all_params == 0 then all_params = common.json.EMPTY_ARRAY end + if #params == 0 then params = common.json.EMPTY_ARRAY end return { rpcs = { [common.rpc.sub] = { @@ -56,20 +58,20 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.on .. " transferred", common.sendOnVehicleData, + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) + common.runner.Step("RPC " .. common.rpc.on .. " transferred", common.sendOnVehicleData, { param, common.isExpected, getValue(param) }) - common.Title("Test") - common.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) - common.Step("RPC " .. common.rpc.on .. " ignored", common.sendOnVehicleData, + common.runner.Title("Test") + common.runner.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) + common.runner.Step("RPC " .. common.rpc.on .. " ignored", common.sendOnVehicleData, { param, common.isNotExpected, getValue(param) }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/OnVehicleData/004_OnVD_with_invalid_data.lua b/test_scripts/API/VehicleData/OnVehicleData/004_OnVD_with_invalid_data.lua index 1d307c1d4f..7c3122dc85 100644 --- a/test_scripts/API/VehicleData/OnVehicleData/004_OnVD_with_invalid_data.lua +++ b/test_scripts/API/VehicleData/OnVehicleData/004_OnVD_with_invalid_data.lua @@ -17,24 +17,20 @@ --[[ Required Shared libraries ]] local common = require('test_scripts/API/VehicleData/common') +--[[ Local Constants ]] +local testTypes = { + common.testType.INVALID_TYPE +} + --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) -common.Title("Test") -for param, value in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, - { param, common.isNotExpected, common.getInvalidData(value) }) -end -for param, value in common.spairs(common.getVDParams(false)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, - { param, common.isNotExpected, common.getInvalidData(value) }) -end +common.runner.Title("Test") +common.runner.getTestsForOnVD(testTypes) -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/OnVehicleData/005_OnVD_App_is_not_subscribed.lua b/test_scripts/API/VehicleData/OnVehicleData/005_OnVD_App_is_not_subscribed.lua index c3c0352e56..a89dbeafa8 100644 --- a/test_scripts/API/VehicleData/OnVehicleData/005_OnVD_App_is_not_subscribed.lua +++ b/test_scripts/API/VehicleData/OnVehicleData/005_OnVD_App_is_not_subscribed.lua @@ -23,23 +23,23 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isExpected }) - common.Step("RPC " .. common.rpc.unsub, common.processSubscriptionRPC, { common.rpc.unsub, param }) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isNotExpected }) + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) + common.runner.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isExpected }) + common.runner.Step("RPC " .. common.rpc.unsub, common.processSubscriptionRPC, { common.rpc.unsub, param }) + common.runner.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isNotExpected }) end for param in common.spairs(common.getVDParams(false)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isNotExpected }) + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { param, common.isNotExpected }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/OnVehicleData/006_OnVD_mandatory_parameters.lua b/test_scripts/API/VehicleData/OnVehicleData/006_OnVD_mandatory_parameters.lua index d94f6ed650..9458b93541 100644 --- a/test_scripts/API/VehicleData/OnVehicleData/006_OnVD_mandatory_parameters.lua +++ b/test_scripts/API/VehicleData/OnVehicleData/006_OnVD_mandatory_parameters.lua @@ -26,25 +26,21 @@ --[[ Required Shared libraries ]] local common = require('test_scripts/API/VehicleData/common') +--[[ Local Constants ]] +local testTypes = { + common.testType.MANDATORY_ONLY, + common.testType.MANDATORY_MISSING +} + --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("RAI", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) -common.Title("Test") -for param in pairs(common.mandatoryVD) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - for caseName, value in pairs(common.getMandatoryOnlyCases(param)) do - common.Step("RPC " .. common.rpc.on .. " with " .. caseName .. " Transfered", common.sendOnVehicleData, - { param, common.isExpected, value }) - end - for caseName, value in pairs(common.getMandatoryMissingCases(param)) do - common.Step("RPC " .. common.rpc.on .. " with " .. caseName .. " Ignored", common.sendOnVehicleData, - { param, common.isNotExpected, value }) - end -end +common.runner.Title("Test") +common.runner.getTestsForOnVD(testTypes) -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/OnVehicleData/007_OnVD_min_max_boundary_values.lua b/test_scripts/API/VehicleData/OnVehicleData/007_OnVD_min_max_boundary_values.lua new file mode 100644 index 0000000000..c652cd5e7b --- /dev/null +++ b/test_scripts/API/VehicleData/OnVehicleData/007_OnVD_min_max_boundary_values.lua @@ -0,0 +1,44 @@ +---------------------------------------------------------------------------------------------------- +-- Description: Check that SDL processes OnVehicleData notification with parameter +-- Positive/Negative cases for boundary values for all VD parameters and sub-parameters +-- +-- Preconditions: +-- 1) SDL and HMI are started +-- 2) SubscribeVehicleData, OnVehicleData RPCs and parameter are allowed by policies +-- 3) App is registered +-- 4) App is subscribed to parameter data +-- +-- In case: +-- 1) HMI sends OnVehicleData notification with valid data for parameter to SDL +-- (closest lower/upper values to the defined boundary) +-- SDL does: +-- - a) transfer this notification to App +-- Exception: Notification for unsubscribable VD parameter is not transfered +-- 2) HMI sends OnVehicleData notification with invalid data for parameter to SDL +-- (closest lower/upper values to the defined boundary) +-- SDL does: +-- - a) not transfer this notification to App +---------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local common = require('test_scripts/API/VehicleData/common') + +--[[ Local Constants ]] +local testTypes = { + common.testType.LOWER_IN_BOUND, + common.testType.UPPER_IN_BOUND, + common.testType.LOWER_OUT_OF_BOUND, + common.testType.UPPER_OUT_OF_BOUND +} + +--[[ Scenario ]] +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) + +common.runner.Title("Test") +common.runner.getTestsForOnVD(testTypes) + +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/OnVehicleData/008_OnVD_enum_and_bool_values.lua b/test_scripts/API/VehicleData/OnVehicleData/008_OnVD_enum_and_bool_values.lua new file mode 100644 index 0000000000..2cf71c44a9 --- /dev/null +++ b/test_scripts/API/VehicleData/OnVehicleData/008_OnVD_enum_and_bool_values.lua @@ -0,0 +1,38 @@ +---------------------------------------------------------------------------------------------------- +-- Description: Check that SDL processes OnVehicleData notification with parameter +-- Positive cases for all possible values for Enum and Boolean VD parameters and sub-parameters +-- +-- Preconditions: +-- 1) SDL and HMI are started +-- 2) SubscribeVehicleData, OnVehicleData RPCs and parameter are allowed by policies +-- 3) App is registered +-- 4) App is subscribed to parameter data +-- +-- In case: +-- 1) HMI sends valid OnVehicleData notification with parameter data to SDL +-- (iterate trough all possible enum and boolean values of applicable parameters) +-- SDL does: +-- - a) transfer this notification to App +-- Exception: Notification for unsubscribable VD parameter is not transfered +---------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local common = require('test_scripts/API/VehicleData/common') + +--[[ Local Constants ]] +local testTypes = { + common.testType.ENUM_ITEMS, + common.testType.BOOL_ITEMS +} + +--[[ Scenario ]] +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) +common.runner.Step("Activate App", common.activateApp) + +common.runner.Title("Test") +common.runner.getTestsForOnVD(testTypes) + +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/RefactorFuelInformation/001_GetVehicleData_with_one_param_in_fuelRange_structure.lua b/test_scripts/API/VehicleData/RefactorFuelInformation/001_GetVehicleData_with_one_param_in_fuelRange_structure.lua deleted file mode 100644 index 4d2f95791f..0000000000 --- a/test_scripts/API/VehicleData/RefactorFuelInformation/001_GetVehicleData_with_one_param_in_fuelRange_structure.lua +++ /dev/null @@ -1,103 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0256-Refactor-Fuel-Information-Related-Vehicle-Data.md --- --- Description: SDL successfully processes GetVehicleData response if 'fuelRange' structure contains one parameter. --- --- In case: --- 1) App sends GetVehicleData(fuelRange=true) request. --- SDL does: --- a) transfer this request to HMI. --- 2) HMI sends the 'fuelRange' structure with only one parameter in GetVehicleData response. --- SDL does: --- a) respond with resultCode:'SUCCESS' to app with only one parameter. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local param = "fuelRange" - -local typeEnumValues = { - "GASOLINE", - "DIESEL", - "CNG", - "LPG", - "HYDROGEN", - "BATTERY" -} - -local levelStateEnumValues = { - "UNKNOWN", - "NORMAL", - "LOW", - "FAULT", - "ALERT", - "NOT_SUPPORTED" -} - -local capacityUnitEnumValues = { - "LITERS", - "KILOWATTHOURS", - "KILOGRAMS" -} - -local fuelRangeData = { - type = typeEnumValues[1], - range = 20, - level = 5, - levelState = levelStateEnumValues[1], - capacity = 1234, - capacityUnit = capacityUnitEnumValues[1] -} - -local fuelRangeDataMinValues = { - range = 0, - level = -6, - capacity = 0 -} - -local fuelRangeDataMaxValues = { - range = 10000, - level = 1000000, - capacity = 1000000 -} - -local maxArraySize = {} -for i = 1, 100 do - maxArraySize[i] = fuelRangeData -end - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for sub_param, value in common.spairs(fuelRangeDataMinValues) do - common.Step("RPC " .. common.rpc.get .. " minValue " .. sub_param .. "=" .. value, - common.getVehicleData, { param, { [1] = { [sub_param] = value } } }) -end -for sub_param, value in common.spairs(fuelRangeDataMaxValues) do - common.Step("RPC " .. common.rpc.get .. " maxValue " .. sub_param .. "=" .. value, - common.getVehicleData, { param, { [1] = { [sub_param] = value } } }) -end -for _, value in common.spairs(typeEnumValues) do - common.Step("RPC " .. common.rpc.get .. " enum value " .. "type" .. "=" .. value, - common.getVehicleData, { param, { [1] = { ["type"] = value } } }) -end -for _, value in common.spairs(levelStateEnumValues) do - common.Step("RPC " .. common.rpc.get .. " enum value " .. "levelState" .. "=" .. value, - common.getVehicleData, { param, { [1] = { ["levelState"] = value } } }) -end -for _, value in common.spairs(capacityUnitEnumValues) do - common.Step("RPC " .. common.rpc.get .. " enum value " .. "capacityUnit" .. "=" .. value, - common.getVehicleData, { param, { [1] = { ["capacityUnit"] = value } } }) -end -common.Step("RPC " .. common.rpc.get .. " max " .. param .. " array size", - common.getVehicleData, { param, maxArraySize }) - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/RefactorFuelInformation/002_OnVehicleData_with_only_one_param_in_fuelRange_structure.lua b/test_scripts/API/VehicleData/RefactorFuelInformation/002_OnVehicleData_with_only_one_param_in_fuelRange_structure.lua deleted file mode 100644 index e0188d9be7..0000000000 --- a/test_scripts/API/VehicleData/RefactorFuelInformation/002_OnVehicleData_with_only_one_param_in_fuelRange_structure.lua +++ /dev/null @@ -1,103 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0256-Refactor-Fuel-Information-Related-Vehicle-Data.md --- --- Description: SDL transfers OnVehicleData notification to app if HMI sends it with only one parameter --- in 'fuelRange' structure. --- --- In case: --- 1) App is subscribed to 'fuelRange' data. --- 2) HMI sends valid OnVehicleData notification with only one parameter in 'fuelRange' structure. --- SDL does: --- a) process this notification and transfer it to mobile app. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local param = "fuelRange" - -local typeEnumValues = { - "GASOLINE", - "DIESEL", - "CNG", - "LPG", - "HYDROGEN", - "BATTERY" -} - -local levelStateEnumValues = { - "UNKNOWN", - "NORMAL", - "LOW", - "FAULT", - "ALERT", - "NOT_SUPPORTED" -} - -local capacityUnitEnumValues = { - "LITERS", - "KILOWATTHOURS", - "KILOGRAMS" -} - -local fuelRangeData = { - type = typeEnumValues[1], - range = 20, - level = 5, - levelState = levelStateEnumValues[1], - capacity = 1234, - capacityUnit = capacityUnitEnumValues[1] -} - -local fuelRangeDataMinValues = { - range = 0, - level = -6, - capacity = 0 -} - -local fuelRangeDataMaxValues = { - range = 10000, - level = 1000000, - capacity = 1000000 -} - -local maxArraySize = {} -for i = 1, 100 do - maxArraySize[i] = fuelRangeData -end - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) -common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for sub_param, value in common.spairs(fuelRangeDataMinValues) do - common.Step("RPC " .. common.rpc.on .. " minValue " .. sub_param .. "=" .. value, - common.sendOnVehicleData, { param, common.isExpected, { [1] = { [sub_param] = value } } }) -end -for sub_param, value in common.spairs(fuelRangeDataMaxValues) do - common.Step("RPC " .. common.rpc.on .. " maxValue " .. sub_param .. "=" .. value, - common.sendOnVehicleData, { param, common.isExpected, { [1] = { [sub_param] = value } } }) -end -for _, value in common.spairs(typeEnumValues) do - common.Step("RPC " .. common.rpc.on .. " enum value " .. "type" .. "=" .. value, - common.sendOnVehicleData, { param, common.isExpected, { [1] = { ["type"] = value } } }) -end -for _, value in common.spairs(levelStateEnumValues) do - common.Step("RPC " .. common.rpc.on .. " enum value " .. "levelState" .. "=" .. value, - common.sendOnVehicleData, { param, common.isExpected, { [1] = { ["levelState"] = value } } }) -end -for _, value in common.spairs(capacityUnitEnumValues) do - common.Step("RPC " .. common.rpc.on .. " enum value " .. "capacityUnit" .. "=" .. value, - common.sendOnVehicleData, { param, common.isExpected, { [1] = { ["capacityUnit"] = value } } }) -end -common.Step("RPC " .. common.rpc.on .. " max " .. param .. " array size", - common.sendOnVehicleData, { param, common.isExpected, maxArraySize }) - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/StabilityControlsStatus/001_GetVehicleData_with_one_param_in_stabilityControlsStatus_structure.lua b/test_scripts/API/VehicleData/StabilityControlsStatus/001_GetVehicleData_with_one_param_in_stabilityControlsStatus_structure.lua deleted file mode 100644 index 8a7c1359f8..0000000000 --- a/test_scripts/API/VehicleData/StabilityControlsStatus/001_GetVehicleData_with_one_param_in_stabilityControlsStatus_structure.lua +++ /dev/null @@ -1,48 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/edit/master/proposals/0253-New-vehicle-data-StabilityControlsStatus.md --- --- Description: SDL successfully processes GetVehicleData response if 'stabilityControlsStatus' structure contains one parameter. --- --- In case: --- 1) App sends GetVehicleData(stabilityControlsStatus=true) request. --- SDL does: --- a) transfer this request to HMI. --- 2) HMI sends the 'stabilityControlsStatus' structure with only one parameter in GetVehicleData response. --- SDL does: --- a) respond with resultCode:'SUCCESS' to app with only one parameter. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local param = "stabilityControlsStatus" - -local vehicleDataStatusEnumValues = { - "NO_DATA_EXISTS", - "OFF", - "ON" -} - -local stabilityControlsStatusData = { - escSystem = vehicleDataStatusEnumValues, - trailerSwayControl = vehicleDataStatusEnumValues -} - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for sub_param, data in common.spairs(stabilityControlsStatusData) do - for _, value in common.spairs(data) do - common.Step("RPC " .. common.rpc.get .. " param " .. sub_param .. "=" .. value, - common.getVehicleData, { param, { [sub_param] = value } }) - end -end - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/StabilityControlsStatus/002_OnVehicleData_with_only_one_param_in_stabilityControlsStatus_structure.lua b/test_scripts/API/VehicleData/StabilityControlsStatus/002_OnVehicleData_with_only_one_param_in_stabilityControlsStatus_structure.lua deleted file mode 100644 index 1049d1ea2c..0000000000 --- a/test_scripts/API/VehicleData/StabilityControlsStatus/002_OnVehicleData_with_only_one_param_in_stabilityControlsStatus_structure.lua +++ /dev/null @@ -1,48 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal: https://github.com/smartdevicelink/sdl_evolution/edit/master/proposals/0253-New-vehicle-data-StabilityControlsStatus.md --- --- Description: SDL transfers OnVehicleData notification to app if HMI sends it with only one parameter --- in 'stabilityControlsStatus' structure. --- --- In case: --- 1) App is subscribed to 'stabilityControlsStatus' data. --- 2) HMI sends valid OnVehicleData notification with only one parameter in 'stabilityControlsStatus' structure. --- SDL does: --- a) process this notification and transfer it to mobile app. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local param = "stabilityControlsStatus" - -local vehicleDataStatusEnumValues = { - "NO_DATA_EXISTS", - "OFF", - "ON" -} - -local stabilityControlsStatusData = { - escSystem = vehicleDataStatusEnumValues, - trailerSwayControl = vehicleDataStatusEnumValues -} - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) -common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for sub_param, data in common.spairs(stabilityControlsStatusData) do - for _, value in common.spairs(data) do - common.Step("RPC " .. common.rpc.on .. " param " .. sub_param .. "=" .. value, - common.sendOnVehicleData, { param, common.isExpected, { [sub_param] = value } }) - end -end - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/001_SubscribeVD_Success.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/001_SubscribeVD_Success.lua index fcc2fdef1e..e9fb71508a 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/001_SubscribeVD_Success.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/001_SubscribeVD_Success.lua @@ -20,20 +20,20 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) end for param in common.spairs(common.getVDParams(false)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub, common.processRPCFailure, { common.rpc.sub, param, "INVALID_DATA" }) + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub, common.processRPCFailure, { common.rpc.sub, param, "INVALID_DATA" }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/002_SubscribeVD_disallowed.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/002_SubscribeVD_disallowed.lua index 9ea599a173..1e66ae4dd8 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/002_SubscribeVD_disallowed.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/002_SubscribeVD_disallowed.lua @@ -37,15 +37,15 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) - common.Title("Test") - common.Step("RPC " .. common.rpc.sub .. " DISALLOWED", common.processRPCFailure, { common.rpc.sub, param, result }) + common.runner.Title("Test") + common.runner.Step("RPC " .. common.rpc.sub .. " DISALLOWED", common.processRPCFailure, { common.rpc.sub, param, result }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/003_SubscribeVD_disallowed_after_PTU.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/003_SubscribeVD_disallowed_after_PTU.lua index c08b91a799..f59619440f 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/003_SubscribeVD_disallowed_after_PTU.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/003_SubscribeVD_disallowed_after_PTU.lua @@ -33,6 +33,7 @@ local function getVDGroup(pDisallowedParam) for param in pairs(common.getVDParams(true)) do if param ~= pDisallowedParam then table.insert(params, param) end end + if #params == 0 then params = common.json.EMPTY_ARRAY end return { rpcs = { [common.rpc.sub] = { @@ -53,17 +54,17 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) + common.runner.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Title("Test") - common.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) - common.Step("RPC " .. common.rpc.sub .. " DISALLOWED after PTU", common.processRPCFailure, { common.rpc.sub, result }) + common.runner.Title("Test") + common.runner.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) + common.runner.Step("RPC " .. common.rpc.sub .. " DISALLOWED after PTU", common.processRPCFailure, { common.rpc.sub, result }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/004_SubscribeVD_HMI_responds_with_invalid_data.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/004_SubscribeVD_HMI_responds_with_invalid_data.lua index fbe67d0bb6..70c3b0eec9 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/004_SubscribeVD_HMI_responds_with_invalid_data.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/004_SubscribeVD_HMI_responds_with_invalid_data.lua @@ -28,19 +28,19 @@ local function getInvalidData(pParam) end --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) + common.runner.Title("VD parameter: " .. param) for caseName, value in common.spairs(getInvalidData(param)) do - common.Step("RPC " .. common.rpc.sub .. " invalid HMI response " .. caseName, + common.runner.Step("RPC " .. common.rpc.sub .. " invalid HMI response " .. caseName, common.processRPCgenericError, { common.rpc.sub, param, value }) end end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/005_SubscribeVD_App_sends_invalid_request.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/005_SubscribeVD_App_sends_invalid_request.lua index 048472a607..7fc34f4c0a 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/005_SubscribeVD_App_sends_invalid_request.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/005_SubscribeVD_App_sends_invalid_request.lua @@ -21,17 +21,17 @@ local result = "INVALID_DATA" local value = 123 --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub .. " invalid App request", + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub .. " invalid App request", common.processRPCFailure, { common.rpc.sub, param, result, value }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/006_SubscribeVD_2nd_request_IGNORED.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/006_SubscribeVD_2nd_request_IGNORED.lua index 940582692a..181b64597d 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/006_SubscribeVD_2nd_request_IGNORED.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/006_SubscribeVD_2nd_request_IGNORED.lua @@ -24,26 +24,26 @@ local common = require('test_scripts/API/VehicleData/common') local result = "IGNORED" --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC 1 " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC 1 " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC 2 " .. common.rpc.sub .. " IGNORED", common.processRPCFailure, + common.runner.Step("RPC 2 " .. common.rpc.sub .. " IGNORED", common.processRPCFailure, { common.rpc.sub, param, result }) end for param in common.spairs(common.getVDParams(false)) do - common.Title("VD parameter: " .. param) - common.Step("RPC 1 " .. common.rpc.sub .. " INVALID_DATA", common.processRPCFailure, + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC 1 " .. common.rpc.sub .. " INVALID_DATA", common.processRPCFailure, { common.rpc.sub, param, "INVALID_DATA" }) - common.Step("RPC 2 " .. common.rpc.sub .. " INVALID_DATA", common.processRPCFailure, + common.runner.Step("RPC 2 " .. common.rpc.sub .. " INVALID_DATA", common.processRPCFailure, { common.rpc.sub, param, "INVALID_DATA" }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/007_SubscribeVD_for_2_apps.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/007_SubscribeVD_for_2_apps.lua index eea30c4ab0..ac38906f9f 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/007_SubscribeVD_for_2_apps.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/007_SubscribeVD_for_2_apps.lua @@ -24,26 +24,26 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App_1", common.registerApp, { common.app[1] }) -common.Step("Register App_2", common.registerAppWOPTU, { common.app[2] }) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App_1", common.registerApp, { common.app[1] }) +common.runner.Step("Register App_2", common.registerAppWOPTU, { common.app[2] }) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("Absence of OnVehicleData for both apps", + common.runner.Title("VD parameter: " .. param) + common.runner.Step("Absence of OnVehicleData for both apps", common.sendOnVehicleDataTwoApps, { param, common.isNotExpected, common.isNotExpected }) - common.Step("RPC " .. common.rpc.sub .. " for App_1", + common.runner.Step("RPC " .. common.rpc.sub .. " for App_1", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[1], common.isExpectedSubscription }) - common.Step("OnVehicleData for App_1", + common.runner.Step("OnVehicleData for App_1", common.sendOnVehicleDataTwoApps, { param, common.isExpected, common.isNotExpected }) - common.Step("RPC " .. common.rpc.sub .. " for App_2", + common.runner.Step("RPC " .. common.rpc.sub .. " for App_2", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[2], common.isNotExpectedSubscription }) - common.Step("OnVehicleData for both apps", + common.runner.Step("OnVehicleData for both apps", common.sendOnVehicleDataTwoApps, { param, common.isExpected, common.isExpected }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/008_SubscribeVD_HMI_responds_with_not_success_codes.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/008_SubscribeVD_HMI_responds_with_not_success_codes.lua index 72da15e82f..94744e5fcf 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/008_SubscribeVD_HMI_responds_with_not_success_codes.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/008_SubscribeVD_HMI_responds_with_not_success_codes.lua @@ -44,19 +44,19 @@ local function subscribeToVDwithUnsuccessCodeForVD(pParam, pCode) end --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) + common.runner.Title("VD parameter: " .. param) for _, code in common.spairs(resultCodes) do - common.Step("RPC " .. common.rpc.sub .. " resultCode " .. code, + common.runner.Step("RPC " .. common.rpc.sub .. " resultCode " .. code, subscribeToVDwithUnsuccessCodeForVD, { param, code }) end end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/009_SubscribeVD_Resumption_of_subscription_Unexpected_Disconnect.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/009_SubscribeVD_Resumption_of_subscription_Unexpected_Disconnect.lua index a54c17aa8e..a58f0404cd 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/009_SubscribeVD_Resumption_of_subscription_Unexpected_Disconnect.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/009_SubscribeVD_Resumption_of_subscription_Unexpected_Disconnect.lua @@ -19,21 +19,21 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) - common.Step("App subscribes to VD param", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) + common.runner.Step("App subscribes to VD param", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Title("Test") - common.Step("Unexpected disconnect", common.unexpectedDisconnect, { param }) - common.Step("Connect mobile", common.connectMobile) - common.Step("Re-register App resumption data", common.registerAppWithResumption, + common.runner.Title("Test") + common.runner.Step("Unexpected disconnect", common.unexpectedDisconnect, { param }) + common.runner.Step("Connect mobile", common.connectMobile) + common.runner.Step("Re-register App resumption data", common.registerAppWithResumption, { param, common.app[1], common.isExpectedSubscription }) - common.Step("OnVehicleData with VD param", common.sendOnVehicleData, { param, common.isExpected }) + common.runner.Step("OnVehicleData with VD param", common.sendOnVehicleData, { param, common.isExpected }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/010_SubscribeVD_Resumption_of_subscription_Ignition_Cycle.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/010_SubscribeVD_Resumption_of_subscription_Ignition_Cycle.lua index b2405c8c2a..08d1e81f7d 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/010_SubscribeVD_Resumption_of_subscription_Ignition_Cycle.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/010_SubscribeVD_Resumption_of_subscription_Ignition_Cycle.lua @@ -19,21 +19,21 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) - common.Step("App subscribes to VD param", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) + common.runner.Step("App subscribes to VD param", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Title("Test") - common.Step("Ignition Off", common.ignitionOff, { param }) - common.Step("Ignition On", common.start) - common.Step("Re-register App resumption data", common.registerAppWithResumption, + common.runner.Title("Test") + common.runner.Step("Ignition Off", common.ignitionOff, { param }) + common.runner.Step("Ignition On", common.start) + common.runner.Step("Re-register App resumption data", common.registerAppWithResumption, { param, common.app[1], common.isExpectedSubscription }) - common.Step("OnVehicleData with VD param", common.sendOnVehicleData, { param, common.isExpected }) + common.runner.Step("OnVehicleData with VD param", common.sendOnVehicleData, { param, common.isExpected }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/011_SubscribeVD_Resumption_of_subscription_for_2_apps_Unexpected_Disconnect.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/011_SubscribeVD_Resumption_of_subscription_for_2_apps_Unexpected_Disconnect.lua index accea4b3f1..30bc7ff389 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/011_SubscribeVD_Resumption_of_subscription_for_2_apps_Unexpected_Disconnect.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/011_SubscribeVD_Resumption_of_subscription_for_2_apps_Unexpected_Disconnect.lua @@ -26,27 +26,27 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App1", common.registerAppWOPTU, { common.app[1] }) - common.Step("Register App2", common.registerAppWOPTU, { common.app[2] }) - common.Step("App1 subscribes to VD param", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App1", common.registerAppWOPTU, { common.app[1] }) + common.runner.Step("Register App2", common.registerAppWOPTU, { common.app[2] }) + common.runner.Step("App1 subscribes to VD param", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[1], common.isExpectedSubscription }) - common.Step("App2 subscribes to VD param", common.processSubscriptionRPC, + common.runner.Step("App2 subscribes to VD param", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[2], common.isNotExpectedSubscription }) - common.Title("Test") - common.Step("Unexpected disconnect", common.unexpectedDisconnect, { param }) - common.Step("Connect mobile", common.connectMobile) - common.Step("Re-register App1 resumption data", common.registerAppWithResumption, + common.runner.Title("Test") + common.runner.Step("Unexpected disconnect", common.unexpectedDisconnect, { param }) + common.runner.Step("Connect mobile", common.connectMobile) + common.runner.Step("Re-register App1 resumption data", common.registerAppWithResumption, { param, common.app[1], common.isExpectedSubscription }) - common.Step("Re-register App2 resumption data", common.registerAppWithResumption, + common.runner.Step("Re-register App2 resumption data", common.registerAppWithResumption, { param, common.app[2], common.isNotExpectedSubscription }) - common.Step("OnVehicleData with VD param for both apps", common.sendOnVehicleDataTwoApps, + common.runner.Step("OnVehicleData with VD param for both apps", common.sendOnVehicleDataTwoApps, { param, common.isExpected, common.isExpected }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/SubscribeVehicleData/012_SubscribeVD_Resumption_of_subscription_for_2_apps_Ignition_Cycle.lua b/test_scripts/API/VehicleData/SubscribeVehicleData/012_SubscribeVD_Resumption_of_subscription_for_2_apps_Ignition_Cycle.lua index 6e78671a7e..a341ec3d21 100644 --- a/test_scripts/API/VehicleData/SubscribeVehicleData/012_SubscribeVD_Resumption_of_subscription_for_2_apps_Ignition_Cycle.lua +++ b/test_scripts/API/VehicleData/SubscribeVehicleData/012_SubscribeVD_Resumption_of_subscription_for_2_apps_Ignition_Cycle.lua @@ -26,27 +26,27 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App1", common.registerAppWOPTU, { common.app[1] }) - common.Step("Register App2", common.registerAppWOPTU, { common.app[2] }) - common.Step("App1 subscribes to VD param", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App1", common.registerAppWOPTU, { common.app[1] }) + common.runner.Step("Register App2", common.registerAppWOPTU, { common.app[2] }) + common.runner.Step("App1 subscribes to VD param", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[1], common.isExpectedSubscription }) - common.Step("App2 subscribes to VD param", common.processSubscriptionRPC, + common.runner.Step("App2 subscribes to VD param", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[2], common.isNotExpectedSubscription }) - common.Title("Test") - common.Step("Ignition Off", common.ignitionOff, { param }) - common.Step("Ignition On", common.start) - common.Step("Re-register App1 resumption data", common.registerAppWithResumption, + common.runner.Title("Test") + common.runner.Step("Ignition Off", common.ignitionOff, { param }) + common.runner.Step("Ignition On", common.start) + common.runner.Step("Re-register App1 resumption data", common.registerAppWithResumption, { param, common.app[1], common.isExpectedSubscription }) - common.Step("Re-register App2 resumption data", common.registerAppWithResumption, + common.runner.Step("Re-register App2 resumption data", common.registerAppWithResumption, { param, common.app[2], common.isNotExpectedSubscription }) - common.Step("OnVehicleData with VD param for both apps", common.sendOnVehicleDataTwoApps, + common.runner.Step("OnVehicleData with VD param for both apps", common.sendOnVehicleDataTwoApps, { param, common.isExpected, common.isExpected }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/001_UnsubscribeVD_Success.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/001_UnsubscribeVD_Success.lua index c22145513b..002620b5cd 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/001_UnsubscribeVD_Success.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/001_UnsubscribeVD_Success.lua @@ -21,23 +21,23 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.unsub, common.processSubscriptionRPC, { common.rpc.unsub, param }) + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) + common.runner.Step("RPC " .. common.rpc.unsub, common.processSubscriptionRPC, { common.rpc.unsub, param }) end for param in common.spairs(common.getVDParams(false)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.unsub .. " INVALID_DATA", common.processRPCFailure, + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.unsub .. " INVALID_DATA", common.processRPCFailure, { common.rpc.unsub, param, "INVALID_DATA" }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/002_UnsubscribeVD_disallowed.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/002_UnsubscribeVD_disallowed.lua index 98325f166b..63adcdff49 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/002_UnsubscribeVD_disallowed.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/002_UnsubscribeVD_disallowed.lua @@ -43,18 +43,18 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions, { getVDGroup(param) }) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) - common.Title("Test") - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Title("Test") + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.unsub .. " DISALLOWED", common.processRPCFailure, + common.runner.Step("RPC " .. common.rpc.unsub .. " DISALLOWED", common.processRPCFailure, { common.rpc.unsub, param, result }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/003_UnsubscribeVD_disallowed_after_PTU.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/003_UnsubscribeVD_disallowed_after_PTU.lua index 7868af5c9c..c9d2af127f 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/003_UnsubscribeVD_disallowed_after_PTU.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/003_UnsubscribeVD_disallowed_after_PTU.lua @@ -36,6 +36,8 @@ local function getVDGroup(pDisallowedParam) if param ~= pDisallowedParam then table.insert(params, param) end table.insert(all_params, param) end + if #all_params == 0 then all_params = common.json.EMPTY_ARRAY end + if #params == 0 then params = common.json.EMPTY_ARRAY end return { rpcs = { [common.rpc.sub] = { @@ -60,23 +62,23 @@ end --[[ Scenario ]] for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Title("Preconditions") - common.Step("Clean environment and update preloaded_pt file", common.preconditions) - common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) - common.Step("Register App", common.registerApp) - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Title("Preconditions") + common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) + common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) + common.runner.Step("Register App", common.registerApp) + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.unsub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Step("RPC " .. common.rpc.unsub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.unsub, param }) - common.Title("Test") - common.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Title("Test") + common.runner.Step("PTU with disabling permissions for VD parameter", policyTableUpdate, { param }) + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.unsub .. " DISALLOWED after PTU", common.processRPCFailure, + common.runner.Step("RPC " .. common.rpc.unsub .. " DISALLOWED after PTU", common.processRPCFailure, { common.rpc.unsub, result }) - common.Title("Postconditions") - common.Step("Stop SDL", common.postconditions) + common.runner.Title("Postconditions") + common.runner.Step("Stop SDL", common.postconditions) end diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/004_UnsubscribeVD_HMI_responds_with_invalid_data.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/004_UnsubscribeVD_HMI_responds_with_invalid_data.lua index 74d095fe0e..c679bbbb04 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/004_UnsubscribeVD_HMI_responds_with_invalid_data.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/004_UnsubscribeVD_HMI_responds_with_invalid_data.lua @@ -28,21 +28,21 @@ local function getInvalidData(pParam) end --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) for caseName, value in common.spairs(getInvalidData(param)) do - common.Step("RPC " .. common.rpc.unsub .. " invalid HMI response " .. caseName, + common.runner.Step("RPC " .. common.rpc.unsub .. " invalid HMI response " .. caseName, common.processRPCgenericError, { common.rpc.unsub, param, value }) end end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/005_UnsubscribeVD_App_sends_invalid_request.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/005_UnsubscribeVD_App_sends_invalid_request.lua index dab8821c18..f356e68339 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/005_UnsubscribeVD_App_sends_invalid_request.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/005_UnsubscribeVD_App_sends_invalid_request.lua @@ -21,19 +21,19 @@ local result = "INVALID_DATA" local value = 123 --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC " .. common.rpc.unsub .. " invalid App request", + common.runner.Step("RPC " .. common.rpc.unsub .. " invalid App request", common.processRPCFailure, { common.rpc.unsub, param, result, value }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua index 5c5555731e..7938b72e8e 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua @@ -25,28 +25,28 @@ local common = require('test_scripts/API/VehicleData/common') local result = "IGNORED" --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.sub, param }) - common.Step("RPC 1 " .. common.rpc.unsub .. " SUCCESS", common.processSubscriptionRPC, + common.runner.Step("RPC 1 " .. common.rpc.unsub .. " SUCCESS", common.processSubscriptionRPC, { common.rpc.unsub, param }) - common.Step("RPC 2 " .. common.rpc.unsub .. " IGNORED", common.processRPCFailure, + common.runner.Step("RPC 2 " .. common.rpc.unsub .. " IGNORED", common.processRPCFailure, { common.rpc.unsub, param, result }) end for param in common.spairs(common.getVDParams(false)) do - common.Title("VD parameter: " .. param) - common.Step("RPC 1 " .. common.rpc.unsub .. " INVALID_DATA", common.processRPCFailure, + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC 1 " .. common.rpc.unsub .. " INVALID_DATA", common.processRPCFailure, { common.rpc.unsub, param, "INVALID_DATA" }) - common.Step("RPC 2 " .. common.rpc.unsub .. " INVALID_DATA", common.processRPCFailure, + common.runner.Step("RPC 2 " .. common.rpc.unsub .. " INVALID_DATA", common.processRPCFailure, { common.rpc.unsub, param, "INVALID_DATA" }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/007_UnsubscribeVD_for_2_apps.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/007_UnsubscribeVD_for_2_apps.lua index be8d8bca1b..a6f6acb7cc 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/007_UnsubscribeVD_for_2_apps.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/007_UnsubscribeVD_for_2_apps.lua @@ -24,30 +24,30 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App_1", common.registerApp, { common.app[1] }) -common.Step("Register App_2", common.registerAppWOPTU, { common.app[2] }) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App_1", common.registerApp, { common.app[1] }) +common.runner.Step("Register App_2", common.registerAppWOPTU, { common.app[2] }) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub .. " for App_1", + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub .. " for App_1", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[1], common.isExpectedSubscription }) - common.Step("RPC " .. common.rpc.sub .. " for App_2", + common.runner.Step("RPC " .. common.rpc.sub .. " for App_2", common.processSubscriptionRPC, { common.rpc.sub, param, common.app[2], common.isNotExpectedSubscription }) - common.Step("OnVehicleData for both apps", + common.runner.Step("OnVehicleData for both apps", common.sendOnVehicleDataTwoApps, { param, common.isExpected, common.isExpected }) - common.Step("RPC " .. common.rpc.unsub .. " for App_1", + common.runner.Step("RPC " .. common.rpc.unsub .. " for App_1", common.processSubscriptionRPC, { common.rpc.unsub, param, common.app[1], common.isNotExpectedSubscription }) - common.Step("Absence of OnVehicleData for App_1", + common.runner.Step("Absence of OnVehicleData for App_1", common.sendOnVehicleDataTwoApps, { param, common.isNotExpected, common.isExpected }) - common.Step("RPC " .. common.rpc.unsub .. " for App_2", + common.runner.Step("RPC " .. common.rpc.unsub .. " for App_2", common.processSubscriptionRPC, { common.rpc.unsub, param, common.app[2], common.isExpectedSubscription }) - common.Step("Absence of OnVehicleData for both apps", + common.runner.Step("Absence of OnVehicleData for both apps", common.sendOnVehicleDataTwoApps, { param, common.isNotExpected, common.isNotExpected }) end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/UnsubscribeVehicleData/008_UnsubscribeVD_HMI_responds_with_not_success_codes.lua b/test_scripts/API/VehicleData/UnsubscribeVehicleData/008_UnsubscribeVD_HMI_responds_with_not_success_codes.lua index 8c0cce9673..ea4caf8f38 100644 --- a/test_scripts/API/VehicleData/UnsubscribeVehicleData/008_UnsubscribeVD_HMI_responds_with_not_success_codes.lua +++ b/test_scripts/API/VehicleData/UnsubscribeVehicleData/008_UnsubscribeVD_HMI_responds_with_not_success_codes.lua @@ -45,20 +45,20 @@ local function unsubscribeVDwithUnsuccessCodeForVD(pParam, pCode) end --[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment and update preloaded_pt file", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) +common.runner.Title("Preconditions") +common.runner.Step("Clean environment and update preloaded_pt file", common.preconditions) +common.runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +common.runner.Step("Register App", common.registerApp) -common.Title("Test") +common.runner.Title("Test") for param in common.spairs(common.getVDParams(true)) do - common.Title("VD parameter: " .. param) - common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) + common.runner.Title("VD parameter: " .. param) + common.runner.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) for _, code in common.spairs(resultCodes) do - common.Step("RPC " .. common.rpc.unsub .. " resultCode " .. code, + common.runner.Step("RPC " .. common.rpc.unsub .. " resultCode " .. code, unsubscribeVDwithUnsuccessCodeForVD, { param, code }) end end -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) +common.runner.Title("Postconditions") +common.runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/WindowStatus/001_GetVehicleData_boundary_values_windowStatus_structure.lua b/test_scripts/API/VehicleData/WindowStatus/001_GetVehicleData_boundary_values_windowStatus_structure.lua deleted file mode 100644 index 4fc2c7814a..0000000000 --- a/test_scripts/API/VehicleData/WindowStatus/001_GetVehicleData_boundary_values_windowStatus_structure.lua +++ /dev/null @@ -1,78 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal:https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0261-New-vehicle-data-WindowStatus.md --- --- Description: SDL processes GetVehicleData if HMI responds with valid values --- for 'windowStatus' structure sub-parameters: --- location: { col, row, level, colspan, rowspan, levelspan } --- state: { approximatePosition, deviation } --- --- In case: --- 1) App sends GetVehicleData request with windowStatus=true to the SDL and this request is allowed by Policies. --- 2) SDL transfers this request to HMI. --- 3) HMI sends GetVehicleData response with 'windowStatus' structure with valid values sub-parameters --- SDL does: --- a) process this response and transfer it to mobile app. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local param = "windowStatus" -local windowStatusData = { - { - location = { col = 0, row = 0, level = 0, colspan = 1, rowspan = 1, levelspan = 1 }, - state = { - approximatePosition = 50, - deviation = 50 - } - } -} - -local windowStatusDataMinValues = { - location = { col = -1, row = -1, level = -1, colspan = 1, rowspan = 1, levelspan = 1 }, - state = { approximatePosition = 0, deviation = 0 } -} - -local windowStatusDataMaxValues = { - location = { col = 100, row = 100, level = 100, colspan = 100, rowspan = 100, levelspan = 100 }, - state = { approximatePosition = 100, deviation = 100 } -} - -local maxArraySize = {} -for i = 1, 100 do - maxArraySize[i] = windowStatusData[1] -end - ---[[ Local Functions ]] -local function getCustomData(pSubParam, pParam, pValue) - local params = common.cloneTable(windowStatusData) - params[1][pParam][pSubParam] = pValue - return params -end - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for k in common.spairs(windowStatusData[1].state) do - common.Step("RPC " .. common.rpc.get .. " minValue " .. k .. "=" .. windowStatusDataMinValues.state[k], - common.getVehicleData, { param, getCustomData(k, "state", windowStatusDataMinValues.state[k]) }) - common.Step("RPC " .. common.rpc.get .. " maxValue " .. k .. "=" .. windowStatusDataMaxValues.state[k], - common.getVehicleData, { param, getCustomData(k, "state", windowStatusDataMaxValues.state[k]) }) -end -for k in common.spairs(windowStatusData[1].location) do - common.Step("RPC " .. common.rpc.get .. " minValue " .. k .. "=" .. windowStatusDataMinValues.location[k], - common.getVehicleData, { param, getCustomData(k, "location", windowStatusDataMinValues.location[k]) }) - common.Step("RPC " .. common.rpc.get .. " maxValue " .. k .. "=" .. windowStatusDataMaxValues.location[k], - common.getVehicleData, { param, getCustomData(k, "location", windowStatusDataMaxValues.location[k]) }) -end -common.Step("RPC " .. common.rpc.get .. " max windowStatus array size", - common.getVehicleData, { param, maxArraySize }) - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/WindowStatus/002_OnVehicleData_boundary_values_windowStatus_structure.lua b/test_scripts/API/VehicleData/WindowStatus/002_OnVehicleData_boundary_values_windowStatus_structure.lua deleted file mode 100644 index 13003fe5b2..0000000000 --- a/test_scripts/API/VehicleData/WindowStatus/002_OnVehicleData_boundary_values_windowStatus_structure.lua +++ /dev/null @@ -1,78 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- Proposal:https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0261-New-vehicle-data-WindowStatus.md --- --- Description: SDL transfers OnVehicleData notification to subscribed app if HMI sends this notification --- with valid values of 'windowStatus' structure sub-parameters: --- location: { col, row, level, colspan, rowspan, levelspan } --- state: { approximatePosition, deviation } --- --- In case: --- 1) App is subscribed to 'windowStatus' data. --- 2) HMI sends the 'windowStatus' structure with valid values for sub-parameters. --- SDL does: --- a) process this notification and transfer it to mobile app. ---------------------------------------------------------------------------------------------------- ---[[ Required Shared libraries ]] -local common = require('test_scripts/API/VehicleData/common') - ---[[ Local Variables ]] -local param = "windowStatus" -local windowStatusData = { - { - location = { col = 0, row = 0, level = 0, colspan = 1, rowspan = 1, levelspan = 1 }, - state = { - approximatePosition = 50, - deviation = 50 - } - } -} - -local windowStatusDataMinValues = { - location = { col = -1, row = -1, level = -1, colspan = 1, rowspan = 1, levelspan = 1 }, - state = { approximatePosition = 0, deviation = 0 } -} - -local windowStatusDataMaxValues = { - location = { col = 100, row = 100, level = 100, colspan = 100, rowspan = 100, levelspan = 100 }, - state = { approximatePosition = 100, deviation = 100 } -} - -local maxArraySize = {} -for i = 1, 100 do - maxArraySize[i] = windowStatusData[1] -end - ---[[ Local Functions ]] -local function getCustomData(pSubParam, pParam, pValue) - local params = common.cloneTable(windowStatusData) - params[1][pParam][pSubParam] = pValue - return params -end - ---[[ Scenario ]] -common.Title("Preconditions") -common.Step("Clean environment", common.preconditions) -common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("Register App", common.registerApp) -common.Step("Activate App", common.activateApp) -common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, param }) - -common.Title("Test") -common.Title("VD parameter: " .. param) -for k in common.spairs(windowStatusData[1].state) do - common.Step("RPC " .. common.rpc.on .. " minValue " .. k .. "=" .. windowStatusDataMinValues.state[k], - common.sendOnVehicleData, { param, common.isExpected, getCustomData(k, "state", windowStatusDataMinValues.state[k]) }) - common.Step("RPC " .. common.rpc.on .. " maxValue " .. k .. "=" .. windowStatusDataMaxValues.state[k], - common.sendOnVehicleData, { param, common.isExpected, getCustomData(k, "state", windowStatusDataMaxValues.state[k]) }) -end -for k in common.spairs(windowStatusData[1].location) do - common.Step("RPC " .. common.rpc.on .. " minValue " .. k .. "=" .. windowStatusDataMinValues.location[k], - common.sendOnVehicleData, { param, common.isExpected, getCustomData(k, "location", windowStatusDataMinValues.location[k]) }) - common.Step("RPC " .. common.rpc.on .. " maxValue " .. k .. "=" .. windowStatusDataMaxValues.location[k], - common.sendOnVehicleData, { param, common.isExpected, getCustomData(k, "location", windowStatusDataMaxValues.location[k]) }) -end -common.Step("RPC " .. common.rpc.on .. " max windowStatus array size", - common.sendOnVehicleData, { param, common.isExpected, maxArraySize }) - -common.Title("Postconditions") -common.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/VehicleData/common.lua b/test_scripts/API/VehicleData/common.lua index 31566c5d1c..951730d9f2 100644 --- a/test_scripts/API/VehicleData/common.lua +++ b/test_scripts/API/VehicleData/common.lua @@ -7,25 +7,21 @@ local runner = require('user_modules/script_runner') local utils = require("user_modules/utils") local json = require("modules/json") local SDL = require("SDL") -local apiLoader = require("modules/api_loader") local color = require("user_modules/consts").color +local api = require("user_modules/api/APIHelper") +local gen = require("user_modules/api/APITestDataGenerator") --[[ General configuration parameters ]] runner.testSettings.isSelfIncluded = false config.defaultProtocolVersion = 2 +config.zeroOccurrenceTimeout = 1000 ---[[ Local Variables ]] +--[[ Module ]] local m = {} -local hashId = {} -local api = { - hmi = apiLoader.init("data/HMI_API.xml"), - mob = apiLoader.init("data/MOBILE_API.xml") -} --[[ Common Proxy Functions ]] do - m.Title = runner.Title - m.Step = runner.Step + m.runner = runner m.getPreloadedPT = actions.sdl.getPreloadedPT m.setPreloadedPT = actions.sdl.setPreloadedPT m.registerApp = actions.app.register @@ -46,7 +42,7 @@ do m.json = actions.json end ---[[ Common Variables ]] +--[[ Common Constants and Variables ]] m.rpc = { get = "GetVehicleData", sub = "SubscribeVehicleData", @@ -54,6 +50,13 @@ m.rpc = { on = "OnVehicleData" } +m.rpcHMIMap = { + [m.rpc.get] = "VehicleInfo.GetVehicleData", + [m.rpc.sub] = "VehicleInfo.SubscribeVehicleData", + [m.rpc.unsub] = "VehicleInfo.UnsubscribeVehicleData", + [m.rpc.on] = "VehicleInfo.OnVehicleData" +} + m.vd = { vin = "", gps = "VEHICLEDATA_GPS", @@ -100,185 +103,138 @@ m.app = { [1] = 1, [2] = 2 } + m.isExpected = 1 m.isNotExpected = 0 m.isExpectedSubscription = true m.isNotExpectedSubscription = false ---[[ API Functions ]] +m.testType = { + VALID_RANDOM_ALL = 1, -- Positive: cases for VD parameters where all possible sub-parameters of hierarchy + -- are defined with valid random values + VALID_RANDOM_SUB = 2, -- Positive: cases for struct VD parameters and sub-parameters where only one sub-parameter + -- of hierarchy is defined with valid random value (mandatory also included) + LOWER_IN_BOUND = 3, -- Positive: cases for VD parameters and sub-parameters where only one sub-parameter + -- of hierarchy is defined with min valid value (mandatory also included) + UPPER_IN_BOUND = 4, -- Positive: cases for VD parameters and sub-parameters where only one sub-parameter + -- of hierarchy is defined with max valid value (mandatory also included) + LOWER_OUT_OF_BOUND = 5, -- Negative: cases for VD parameters and sub-parameters where only one sub-parameter + -- of hierarchy is defined with nearest invalid min value + UPPER_OUT_OF_BOUND = 6, -- Negative: cases for VD parameters and sub-parameters where only one sub-parameter + -- of hierarchy is defined with nearest invalid max value + INVALID_TYPE = 7, -- Negative: cases for VD parameters and sub-parameters with invalid type value defined + -- for one of them + ENUM_ITEMS = 8, -- Positive: cases for enum VD parameters and sub-parameters with all possible enum values + -- defined + BOOL_ITEMS = 9, -- Positive: cases for boolean VD parameters and sub-parameters with 'true' and 'false' + -- values defined + PARAM_VERSION = 10, -- Positive/Negative: cases for VD parameters with version defined + -- + MANDATORY_ONLY = 11, -- Positive: cases for struct VD parameters and sub-parameters + -- where only mandatory sub-parameters are defined with valid random values + MANDATORY_MISSING = 12 -- Negative: cases for struct VD parameters and sub-parameters + -- where only mandatory sub-parameters are defined and one of them is missing +} -math.randomseed(os.clock()) +m.isMandatory = { + YES = true, -- only mandatory + NO = false, -- only optional + ALL = 3 -- both mandatory and optional +} ---[[ @split: Split input string by '.' into a few sub-strings ---! @parameters: ---! pStr: input string ---! @return: table with sub-strings ---]] -local function split(pStr) - local result = {} - for match in (pStr.."."):gmatch("(.-)%.") do - if string.len(match) > 0 then table.insert(result, match) end - end - return result -end +m.isArray = { + YES = true, -- only array + NO = false, -- only non-array + ALL = 3 -- both array and non-array +} ---[[ @getParamValues: Generate VD parameter values bases on restrictions in API --- Function iterates through all structs recursively ---! @parameters: ---! pParams: table with parameters ---! pCmnSchema: table with data representation of 'Common' interface ---! @return: table with VD parameters and values +m.isVersion = { + YES = true, -- only with version + NO = false, -- only without version + ALL = 3 -- both with and without version +} + +--[[ Local Constants and Variables ]] +local hashId = {} +local isSubscribed = {} +local rpc +local rpcType +local testType +local paramName +local boundValueTypeMap = { + [m.testType.UPPER_IN_BOUND] = gen.valueType.UPPER_IN_BOUND, + [m.testType.LOWER_IN_BOUND] = gen.valueType.LOWER_IN_BOUND, + [m.testType.UPPER_OUT_OF_BOUND] = gen.valueType.UPPER_OUT_OF_BOUND, + [m.testType.LOWER_OUT_OF_BOUND] = gen.valueType.LOWER_OUT_OF_BOUND +} +local isRestricted = false + +--[[ Common Functions ]] + +--[[ @restrictAvailableVDParams: Restrict VD parameters for test by only ones defined in 'VD_PARAMS' environment variable +--! @parameters: none +--! @return: none --]] -function m.getParamValues(pParams, pCmnSchema) - local function getTypeValue(pData) - local itype = split(pData.type)[2] - local function getSimpleValue() - local tp = pData.type - local min = 1 - local max = 30 - -- set min/max restrictions - if tp == "Float" or tp == "Integer" then - if pData.minvalue ~= nil then min = pData.minvalue end - if pData.maxvalue ~= nil then max = pData.maxvalue end - end - if tp == "String" then - if pData.minlength ~= nil then min = pData.minlength end - if pData.maxlength ~= nil then max = pData.maxlength end - end - -- generate random value - if tp == "Boolean" then - return math.random(0, 1) == 1 - end - if tp == "Float" then - return tonumber(string.format('%.02f', math.random() + math.random(min, max-1))) - end - if tp == "Integer" then - return math.random(min, max) - end - if tp == "String" then - local length = math.random(min, max) - local res = "" - for _ = 1, length do - res = res .. string.char(math.random(97, 122)) -- [a-z] characters - end - return res - end - end - local function getEnumValue() - local data = {} - for k in m.spairs(pCmnSchema.enum[itype]) do - table.insert(data, k) +local function restrictAvailableVDParams() + local extVDParams = os.getenv("VD_PARAMS") + local checkedExtVDParams = {} + if extVDParams ~= nil then + m.cprint(color.magenta, "Environment variable 'VD_PARAMS': " .. extVDParams) + for _, p in pairs(utils.splitString(extVDParams, ",")) do + if m.vd[p] ~= nil then + isRestricted = true + table.insert(checkedExtVDParams, p) + else + m.cprint(color.magenta, "Unknown VD parameter:", p) end - return data[math.random(1, #data)] - end - local function getStructValue() - return m.getParamValues(pCmnSchema.struct[itype].param, pCmnSchema) - end - if pCmnSchema.struct[itype] ~= nil then - return getStructValue() - elseif pCmnSchema.enum[itype] ~= nil then - return getEnumValue() - else - return getSimpleValue() end end - local function getArrayTypeValue(pData) - local min = 1 - local max = 5 - if pData.minsize ~= nil and pData.minsize > min then min = pData.minsize end - if pData.maxsize ~= nil and pData.maxsize < max then max = pData.maxsize end - local numOfItems = math.random(min, max) - local out = {} - for _ = 1, numOfItems do - table.insert(out, getTypeValue(pData, pCmnSchema)) + if #checkedExtVDParams > 0 then + for k in pairs(m.vd) do + if not utils.isTableContains(checkedExtVDParams, k) then + m.vd[k] = nil + end end - return out - end - local out = {} - for k, v in pairs(pParams) do - if v.array == false then - out[k] = getTypeValue(v) - else - out[k] = getArrayTypeValue(v) + local checkedExtVDParamsToPrint = "" + for id, p in pairs(checkedExtVDParams) do + checkedExtVDParamsToPrint = checkedExtVDParamsToPrint .. p + if id ~= #checkedExtVDParams then checkedExtVDParamsToPrint = checkedExtVDParamsToPrint .. ", " end end + m.cprint(color.magenta, "Testing VD parameters restricted to: " .. checkedExtVDParamsToPrint) + else + m.cprint(color.magenta, "Testing VD parameters are not restricted") end - return out end ---[[ @getParamValuesFromAPI: Generate VD parameter values bases on restrictions in API --- This is a wrapper for 'm.getParamValues()' function ---! @parameters: ---! @return: table with VD parameters and values +restrictAvailableVDParams() + +--[[ @getAvailableVDParams: Return VD parameters available for processing +--! @parameters: none +--! @return: table with VD parameters --]] -local function getParamValuesFromAPI() - local viSchema = api.hmi.interface["VehicleInfo"] - local cmnSchema = api.hmi.interface["Common"] - local params = viSchema.type.response.functions.GetVehicleData.param - local paramValues = m.getParamValues(params, cmnSchema) +local function getAvailableVDParams() + local graph = api.getGraph(api.apiType.MOBILE, api.eventType.REQUEST, m.rpc.get) + local vdParams = {} + for _, data in pairs(graph) do + if data.parentId == nil then vdParams[data.name] = true end + end -- print not defined in API parameters for k in pairs(m.vd) do - if paramValues[k] == nil then + if vdParams[k] == nil then m.cprint(color.magenta, "Not found in API VD parameter:", k) end end -- remove disabled parameters - for k in pairs(paramValues) do + for k in pairs(vdParams) do if m.vd[k] == nil then - paramValues[k] = nil - m.cprint(color.magenta, "Disabled VD parameter:", k) + vdParams[k] = nil + if not isRestricted then m.cprint(color.magenta, "Disabled VD parameter:", k) end end end - return paramValues -end - -m.vdValues = getParamValuesFromAPI() - ---[[ @getMandatoryParamsFromAPI: Return VD parameters and values which has mandatory sub-parameters defined in API ---! @parameters: ---! @return: table with VD parameters and values ---]] -local function getMandatoryParamsFromAPI() - local out = {} - local viSchema = api.hmi.interface["VehicleInfo"] - local cmnSchema = api.hmi.interface["Common"] - local params = viSchema.type.response.functions.GetVehicleData.param - for k, v in pairs(params) do - local iface = split(v.type)[1] - local itype = split(v.type)[2] - if iface == "Common" then - if cmnSchema.struct[itype] ~= nil then - for k2, v2 in pairs(cmnSchema.struct[itype].param) do - if v2.mandatory == "true" and m.vd[k] then - if out[k] == nil then out[k] = { sub = {}, array = false } end - if v.array == "true" then out[k].array = true end - table.insert(out[k].sub, k2) - end - end - end - end - end - return out + return vdParams end -m.mandatoryVD = getMandatoryParamsFromAPI() - ---[[ @getVersioningParamsFromAPI: Return VD parameters and values which has version defined in API ---! @parameters: ---! @return: table with VD parameters and values ---]] -local function getVersioningParamsFromAPI() - local out = {} - local schema = api.mob.interface[next(api.mob.interface)] - local params = schema.type.request.functions.GetVehicleData.param - for k, v in pairs(params) do - if v.since ~= nil and m.vd[k] and v.deprecated ~= "true" then out[k] = v.since end - end - return out -end - -m.versioningVD = getVersioningParamsFromAPI() - ---[[ Common Functions ]] +local vdParams = getAvailableVDParams() --[[ @updatePreloadedPTFile: Update preloaded file with additional permissions --! @parameters: @@ -304,6 +260,9 @@ local function updatePreloadedPTFile(pGroup) } end end + for _, data in pairs(pGroup.rpcs) do + if #data.parameters == 0 then data.parameters = json.EMPTY_ARRAY end + end pt.policy_table.functional_groupings["VDGroup"] = pGroup pt.policy_table.app_policies["default"].groups = { "Base-4", "VDGroup" } pt.policy_table.functional_groupings["DataConsent-2"].rpcs = json.null @@ -339,64 +298,27 @@ function m.getHashId(pAppId) return hashId[pAppId] end ---[[ @getVDParams: Return VD parameters and values ---! @parameters: ---! pIsSubscribable: true if parameter is available for subscription, otherwise - false ---! @return: table with VD parameters and values ---]] -function m.getVDParams(pIsSubscribable) - if pIsSubscribable == nil then return m.vdValues end - local out = {} - for param in pairs(m.vd) do - if pIsSubscribable == (m.vd[param] ~= "") then out[param] = m.vdValues[param] end - end - return out -end - ---[[ @getMandatoryOnlyCases: Return cases for VD parameter where only mandatory sub-parameters are defined +--[[ @isSubscribable: Check whether VD parameter is subscribable +--! E.g. it's not possible to subscribe to 'vin' VD parameter --! @parameters: --! pParam: name of the VD parameter ---! @return: table with test cases where key is name of test case and value is VD parameter with value +--! @return: true if it's possible to subscribe to VD parameter, otherwise - false --]] -function m.getMandatoryOnlyCases(pParam) - local out = {} - local value = utils.cloneTable(m.vdValues[pParam]) - local mnd = m.mandatoryVD[pParam] -- get information about mandatory sub-parameters - local to_upd = value -- 'to_upd' variable allows to handle non-array and array cases by the same logic - if mnd.array then -- in both cases 'to_upd' is a table with sub-parameters - value = { value[1] } -- in case of non-array it equals to param value - to_upd = value[1] -- in case of array it equals to 1st item of param value - end - -- iterate through all sub-parameters and remove all optional - for k in pairs(to_upd) do - if not utils.isTableContains(mnd.sub, k) then - to_upd[k] = nil - end - end - out["mandatory"] = value - return out +function m.isSubscribable(pParam) + if m.vd[pParam] ~= "" then return true end + return false end ---[[ @getMandatoryMissingCases: Return cases for VD parameter where one mandatory sub-parameter is missing +--[[ @getVDParams: Return VD parameters and values --! @parameters: ---! pParam: name of the VD parameter ---! @return: table with test cases where key is name of test case and value is VD parameter with value +--! pIsSubscribable: true if parameter is available for subscription, otherwise - false +--! @return: table with VD parameters and values --]] -function m.getMandatoryMissingCases(pParam) +function m.getVDParams(pIsSubscribable) + if pIsSubscribable == nil then return vdParams end local out = {} - local mnd = m.mandatoryVD[pParam] -- get information about mandatory sub-parameters - -- iterate through all mandatory sub-parameters and remove one of them for each case - for _, k in pairs(mnd.sub) do - local value = utils.cloneTable(m.vdValues[pParam]) - local to_upd = value - if mnd.array then - value = { value[1] } - to_upd = value[1] - end - for j in pairs(to_upd) do - if j == k then to_upd[k] = nil end - end - out["missing_" .. k] = value + for param in pairs(m.vd) do + if pIsSubscribable == m.isSubscribable(param) then out[param] = true end end return out end @@ -449,23 +371,6 @@ function m.processRPCgenericError(pRPC, pParam, pValue) m.getMobileSession():ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) end ---[[ @getInvalidData: Return invalid value bases on valid one ---! @parameters: ---! pData: valid value ---! @return: invalid value ---]] -function m.getInvalidData(pData) - if type(pData) == "boolean" then return 123 end - if type(pData) == "number" then return true end - if type(pData) == "string" then return false end - if type(pData) == "table" then - for k, v in pairs(pData) do - pData[k] = m.getInvalidData(v) - end - return pData - end -end - --[[ @processSubscriptionRPC: Processing SubscribeVehicleData and UnsubscribeVehicleData RPCs --! @parameters: --! pRPC: RPC for mobile request @@ -495,10 +400,11 @@ function m.processSubscriptionRPC(pRPC, pParam, pAppId, isRequestOnHMIExpected) end m.getMobileSession(pAppId):ExpectResponse(cid, { success = true, resultCode = "SUCCESS", [responseParam] = response }) - m.getMobileSession(pAppId):ExpectNotification("OnHashChange") + local ret = m.getMobileSession(pAppId):ExpectNotification("OnHashChange") :Do(function(_, data) m.setHashId(data.payload.hashID, pAppId) end) + return ret end --[[ @sendOnVehicleData: Processing OnVehicleData RPC @@ -621,9 +527,9 @@ end --]] function m.setAppVersion(pParamVersion, pOperator) m.cprint(color.magenta, "Param version:", pParamVersion) - local major = tonumber(split(pParamVersion)[1]) or 0 - local minor = tonumber(split(pParamVersion)[2]) or 0 - local patch = tonumber(split(pParamVersion)[3]) or 0 + local major = tonumber(utils.splitString(pParamVersion, ".")[1]) or 0 + local minor = tonumber(utils.splitString(pParamVersion, ".")[2]) or 0 + local patch = tonumber(utils.splitString(pParamVersion, ".")[3]) or 0 local ver = (major*100 + minor*10 + patch) + pOperator if ver < 450 then ver = 450 end ver = tostring(ver) @@ -636,4 +542,778 @@ function m.setAppVersion(pParamVersion, pOperator) actions.app.getParams().syncMsgVersion.patchVersion = patch end +--[[ @getKeyByValue: Get key from table by defined value +--! @parameters: +--! pTbl: table for lookup +--! pValue: value for lookup +--! @return: key +--]] +function m.getKeyByValue(pTbl, pValue) + for k, v in pairs(pTbl) do + if v == pValue then return k end + end + return nil +end + +--[[ Params Generator Functions ]]------------------------------------------------------------------ + +--[[ @getParamsValidDataTestForRequest: Provide parameters for processing valid sequence for 'GetVehicleData' request +--! @parameters: +--! pGraph: graph with structure of parameters +--! @return: table with parameters +--]] +local function getParamsValidDataTestForRequest(pGraph) + local request = { [paramName] = true } + local hmiResponse = gen.getParamValues(pGraph) + local mobileResponse = utils.cloneTable(hmiResponse) + mobileResponse.success = true + mobileResponse.resultCode = "SUCCESS" + local params = { + mobile = { + name = rpc, + request = request, + response = mobileResponse + }, + hmi = { + name = m.rpcHMIMap[rpc], + request = request, + response = hmiResponse + } + } + return params +end + +--[[ @getParamsInvalidDataTestForRequest: Provide parameters for processing invalid sequence for 'GetVehicleData' request +--! @parameters: +--! pGraph: graph with structure of parameters +--! @return: table with parameters +--]] +local function getParamsInvalidDataTestForRequest(pGraph) + local request = { [paramName] = true } + local hmiResponse = gen.getParamValues(pGraph) + local params = { + mobile = { + name = rpc, + request = request, + response = { success = false, resultCode = "GENERIC_ERROR" } + }, + hmi = { + name = m.rpcHMIMap[rpc], + request = request, + response = hmiResponse + } + } + return params +end + +--[[ @getParamsAnyDataTestForNotification: Provide parameters for processing any sequence for 'OnVehicleData' notification +--! @parameters: +--! pGraph: graph with structure of parameters +--! @return: table with parameters +--]] +local function getParamsAnyDataTestForNotification(pGraph) + local notification = gen.getParamValues(pGraph) + local params = { + mobile = { + name = rpc, + notification = { [paramName] = notification[paramName] } + }, + hmi = { + name = m.rpcHMIMap[rpc], + notification = { [paramName] = notification[paramName] } + } + } + return params +end + +local getParamsFuncMap = { + VALID = { + [api.eventType.RESPONSE] = getParamsValidDataTestForRequest, + [api.eventType.NOTIFICATION] = getParamsAnyDataTestForNotification + }, + INVALID = { + [api.eventType.RESPONSE] = getParamsInvalidDataTestForRequest, + [api.eventType.NOTIFICATION] = getParamsAnyDataTestForNotification + } +} + +--[[ Test Cases Generator Function ]]--------------------------------------------------------------- + +--[[ @createTestCases: Generate test cases depends on API structure of VD parameter and various options +--! @parameters: +--! pAPIType: type of the API, e.g. 'mobile' or 'hmi' +--! pEventType: type of the event, e.g. 'request', 'response' or 'notification' +--! pFuncName: name of the API function, e.g. 'GetVehicleData' +--! pIsMandatory: defines how mandatory parameters is going to be handled (see 'm.isMandatory') +--! pIsArray: defines how array parameters is going to be handled (see 'm.isArray') +--! pIsVersion: defines how parameters with version defined is going to be handled (see 'm.isVersion') +--! pDataTypes: list of data types included into processing, e.g. 'api.dataType.INTEGER.type' +--! @return: table with test cases +--]] +local function createTestCases(pAPIType, pEventType, pFuncName, pIsMandatory, pIsArray, pIsVersion, pDataTypes) + + --[[ + Build a graph object which is a flattened list representation of all parameters defined in a particular API function. + It includes all hierarchy of parameters and sub-parameters. E.g.: + root-level 0 - bodyInformation + child-level 1 - roofStatuses + child-level 2 - location + child-level 3 - rowspan + It's a 'key:value' list, where + - 'key' is a unique integer ID for the parameter (or sub-parameter) + - 'value' is a table of properties for the parameter, such as: + - parentId - ID of the parent for this parameter (or nil for root-level parameters) + - name - name of the parameter + - , such as 'type', 'array', 'mandatory', 'since' etc. copied from API + --]] + local graph = api.getGraph(pAPIType, pEventType, pFuncName) + + --[[ @getParents: Get table with all parents for parameter defined by pId + --! @parameters: + --! pGraph: graph with all parameters + --! pId: parameter identifier + --! @return: table with parent parameters identifiers + --]] + local function getParents(pGraph, pId) + local out = {} + pId = pGraph[pId].parentId + while pId do + out[pId] = true + pId = pGraph[pId].parentId + end + return out + end + + --[[ @getMandatoryNeighbors: Get table with mandatory neighbors for parameters defined by pId and pParentIds + --! @parameters: + --! pGraph: graph with all parameters + --! pId: parameter identifier + --! pParentIds: table with parent parameters identifiers + --! @return: table with mandatory neighbors parameters identifiers + --]] + local function getMandatoryNeighbors(pGraph, pId, pParentIds) + local parentIds = utils.cloneTable(pParentIds) + parentIds[pId] = true + local out = {} + for p in pairs(parentIds) do + for k, v in pairs(pGraph) do + if v.parentId == pGraph[p].parentId and v.mandatory and p ~= k then + out[k] = true + end + end + end + return out + end + + --[[ @getMandatoryChildren: Get table with mandatory children for parameter defined by pId + --! @parameters: + --! pGraph: graph with all parameters + --! pId: parameter identifier + --! pChildrenIds: output table with mandatory children parameters identifiers + --! @return: table with mandatory children parameters identifiers + --]] + local function getMandatoryChildren(pGraph, pId, pChildrenIds) + for k, v in pairs(pGraph) do + if v.parentId == pId and v.mandatory then + pChildrenIds[k] = true + getMandatoryChildren(pGraph, k, pChildrenIds) + end + end + return pChildrenIds + end + + --[[ @getTCParamsIds: Merge all parameters identifiers required for the test case into one table + --! @parameters: + --! pId: parameter identifier + --! ...: all tables with parameters identifiers + --! @return: table with merged parameters identifiers + --]] + local function getTCParamsIds(pId, ...) + local ids = {} + ids[pId] = true + for _, arg in pairs({...}) do + if type(arg) == "table" then + for p in pairs(arg) do + ids[p] = true + end + end + end + return ids + end + + --[[ @getUpdatedParams: Filter graph by defined parameters + --! @parameters: + --! pGraph: initial graph with all parameters + --! pParamIds: table with parameters identifiers + --! @return: filtered graph + --]] + local function getUpdatedParams(pGraph, pParamIds) + for k in pairs(pGraph) do + if not pParamIds[k] then + pGraph[k] = nil + end + end + return pGraph + end + + --[[ @getTestCases: Get test cases from graph + --! @parameters: + --! pGraph: graph with all parameters + --! @return: table with test cases + --]] + local function getTestCases(pGraph) + --[[ @getMandatoryCondition: Check mandatory condition for the parameter + --! @parameters: + --! pMandatory - 'mandatory' attribute of the parameter defined in API + --! @return: true if mandatory condition is met + --]] + local function getMandatoryCondition(pMandatory) + if pIsMandatory == m.isMandatory.ALL then return true + else return pIsMandatory == pMandatory + end + end + --[[ @getArrayCondition: Check array condition for the parameter + --! @parameters: + --! pArray - 'array' attribute of the parameter defined in API + --! @return: true if array condition is met + --]] + local function getArrayCondition(pArray) + if pIsArray == m.isArray.ALL then return true + else return pIsArray == pArray + end + end + --[[ @getVersionCondition: Check version condition for the parameter + --! @parameters: + --! pSince - 'since' attribute of the parameter defined in API + --! pDeprecated - 'deprecated' attribute of the parameter defined in API + --! @return: true if version condition is met + --]] + local function getVersionCondition(pSince, pDeprecated) + if pIsVersion == m.isVersion.ALL then return true end + if pSince ~= nil and pDeprecated ~= true then return true end + return false + end + --[[ @getTypeCondition: Check type condition for the parameter + --! @parameters: + --! pType - type of the parameter, see 'APIHelper.dataType' table + --! @return: true if type condition is met + --]] + local function getTypeCondition(pType) + if pDataTypes == nil or #pDataTypes == 0 then return true + elseif utils.isTableContains(pDataTypes, pType) then return true + else return false + end + end + --[[ @getParamNameCondition: Check name condition for the parameter + --! @parameters: + --! pName - name of the parameter + --! @return: true if name condition is met + --]] + local function getParamNameCondition(pName) + if paramName == nil or paramName == "" then return true end + if (pName == paramName) or (string.find(pName .. ".", paramName .. "%.") == 1) then return true end + return false + end + --[[ + Iterate through all the parameters and sub-parameters defined in graph object. + Check whether various conditions are met and include a test case in table with test cases if so. + Test case is a table with elements: + - 'paramId' - Id of the parameter to be tested + - 'graph' - reduced graph object with all parameter Ids required for the test case + Later this object is used for creating a hierarchy of parameters with their values. + --]] + local tcs = {} + for k, v in pairs(pGraph) do + local paramFullName = api.getFullParamName(graph, k) + if getMandatoryCondition(v.mandatory) and getArrayCondition(v.array) + and getTypeCondition(v.type) and getParamNameCondition(paramFullName) + and getVersionCondition(v.since, v.deprecated) then + local parentIds = getParents(graph, k) + local childrenIds = getMandatoryChildren(graph, k, {}) + local neighborsIds = getMandatoryNeighbors(graph, k, parentIds) + local neighborsChildrenIds = {} + for id in pairs(neighborsIds) do + getMandatoryChildren(graph, id, neighborsChildrenIds) + end + local tcParamIds = getTCParamsIds(k, parentIds, neighborsIds, childrenIds, neighborsChildrenIds) + local tc = { + paramId = k, + graph = getUpdatedParams(utils.cloneTable(graph), tcParamIds) + } + table.insert(tcs, tc) + end + end + return tcs + end + + local tcs = getTestCases(graph) + + return tcs +end + +--[[ Tests Generator Functions ]]------------------------------------------------------------------- + +--[[ @getValidRandomTests: Generate tests for VALID_RANDOM_SUB test type +--! @parameters: none +--! @return: table with tests +--]] +local function getValidRandomTests() + local tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, {}) + local tests = {} + for _, tc in pairs(tcs) do + local paramData = tc.graph[tc.paramId] + if paramData.type ~= api.dataType.STRUCT.type and paramData.parentId ~= nil then + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.VALID[rpcType](tc.graph), + }) + end + end + return tests +end + +--[[ @getOnlyMandatoryTests: Generate tests for MANDATORY_ONLY test type +--! @parameters: none +--! @return: table with tests +--]] +local function getOnlyMandatoryTests() + local function isTCExist(pExistingTCs, pTC) + local tc = utils.cloneTable(pTC) + tc.paramId = nil + for _, e in pairs(pExistingTCs) do + local etc = utils.cloneTable(e) + etc.paramId = nil + if utils.isTableEqual(etc, tc) then return true end + end + return false + end + local function filterDuplicates(pTCs) + local existingTCs = {} + for _, tc in pairs(pTCs) do + if not isTCExist(existingTCs, tc) then + tc.paramId = tc.graph[tc.paramId].parentId + table.insert(existingTCs, tc) + end + end + return existingTCs + end + local tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.YES, m.isArray.ALL, m.isVersion.ALL, {}) + tcs = filterDuplicates(tcs) + local tests = {} + for _, tc in pairs(tcs) do + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.VALID[rpcType](tc.graph), + paramId = tc.paramId, + graph = tc.graph + }) + end + return tests +end + +--[[ @getInBoundTests: Generate tests for LOWER_IN_BOUND/UPPER_IN_BOUND test types +--! @parameters: none +--! @return: table with tests +--]] +local function getInBoundTests() + local tests = {} + -- tests simple data types + local dataTypes = { api.dataType.INTEGER.type, api.dataType.FLOAT.type, api.dataType.DOUBLE.type, api.dataType.STRING.type } + local tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, dataTypes) + for _, tc in pairs(tcs) do + tc.graph[tc.paramId].valueType = boundValueTypeMap[testType] + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.VALID[rpcType](tc.graph), + }) + end + -- tests for arrays + tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.YES, m.isVersion.ALL, {}) + for _, tc in pairs(tcs) do + tc.graph[tc.paramId].valueTypeArray = boundValueTypeMap[testType] + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId) .. "_ARRAY", + params = getParamsFuncMap.VALID[rpcType](tc.graph), + }) + end + return tests +end + +--[[ @getOutOfBoundTests: Generate tests for LOWER_OUT_OF_BOUND/UPPER_OUT_OF_BOUND test types +--! @parameters: none +--! @return: table with tests +--]] +local function getOutOfBoundTests() + local tests = {} + -- tests for simple data types + local dataTypes = { api.dataType.INTEGER.type, api.dataType.FLOAT.type, api.dataType.DOUBLE.type, api.dataType.STRING.type } + local tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, dataTypes) + for _, tc in pairs(tcs) do + local function isSkipped() + local paramData = tc.graph[tc.paramId] + if paramData.type == api.dataType.STRING.type then + if (testType == m.testType.LOWER_OUT_OF_BOUND and paramData.minlength == 0) + or (testType == m.testType.UPPER_OUT_OF_BOUND and paramData.maxlength == nil) then + return true + end + else + if (testType == m.testType.LOWER_OUT_OF_BOUND and paramData.minvalue == nil) + or (testType == m.testType.UPPER_OUT_OF_BOUND and paramData.maxvalue == nil) then + return true + end + end + return false + end + if not isSkipped() then + tc.graph[tc.paramId].valueType = boundValueTypeMap[testType] + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.INVALID[rpcType](tc.graph), + }) + end + end + -- tests for arrays + tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.YES, m.isVersion.ALL, {}) + for _, tc in pairs(tcs) do + local function isSkipped() + local paramData = tc.graph[tc.paramId] + if (testType == m.testType.LOWER_OUT_OF_BOUND and (paramData.minsize == 0 or paramData.minsize == nil)) + or (testType == m.testType.UPPER_OUT_OF_BOUND and paramData.maxsize == nil) then + return true + end + return false + end + if not isSkipped() then + tc.graph[tc.paramId].valueTypeArray = boundValueTypeMap[testType] + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId) .. "_ARRAY", + params = getParamsFuncMap.INVALID[rpcType](tc.graph), + }) + end + end + -- tests for enums + tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, { api.dataType.ENUM.type }) + for _, tc in pairs(tcs) do + local function isSkipped() + local paramData = tc.graph[tc.paramId] + if paramData.type == api.dataType.ENUM.type and testType == m.testType.LOWER_OUT_OF_BOUND then + return true + end + return false + end + --[[ @getMandatoryValues: Get hierarchy levels of parameters starting from current and to the root + -- with mandatory value for each + --! @parameters: + --! pId: parameter identifier (in graph) + --! pLevel: level of hierarchy + --! pOut: table with result + --! @return: table with levels and mandatory values + --]] + local function getMandatoryValues(pId, pLevel, pOut) + pOut[pLevel] = tc.graph[pId].mandatory + local parentId = tc.graph[pId].parentId + if parentId then return getMandatoryValues(parentId, pLevel+1, pOut) end + return pOut + end + local mandatoryValues = getMandatoryValues(tc.paramId, 1, {}) + if not isSkipped() and (#mandatoryValues == 1 or mandatoryValues[#mandatoryValues-1]) then + local invalidValue = "INVALID_VALUE" + tc.graph[tc.paramId].data = { invalidValue } + local params = getParamsFuncMap.INVALID[rpcType](tc.graph) + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId) .. "_" .. invalidValue, + params = params + }) + end + end + return tests +end + +--[[ @getEnumItemsTests: Generate tests for ENUM_ITEMS test type +--! @parameters: none +--! @return: table with tests +--]] +local function getEnumItemsTests() + local tests = {} + local dataTypes = { api.dataType.ENUM.type } + local tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, dataTypes) + for _, tc in pairs(tcs) do + for _, item in pairs(tc.graph[tc.paramId].data) do + local tcUpd = utils.cloneTable(tc) + tcUpd.graph[tc.paramId].data = { item } + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId) .. "_" .. item, + params = getParamsFuncMap.VALID[rpcType](tcUpd.graph) + }) + end + end + return tests +end + +--[[ @getBoolItemsTests: Generate tests for BOOL_ITEMS test type +--! @parameters: none +--! @return: table with tests +--]] +local function getBoolItemsTests() + local tests = {} + local dataTypes = { api.dataType.BOOLEAN.type } + local tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, dataTypes) + for _, tc in pairs(tcs) do + for _, item in pairs({ true, false }) do + local tcUpd = utils.cloneTable(tc) + tcUpd.graph[tc.paramId].data = { item } + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId) .. "_" .. tostring(item), + params = getParamsFuncMap.VALID[rpcType](tcUpd.graph) + }) + end + end + return tests +end + +--[[ @getVersionTests: Generate tests for PARAM_VERSION test type +--! @parameters: none +--! @return: table with tests +--]] +local function getVersionTests() + local tests = {} + local tcs = createTestCases(api.apiType.MOBILE, api.eventType.REQUEST, rpc, + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.YES, {}) + for _, tc in pairs(tcs) do + local name = tc.graph[tc.paramId].name + if vdParams[name] then + table.insert(tests, { + param = tc.graph[tc.paramId].name, + version = tc.graph[tc.paramId].since + }) + end + end + return tests +end + +--[[ @getValidRandomAllTests: Generate tests for VALID_RANDOM_ALL test type +--! @parameters: none +--! @return: table with tests +--]] +local function getValidRandomAllTests() + local tests = {} + local graph = api.getGraph(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc]) + local function getParamId(pGraph, pName) + for k, v in pairs(pGraph) do + if v.parentId == nil and v.name == pName then return k end + end + return nil + end + local paramId = getParamId(graph, paramName) + + graph = api.getBranch(graph, paramId) + local tc = { graph = graph, paramId = paramId } + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.VALID[rpcType](tc.graph), + paramId = tc.paramId, + graph = tc.graph + }) + return tests +end + +--[[ @getMandatoryMissingTests: Generate tests for MANDATORY_MISSING test type +--! @parameters: none +--! @return: table with tests +--]] +local function getMandatoryMissingTests() + local tests = {} + local mndTests = getOnlyMandatoryTests() + local randomAllTests = getValidRandomAllTests() + if #mndTests == 0 or #randomAllTests == 0 then return tests end + for testId in pairs(mndTests) do + for paramId in pairs(mndTests[testId].graph) do + local graph = utils.cloneTable(randomAllTests[1].graph) + if graph[paramId].parentId ~= nil and graph[paramId].mandatory == true then + local name = api.getFullParamName(graph, paramId) + local branchToDelete = api.getBranch(graph, paramId, {}) + for id in pairs(graph) do + if branchToDelete[id] then graph[id] = nil end + end + table.insert(tests, { + name = "Param_missing_" .. name, + params = getParamsFuncMap.INVALID[rpcType](graph), + }) + end + end + end + return tests +end + +--[[ @getInvalidTypeTests: Generate tests for INVALID_TYPE test type +--! @parameters: none +--! @return: table with tests +--]] +local function getInvalidTypeTests() + local dataTypes = { api.dataType.INTEGER.type, api.dataType.FLOAT.type, api.dataType.DOUBLE.type, + api.dataType.STRING.type, api.dataType.ENUM.type, api.dataType.BOOLEAN.type } + local tcs = createTestCases(api.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, dataTypes) + local tests = {} + for _, tc in pairs(tcs) do + tc.graph[tc.paramId].valueType = gen.valueType.INVALID_TYPE + table.insert(tests, { + name = "Param_" .. api.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.INVALID[rpcType](tc.graph), + }) + end + return tests +end + +--[[ Test Getter Functions ]]----------------------------------------------------------------------- + +--[[ @getTests: Provide tests for defined test type and VD parameter +--! @parameters: +--! pRPC: name of RPC, e.g. 'GetVehicleData' +--! pTestType: test type, e.g. 'm.testType.VALID_RANDOM_ALL' +--! pParamName: name of the VD parameter +--! @return: table with tests +--]] +function m.getTests(pRPC, pTestType, pParamName) + local rpcTypeMap = { + [m.rpc.get] = api.eventType.RESPONSE, + [m.rpc.on] = api.eventType.NOTIFICATION + } + rpc = pRPC + rpcType = rpcTypeMap[pRPC] + testType = pTestType + paramName = pParamName + + local testTypeMap = { + [m.testType.VALID_RANDOM_ALL] = getValidRandomAllTests, + [m.testType.VALID_RANDOM_SUB] = getValidRandomTests, + [m.testType.LOWER_IN_BOUND] = getInBoundTests, + [m.testType.UPPER_IN_BOUND] = getInBoundTests, + [m.testType.LOWER_OUT_OF_BOUND] = getOutOfBoundTests, + [m.testType.UPPER_OUT_OF_BOUND] = getOutOfBoundTests, + [m.testType.INVALID_TYPE] = getInvalidTypeTests, + [m.testType.ENUM_ITEMS] = getEnumItemsTests, + [m.testType.BOOL_ITEMS] = getBoolItemsTests, + [m.testType.PARAM_VERSION] = getVersionTests, + [m.testType.MANDATORY_ONLY] = getOnlyMandatoryTests, + [m.testType.MANDATORY_MISSING] = getMandatoryMissingTests, + + } + if testTypeMap[testType] then return testTypeMap[testType]() end + return {} +end + +--[[ @processRequest: Processing sequence for 'GetVehicleData' request +--! @parameters: +--! pParams: all parameters for the sequence +--! @return: none +--]] +function m.processRequest(pParams) + local cid = m.getMobileSession():SendRPC(pParams.mobile.name, pParams.mobile.request) + m.getHMIConnection():ExpectRequest(pParams.hmi.name, pParams.hmi.request) + :Do(function(_, data) + m.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", pParams.hmi.response) + end) + m.getMobileSession():ExpectResponse(cid, pParams.mobile.response) +end + +--[[ @processNotification: Processing sequence for 'OnVehicleData' notification +--! @parameters: +--! pParams: all parameters for the sequence +--! pTestType: test type, e.g. 'm.testType.VALID_RANDOM_ALL' +--! pParamName: name of the VD parameter +--! @return: none +--]] +function m.processNotification(pParams, pTestType, pParamName) + local function SendNotification() + local times = m.isExpected + if pTestType == m.testType.LOWER_OUT_OF_BOUND or pTestType == m.testType.UPPER_OUT_OF_BOUND + or pTestType == m.testType.MANDATORY_MISSING or pTestType == m.testType.INVALID_TYPE + or not m.isSubscribable(pParamName) then + times = m.isNotExpected + end + m.getHMIConnection():SendNotification(pParams.hmi.name, pParams.hmi.notification) + m.getMobileSession():ExpectNotification(pParams.mobile.name, pParams.mobile.notification) + :Times(times) + end + if not isSubscribed[pParamName] and m.isSubscribable(pParamName) then + m.processSubscriptionRPC(m.rpc.sub, pParamName) + :Do(function() + SendNotification() + end) + isSubscribed[pParamName] = true + else + SendNotification() + end +end + +--[[ @getTestsForGetVD: Generate test steps for 'GetVehicleData' tests for defined test types +--! @parameters: +--! pTestTypes: test types +--! @return: test steps +--]] +function m.runner.getTestsForGetVD(pTestTypes) + for param in m.spairs(m.getVDParams()) do + m.runner.Title("VD parameter: " .. param) + for _, tt in pairs(pTestTypes) do + local tests = m.getTests(m.rpc.get, tt, param) + if #tests > 0 then + m.runner.Title("Test type: " .. m.getKeyByValue(m.testType, tt)) + for _, t in pairs(tests) do + m.runner.Step(t.name, m.processRequest, { t.params }) + end + end + end + end +end + +--[[ @getTestsForOnVD: Generate test steps for 'OnVehicleData' tests for defined test types +--! @parameters: +--! pTestTypes: test types +--! @return: test steps +--]] +function m.runner.getTestsForOnVD(pTestTypes) + for param in m.spairs(m.getVDParams()) do + m.runner.Title("VD parameter: " .. param) + for _, tt in pairs(pTestTypes) do + local tests = m.getTests(m.rpc.on, tt, param) + if #tests > 0 then + m.runner.Title("Test type: " .. m.getKeyByValue(m.testType, tt)) + for _, t in pairs(tests) do + m.runner.Step(t.name, m.processNotification, { t.params, tt, param }) + end + end + end + end +end + +--[[ @getDefaultValues: Generate default random valid values for all VD parameters +--! @parameters: none +--! @return: values for parameters +--]] +local function getDefaultValues() + local out = {} + local fullGraph = api.getGraph(api.apiType.HMI, api.eventType.RESPONSE, m.rpcHMIMap[m.rpc.get]) + for k, v in pairs(fullGraph) do + if v.parentId == nil then + local name = v.name + local graph = api.getBranch(fullGraph, k) + local params = gen.getParamValues(graph) + out[name] = params[name] + end + end + return out +end + +m.vdValues = getDefaultValues() + return m diff --git a/test_sets/API/vehicle_data.txt b/test_sets/API/vehicle_data.txt index 956ad9a007..447999cb1e 100644 --- a/test_sets/API/vehicle_data.txt +++ b/test_sets/API/vehicle_data.txt @@ -1,5 +1,3 @@ -./test_scripts/API/VehicleData/AudioSource/001_Success_deviceStatus_primaryAudioSource.lua -./test_scripts/API/VehicleData/AudioSource/002_Success_flow_deviceStatus_primaryAudioSource.lua ./test_scripts/API/VehicleData/GetVehicleData/001_GetVD_Success_flow.lua ./test_scripts/API/VehicleData/GetVehicleData/002_GetVD_disallowed.lua ./test_scripts/API/VehicleData/GetVehicleData/003_GetVD_disallowed_after_PTU.lua @@ -8,12 +6,16 @@ ./test_scripts/API/VehicleData/GetVehicleData/006_GetVD_mandatory_parameters.lua ./test_scripts/API/VehicleData/GetVehicleData/007_GetVD_app_version_is_greater_than_parameter_version.lua ./test_scripts/API/VehicleData/GetVehicleData/008_GetVD_app_version_is_less_than_parameter_version.lua +./test_scripts/API/VehicleData/GetVehicleData/009_GetVD_min_max_boundary_values.lua +./test_scripts/API/VehicleData/GetVehicleData/010_GetVD_enum_and_bool_values.lua ./test_scripts/API/VehicleData/OnVehicleData/001_OnVD_Success.lua ./test_scripts/API/VehicleData/OnVehicleData/002_OnVD_disallowed.lua ./test_scripts/API/VehicleData/OnVehicleData/003_OnVD_disallowed_after_PTU.lua ./test_scripts/API/VehicleData/OnVehicleData/004_OnVD_with_invalid_data.lua ./test_scripts/API/VehicleData/OnVehicleData/005_OnVD_App_is_not_subscribed.lua ./test_scripts/API/VehicleData/OnVehicleData/006_OnVD_mandatory_parameters.lua +./test_scripts/API/VehicleData/OnVehicleData/007_OnVD_min_max_boundary_values.lua +./test_scripts/API/VehicleData/OnVehicleData/008_OnVD_enum_and_bool_values.lua ./test_scripts/API/VehicleData/SubscribeVehicleData/001_SubscribeVD_Success.lua ./test_scripts/API/VehicleData/SubscribeVehicleData/002_SubscribeVD_disallowed.lua ./test_scripts/API/VehicleData/SubscribeVehicleData/003_SubscribeVD_disallowed_after_PTU.lua @@ -34,11 +36,3 @@ ./test_scripts/API/VehicleData/UnsubscribeVehicleData/006_UnsubscribeVD_2nd_request_IGNORED.lua ./test_scripts/API/VehicleData/UnsubscribeVehicleData/007_UnsubscribeVD_for_2_apps.lua ./test_scripts/API/VehicleData/UnsubscribeVehicleData/008_UnsubscribeVD_HMI_responds_with_not_success_codes.lua -./test_scripts/API/VehicleData/RefactorFuelInformation/001_GetVehicleData_with_one_param_in_fuelRange_structure.lua -./test_scripts/API/VehicleData/RefactorFuelInformation/002_OnVehicleData_with_only_one_param_in_fuelRange_structure.lua -./test_scripts/API/VehicleData/StabilityControlsStatus/001_GetVehicleData_with_one_param_in_stabilityControlsStatus_structure.lua -./test_scripts/API/VehicleData/StabilityControlsStatus/002_OnVehicleData_with_only_one_param_in_stabilityControlsStatus_structure.lua -./test_scripts/API/VehicleData/GearStatus/001_GetVehicleData_with_one_param_in_gearStatus_structure.lua -./test_scripts/API/VehicleData/GearStatus/002_OnVehicleData_with_only_one_param_in_gearStatus_structure.lua -./test_scripts/API/VehicleData/WindowStatus/001_GetVehicleData_boundary_values_windowStatus_structure.lua -./test_scripts/API/VehicleData/WindowStatus/002_OnVehicleData_boundary_values_windowStatus_structure.lua diff --git a/user_modules/api/APIHelper.lua b/user_modules/api/APIHelper.lua new file mode 100644 index 0000000000..f7bbb36fcd --- /dev/null +++ b/user_modules/api/APIHelper.lua @@ -0,0 +1,195 @@ +---------------------------------------------------------------------------------------------------- +-- API Helper module +---------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]]------------------------------------------------------------------- +local utils = require("user_modules/utils") +local apiLoader = require("modules/api_loader") + +--[[ Module ]]-------------------------------------------------------------------------------------- +local m = {} + +--[[ Constants ]]----------------------------------------------------------------------------------- +m.apiType = { + MOBILE = "mobile", + HMI = "hmi" +} + +m.eventType = { + REQUEST = "request", + RESPONSE = "response", + NOTIFICATION = "notification" +} + +m.dataType = { + INTEGER = { type = "Integer", min = -2147483647, max = 2147483647 }, + FLOAT = { type = "Float", min = -1000000, max = 1000000 }, + DOUBLE = { type = "Double", min = -1000000000, max = 1000000000 }, + STRING = { type = "String", min = 1, max = 100 }, + BOOLEAN = { type = "Boolean" }, + ENUM = { type = "Enum" }, + STRUCT = { type = "Struct" } +} + +--[[ Variables ]]----------------------------------------------------------------------------------- +local api = { + mobile = apiLoader.init("data/MOBILE_API.xml"), + hmi = apiLoader.init("data/HMI_API.xml") +} + +local schema = { + mobile = api.mobile.interface[next(api.mobile.interface)], + hmi = api.hmi.interface["Common"] +} + +--[[ Functions ]]----------------------------------------------------------------------------------- + +--[[ @getType: Provide type of the parameter without interface +--! @parameters: +--! pType: type of the parameter (possibly with interface) +--! @return: type of the parameter +--]] +local function getType(pType) + if string.find(pType, "%.") then + return utils.splitString(pType, ".")[2] + end + return pType +end + +--[[ @getParamsData: Provide hierarchy of parameters and sub-parameters for the defined API function +--! @parameters: +--! pAPIType: type of the API, e.g. 'mobile' or 'hmi' +--! pEventType: type of the event, e.g. 'request', 'response' or 'notification' +--! pFuncName: name of the API function, e.g. 'GetVehicleData' +--! @return: structure with hierarchy of parameters +--]] +local function getParamsData(pAPIType, pEventType, pFuncName) + + local function buildParams(pTbl, pParams) + for k, v in pairs(pParams) do + pTbl[k] = utils.cloneTable(v) + if schema[pAPIType].struct[getType(v.type)] then + pTbl[k].data = {} + buildParams(pTbl[k].data, schema[pAPIType].struct[getType(v.type)].param) + pTbl[k].type = m.dataType.STRUCT.type + elseif schema[pAPIType].enum[getType(v.type)] then + pTbl[k].data = {} + for kk in utils.spairs(schema[pAPIType].enum[getType(v.type)]) do + table.insert(pTbl[k].data, kk) + end + pTbl[k].type = m.dataType.ENUM.type + end + end + end + + local function getAPIParams() + if pAPIType == m.apiType.MOBILE then + return schema.mobile.type[pEventType].functions[pFuncName].param + elseif pAPIType == m.apiType.HMI then + local iName = utils.splitString(pFuncName, ".")[1] + local fName = utils.splitString(pFuncName, ".")[2] + return api.hmi.interface[iName].type[pEventType].functions[fName].param + end + end + + local params = getAPIParams(pAPIType) + + local out = {} + buildParams(out, params) + + local function updateBooleanValue(pValue) + local o = pValue + if type(pValue) == "string" then + if pValue == "true" then o = true + elseif pValue == "false" then o = false + end + end + return o + end + + local function updateValues(pTbl) + for k, v in pairs(pTbl) do + if type(v) == "table" then + updateValues(v) + else + pTbl[k] = updateBooleanValue(v) + end + end + end + updateValues(out) + + return out +end + +--[[ @getGraph: Provide graph of all parameters for defined API function +--! @parameters: +--! pAPIType: type of the API, e.g. 'mobile' or 'hmi' +--! pEventType: type of the event, e.g. 'request', 'response' or 'notification' +--! pFuncName: name of the API function, e.g. 'GetVehicleData' +--! @return: graph of all parameters (incl. sub-parameters) for the API function +--]] +function m.getGraph(pAPIType, pEventType, pFuncName) + + local function getGraph(pParams, pGraph, pParentId) + for k, v in utils.spairs(pParams) do + local item = utils.cloneTable(v) + item.parentId = pParentId + item.name = k + if v.type ~= m.dataType.ENUM.type then + item.data = nil + end + table.insert(pGraph, item) + v.id = #pGraph + if v.type == m.dataType.STRUCT.type then + getGraph(v.data, pGraph, #pGraph) + end + end + return pGraph + end + + local apiParamsData = getParamsData(pAPIType, pEventType, pFuncName) + return getGraph(apiParamsData, {}) +end + +--[[ @getFullParamName: Provide full parameter name created based on hierarchy. +--! E.g. for the `pressure` sub-parameter it returns `tirePressure.innerLeftRear.pressure` +--! @parameters: +--! pGraph: graph which includes defined parameter +--! pId: id of the parameter in graph +--! @return: full name of the parameter +--]] +function m.getFullParamName(pGraph, pId) + local out = pGraph[pId].name + pId = pGraph[pId].parentId + while pId do + out = pGraph[pId].name .. "." .. out + pId = pGraph[pId].parentId + end + return out +end + +--[[ @getBranch: Provide branch (part of the initial graph) related to defined parameter +--! @parameters: +--! pGraph: graph which includes defined parameter +--! pId: id of the parameter in graph +--! @return: reduced graph with defined parameter and all it's sub-parameters +--]] +function m.getBranch(pGraph, pId) + local function getChildren(pGraph, pId, pTbl) + pTbl[pId] = true + for k, v in pairs(pGraph) do + if v.parentId == pId then + pTbl[k] = true + getChildren(pGraph, k, pTbl) + end + end + return pTbl + end + local children = getChildren(pGraph, pId, {}) + local branch = utils.cloneTable(pGraph) + for k in pairs(branch) do + if not children[k] then branch[k] = nil end + end + return branch +end + +return m diff --git a/user_modules/api/APITestDataGenerator.lua b/user_modules/api/APITestDataGenerator.lua new file mode 100644 index 0000000000..df30a5ea5d --- /dev/null +++ b/user_modules/api/APITestDataGenerator.lua @@ -0,0 +1,309 @@ +---------------------------------------------------------------------------------------------------- +-- API Test Data Generator module +---------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]]------------------------------------------------------------------- +local api = require("user_modules/api/APIHelper") +local json = require("modules/json") + +--[[ Module ]]-------------------------------------------------------------------------------------- +local m = {} + +--[[ Constants ]]----------------------------------------------------------------------------------- +m.valueType = { + VALID_RANDOM = 1, + LOWER_IN_BOUND = 2, + UPPER_IN_BOUND = 3, + LOWER_OUT_OF_BOUND = 4, + UPPER_OUT_OF_BOUND = 5, + INVALID_TYPE = 6 +} + +--[[ Value generators ]]---------------------------------------------------------------------------- +math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6))) + +--[[ @getStringValue: Return value for 'string' data type +--! @parameters: +--! pTypeData: table with data type restrictions +--! @return: value for the parameter +--]] +local function getStringValue(pTypeData) + local length + if pTypeData.valueType == m.valueType.LOWER_IN_BOUND then + length = pTypeData.minlength + if not length then length = api.dataType.STRING.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + length = pTypeData.maxlength + if not length or length == 0 then length = api.dataType.STRING.max end + elseif pTypeData.valueType == m.valueType.LOWER_OUT_OF_BOUND then + length = pTypeData.minlength + if not length or length == 0 then length = api.dataType.STRING.min end + length = length - 1 + elseif pTypeData.valueType == m.valueType.UPPER_OUT_OF_BOUND then + length = pTypeData.maxlength + if not length or length == 0 then length = api.dataType.STRING.max end + length = length + 1 + elseif pTypeData.valueType == m.valueType.VALID_RANDOM then + local min = pTypeData.minlength + local max = pTypeData.maxlength + if not min or min == 0 then min = api.dataType.STRING.min end + if not max or max == 0 then max = api.dataType.STRING.max end + length = math.random(min, max) + elseif pTypeData.valueType == m.valueType.INVALID_TYPE then + return false + end + return string.rep("a", length) +end + +--[[ @getIntegerValue: Return value for 'integer' data type +--! @parameters: +--! pTypeData: table with data type restrictions +--! @return: value for the parameter +--]] +local function getIntegerValue(pTypeData) + local value + if pTypeData.valueType == m.valueType.LOWER_IN_BOUND then + value = pTypeData.minvalue + if not value then value = api.dataType.INTEGER.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + value = pTypeData.maxvalue + if not value then value = api.dataType.INTEGER.max end + elseif pTypeData.valueType == m.valueType.LOWER_OUT_OF_BOUND then + value = pTypeData.minvalue + if not value then value = api.dataType.INTEGER.min end + value = value - 1 + elseif pTypeData.valueType == m.valueType.UPPER_OUT_OF_BOUND then + value = pTypeData.maxvalue + if not value then value = api.dataType.INTEGER.max end + value = value + 1 + elseif pTypeData.valueType == m.valueType.VALID_RANDOM then + local min = pTypeData.minvalue + local max = pTypeData.maxvalue + if not min then min = api.dataType.INTEGER.min end + if not max then max = api.dataType.INTEGER.max end + value = math.random(min, max) + elseif pTypeData.valueType == m.valueType.INVALID_TYPE then + return true + end + return value +end + +--[[ @getFloatValue: Return value for 'float' data type +--! @parameters: +--! pTypeData: table with data type restrictions +--! @return: value for the parameter +--]] +local function getFloatValue(pTypeData) + local value + if pTypeData.valueType == m.valueType.LOWER_IN_BOUND then + value = pTypeData.minvalue + if not value then value = api.dataType.FLOAT.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + value = pTypeData.maxvalue + if not value then value = api.dataType.FLOAT.max end + elseif pTypeData.valueType == m.valueType.LOWER_OUT_OF_BOUND then + value = pTypeData.minvalue + if not value then value = api.dataType.FLOAT.min end + value = value - 0.1 + elseif pTypeData.valueType == m.valueType.UPPER_OUT_OF_BOUND then + value = pTypeData.maxvalue + if not value then value = api.dataType.FLOAT.max end + value = value + 0.1 + elseif pTypeData.valueType == m.valueType.VALID_RANDOM then + local min = pTypeData.minvalue + local max = pTypeData.maxvalue + if not min then min = api.dataType.FLOAT.min end + if not max then max = api.dataType.FLOAT.max end + value = tonumber(string.format('%.02f', math.random() + math.random(min, max-1))) + elseif pTypeData.valueType == m.valueType.INVALID_TYPE then + return true + end + return value +end + +--[[ @getDoubleValue: Return value for 'double' data type +--! @parameters: +--! pTypeData: table with data type restrictions +--! @return: value for the parameter +--]] +local function getDoubleValue(pTypeData) + local value + if pTypeData.valueType == m.valueType.LOWER_IN_BOUND then + value = pTypeData.minvalue + if not value then value = api.dataType.DOUBLE.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + value = pTypeData.maxvalue + if not value then value = api.dataType.DOUBLE.max end + elseif pTypeData.valueType == m.valueType.LOWER_OUT_OF_BOUND then + value = pTypeData.minvalue + if not value then value = api.dataType.DOUBLE.min end + value = value - 0.1 + elseif pTypeData.valueType == m.valueType.UPPER_OUT_OF_BOUND then + value = pTypeData.maxvalue + if not value then value = api.dataType.DOUBLE.max end + value = value + 0.1 + elseif pTypeData.valueType == m.valueType.VALID_RANDOM then + local min = pTypeData.minvalue + local max = pTypeData.maxvalue + if not min then min = api.dataType.DOUBLE.min end + if not max then max = api.dataType.DOUBLE.max end + value = tonumber(string.format('%.02f', math.random() + math.random(min, max-1))) + elseif pTypeData.valueType == m.valueType.INVALID_TYPE then + return true + end + return value +end + +--[[ @getBooleanValue: Return value for 'boolean' data type +--! @parameters: +--! pTypeData: table with data type restrictions +--! @return: value for the parameter +--]] +local function getBooleanValue(pTypeData) + if pTypeData.data and #pTypeData.data == 1 then + return pTypeData.data[1] + end + if pTypeData.valueType == m.valueType.VALID_RANDOM then + return math.random(0, 1) == 1 + elseif pTypeData.valueType == m.valueType.INVALID_TYPE then + return 123 + end + return true +end + +--[[ @getEnumTypeValue: Return value for 'enum' data type +--! @parameters: +--! pTypeData: table with data type restrictions +--! @return: value for the parameter +--]] +local function getEnumTypeValue(pTypeData) + if pTypeData.valueType == m.valueType.UPPER_OUT_OF_BOUND then + return #pTypeData.data + 1 + elseif pTypeData.valueType == m.valueType.VALID_RANDOM then + return pTypeData.data[math.random(1, #pTypeData.data)] + elseif pTypeData.valueType == m.valueType.INVALID_TYPE then + return false + end + return pTypeData.data[1] +end + +--[[ @getStructTypeValue: Return value for 'struct' data type +--! @parameters: +--! pGraph: graph with structure of parameters +--! pId: id of the parameter in graph +--! @return: value for the parameter +--]] +local function getStructTypeValue(_, pGraph, pId) + local childrenIds = {} + for k, v in pairs(pGraph) do + if v.parentId == pId then table.insert(childrenIds, k) end + end + if #childrenIds == 0 then + return {} + else + local out = {} + for _, id in pairs(childrenIds) do + m.buildParams(pGraph, id, out) + end + return out + end +end + +--[[ @getTypeValue: Return value for defined data type +--! Returned value depends on 'pTypeData.valueType' value +--! Could be any of 'm.valueType', default is VALID_RANDOM +--! @parameters: +--! pTypeData: table with data type restrictions +--! pGraph: graph with structure of parameters +--! pId: id of the parameter in graph +--! @return: value for the parameter +--]] +local function getTypeValue(pTypeData, pGraph, pId) + if not pTypeData.valueType then pTypeData.valueType = m.valueType.VALID_RANDOM end + local getValueFuncMap = { + [api.dataType.INTEGER.type] = getIntegerValue, + [api.dataType.FLOAT.type] = getFloatValue, + [api.dataType.DOUBLE.type] = getDoubleValue, + [api.dataType.STRING.type] = getStringValue, + [api.dataType.BOOLEAN.type] = getBooleanValue, + [api.dataType.ENUM.type] = getEnumTypeValue, + [api.dataType.STRUCT.type] = getStructTypeValue + } + return getValueFuncMap[pTypeData.type](pTypeData, pGraph, pId) +end + +--[[ @getNumOfItems: Return number of items for the parameter +--! For the array number of items depends on 'pTypeData.valueTypeArray' value +--! Could be any of 'm.valueType', default is VALID_RANDOM +--! For non-array '-1' will be returned +--! @parameters: +--! pTypeData: table with data type restrictions +--! @return: number of items for the parameter +--]] +local function getNumOfItems(pTypeData) + local arrayValueType = m.valueType.VALID_RANDOM + if pTypeData.valueTypeArray then arrayValueType = pTypeData.valueTypeArray end + local numOfItems = -1 + if pTypeData.array == true then + if arrayValueType == m.valueType.LOWER_IN_BOUND then + numOfItems = pTypeData.minsize + if not numOfItems then numOfItems = 0 end + elseif arrayValueType == m.valueType.UPPER_IN_BOUND then + numOfItems = pTypeData.maxsize + if not numOfItems or numOfItems == 0 then numOfItems = 100 end + elseif arrayValueType == m.valueType.LOWER_OUT_OF_BOUND then + numOfItems = pTypeData.minsize + elseif arrayValueType == m.valueType.UPPER_OUT_OF_BOUND then + numOfItems = pTypeData.maxsize + if not numOfItems or numOfItems == 0 then numOfItems = 100 end + numOfItems = numOfItems + 1 + elseif arrayValueType == m.valueType.VALID_RANDOM then + local min = 1 + local max = 5 + if pTypeData.minsize ~= nil and pTypeData.minsize > min then min = pTypeData.minsize end + if pTypeData.maxsize ~= nil and pTypeData.maxsize < max then max = pTypeData.maxsize end + numOfItems = math.random(min, max) + end + end + return numOfItems +end + +--[[ @buildParams: Provide value for defined parameter and it's sub-parameters +--! @parameters: +--! pGraph: graph with structure of parameters +--! pId: id of the parameter in graph +--! pParams: table with result (used for recursion) +--! @return: table with parameter and it's value +--]] +function m.buildParams(pGraph, pId, pParams) + local name = pGraph[pId].name + local data = pGraph[pId] + local numOfItems = getNumOfItems(data) + if numOfItems == -1 then + pParams[name] = getTypeValue(data, pGraph, pId) + elseif numOfItems == 0 then + pParams[name] = json.EMPTY_ARRAY + else + pParams[name] = {} + for i = 1, numOfItems do + pParams[name][i] = getTypeValue(data, pGraph, pId) + end + end + return pParams +end + +--[[ @getParamValues: Provide values for parameter(s) and it's sub-parameters +--! @parameters: +--! pGraph: graph with structure of parameters +--! @return: table with parameters and it's values +--]] +function m.getParamValues(pGraph) + local out = {} + for id in pairs(pGraph) do + if pGraph[id].parentId == nil then + m.buildParams(pGraph, id, out) + end + end + return out +end + +return m diff --git a/user_modules/utils.lua b/user_modules/utils.lua index 3d98b5d66c..134f2df6a1 100644 --- a/user_modules/utils.lua +++ b/user_modules/utils.lua @@ -428,4 +428,18 @@ function m.getDeviceTransportType() end end +--[[ @splitString: split string by defined delimiter +--! @parameters: +--! pStr - string to be split +--! pDelimiter - delimiter +--! @return: table with string parts +--]] +function m.splitString(pStr, pDelimiter) + local result = {} + for match in (pStr .. pDelimiter):gmatch("(.-)%" .. pDelimiter) do + if string.len(match) > 0 then table.insert(result, match) end + end + return result +end + return m