From 19f79c277b5f1a41f3b0bf3fd05d6e5d92fa97ee Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 25 Nov 2020 10:56:49 -0500 Subject: [PATCH 01/10] Add new functions into utils module --- user_modules/utils.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 From 4d83c712dc382af115c62621f4266d52404a0df2 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 25 Nov 2020 10:57:10 -0500 Subject: [PATCH 02/10] Add new API common modules --- user_modules/api/APIHelper.lua | 195 ++++++++++++++ user_modules/api/APITestDataGenerator.lua | 308 ++++++++++++++++++++++ 2 files changed, 503 insertions(+) create mode 100644 user_modules/api/APIHelper.lua create mode 100644 user_modules/api/APITestDataGenerator.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..a21a2e1b72 --- /dev/null +++ b/user_modules/api/APITestDataGenerator.lua @@ -0,0 +1,308 @@ +---------------------------------------------------------------------------------------------------- +-- API Test Data Generator module +---------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]]------------------------------------------------------------------- +local ah = require("user_modules/api/APIHelper") + +--[[ 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 or length == 0 then length = ah.dataType.STRING.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + length = pTypeData.maxlength + if not length or length == 0 then length = ah.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 = ah.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 = ah.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 = ah.dataType.STRING.min end + if not max or max == 0 then max = ah.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 = ah.dataType.INTEGER.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + value = pTypeData.maxvalue + if not value then value = ah.dataType.INTEGER.max end + elseif pTypeData.valueType == m.valueType.LOWER_OUT_OF_BOUND then + value = pTypeData.minvalue + if not value then value = ah.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 = ah.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 = ah.dataType.INTEGER.min end + if not max then max = ah.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 = ah.dataType.FLOAT.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + value = pTypeData.maxvalue + if not value then value = ah.dataType.FLOAT.max end + elseif pTypeData.valueType == m.valueType.LOWER_OUT_OF_BOUND then + value = pTypeData.minvalue + if not value then value = ah.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 = ah.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 = ah.dataType.FLOAT.min end + if not max then max = ah.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 = ah.dataType.DOUBLE.min end + elseif pTypeData.valueType == m.valueType.UPPER_IN_BOUND then + value = pTypeData.maxvalue + if not value then value = ah.dataType.DOUBLE.max end + elseif pTypeData.valueType == m.valueType.LOWER_OUT_OF_BOUND then + value = pTypeData.minvalue + if not value then value = ah.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 = ah.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 = ah.dataType.DOUBLE.min end + if not max then max = ah.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 = { + [ah.dataType.INTEGER.type] = getIntegerValue, + [ah.dataType.FLOAT.type] = getFloatValue, + [ah.dataType.DOUBLE.type] = getDoubleValue, + [ah.dataType.STRING.type] = getStringValue, + [ah.dataType.BOOLEAN.type] = getBooleanValue, + [ah.dataType.ENUM.type] = getEnumTypeValue, + [ah.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 or numOfItems == 0 then numOfItems = 1 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 + if not numOfItems or numOfItems == 0 then numOfItems = 1 end + numOfItems = numOfItems - 1 + 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) + 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 From f38ed32d827681fc52415bab7021958a54453bbb Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 25 Nov 2020 10:57:33 -0500 Subject: [PATCH 03/10] Update VD common module --- test_scripts/API/VehicleData/common.lua | 1006 +++++++++++++++++------ 1 file changed, 770 insertions(+), 236 deletions(-) diff --git a/test_scripts/API/VehicleData/common.lua b/test_scripts/API/VehicleData/common.lua index 31566c5d1c..247beba3f7 100644 --- a/test_scripts/API/VehicleData/common.lua +++ b/test_scripts/API/VehicleData/common.lua @@ -7,20 +7,17 @@ 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 ah = require("user_modules/api/APIHelper") +local tdg = 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 @@ -46,7 +43,7 @@ do m.json = actions.json end ---[[ Common Variables ]] +--[[ Common Constants and Variables ]] m.rpc = { get = "GetVehicleData", sub = "SubscribeVehicleData", @@ -54,6 +51,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 +104,100 @@ 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, + NO = false, + ALL = 3 +} ---[[ @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, + NO = false, + ALL = 3 +} ---[[ @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 ---]] -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) - 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)) - 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) - end - end - return out -end +m.isVersion = { + YES = true, + NO = false, + ALL = 3 +} ---[[ @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 +--[[ Local Constants and Variables ]] +local hashId = {} +local isSubscribed = {} +local rpc +local rpcType +local testType +local paramName +local boundValueTypeMap = { + [m.testType.UPPER_IN_BOUND] = tdg.valueType.UPPER_IN_BOUND, + [m.testType.LOWER_IN_BOUND] = tdg.valueType.LOWER_IN_BOUND, + [m.testType.UPPER_OUT_OF_BOUND] = tdg.valueType.UPPER_OUT_OF_BOUND, + [m.testType.LOWER_OUT_OF_BOUND] = tdg.valueType.LOWER_OUT_OF_BOUND +} + +--[[ Common Functions ]] + +--[[ @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 = ah.getGraph(ah.apiType.MOBILE, ah.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 + vdParams[k] = nil m.cprint(color.magenta, "Disabled VD parameter:", k) 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 -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 + return vdParams end -m.versioningVD = getVersioningParamsFromAPI() - ---[[ Common Functions ]] +local vdParams = getAvailableVDParams() --[[ @updatePreloadedPTFile: Update preloaded file with additional permissions --! @parameters: @@ -339,64 +258,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 no 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 +331,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 +360,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 +487,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 +502,672 @@ 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 = tdg.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 = tdg.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 = tdg.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 = { + [ah.eventType.RESPONSE] = getParamsValidDataTestForRequest, + [ah.eventType.NOTIFICATION] = getParamsAnyDataTestForNotification + }, + INVALID = { + [ah.eventType.RESPONSE] = getParamsInvalidDataTestForRequest, + [ah.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. 'ah.dataType.INTEGER.type' +--! @return: table with test cases +--]] +local function createTestCases(pAPIType, pEventType, pFuncName, pIsMandatory, pIsArray, pIsVersion, pDataTypes) + + local graph = ah.getGraph(pAPIType, pEventType, pFuncName) + + 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 + + local function getMandatoryNeighbors(pGraph, pId, pParentIds) + local pIds = utils.cloneTable(pParentIds) + pIds[pId] = true + local out = {} + for p in pairs(pIds) 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 + + local function getMandatoryChildren(pGraph, pId, pChildreIds) + for k, v in pairs(pGraph) do + if v.parentId == pId and v.mandatory then + pChildreIds[k] = true + getMandatoryChildren(pGraph, k, pChildreIds) + end + end + return pChildreIds + end + + 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 + + local function getUpdatedParams(pGraph, pParamIds) + for k in pairs(pGraph) do + if not pParamIds[k] then + pGraph[k] = nil + end + end + return pGraph + end + + local function getTestCases(pGraph) + local function getMandatoryCondition(pMandatory) + if pIsMandatory == m.isMandatory.ALL then return true + else return pIsMandatory == pMandatory + end + end + local function getArrayCondition(pArray) + if pIsArray == m.isArray.ALL then return true + else return pIsArray == pArray + end + end + 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 + 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 + 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 + local tcs = {} + for k, v in pairs(pGraph) do + local paramFullName = ah.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(ah.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 ~= ah.dataType.STRUCT.type and paramData.parentId ~= nil then + table.insert(tests, { + name = "Param_" .. ah.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(ah.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_" .. ah.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 = { ah.dataType.INTEGER.type, ah.dataType.FLOAT.type, ah.dataType.DOUBLE.type, ah.dataType.STRING.type } + local tcs = createTestCases(ah.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_" .. ah.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.VALID[rpcType](tc.graph), + }) + end + -- tests for arrays + tcs = createTestCases(ah.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_" .. ah.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 = { ah.dataType.INTEGER.type, ah.dataType.FLOAT.type, ah.dataType.DOUBLE.type, ah.dataType.STRING.type } + local tcs = createTestCases(ah.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 == ah.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_" .. ah.getFullParamName(tc.graph, tc.paramId), + params = getParamsFuncMap.INVALID[rpcType](tc.graph), + }) + end + end + -- tests for arrays + tcs = createTestCases(ah.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_" .. ah.getFullParamName(tc.graph, tc.paramId) .. "_ARRAY", + params = getParamsFuncMap.INVALID[rpcType](tc.graph), + }) + end + -- tests for enums + tcs = createTestCases(ah.apiType.HMI, rpcType, m.rpcHMIMap[rpc], + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.ALL, { ah.dataType.ENUM.type }) + for _, tc in pairs(tcs) do + local function isSkipped() + local paramData = tc.graph[tc.paramId] + if paramData.type == ah.dataType.ENUM.type and testType == m.testType.LOWER_OUT_OF_BOUND then + return true + end + return false + end + 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_" .. ah.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 = { ah.dataType.ENUM.type } + local tcs = createTestCases(ah.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_" .. ah.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 = { ah.dataType.BOOLEAN.type } + local tcs = createTestCases(ah.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_" .. ah.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(ah.apiType.MOBILE, ah.eventType.REQUEST, rpc, + m.isMandatory.ALL, m.isArray.ALL, m.isVersion.YES, {}) + for _, tc in pairs(tcs) do + table.insert(tests, { + param = tc.graph[tc.paramId].name, + version = tc.graph[tc.paramId].since + }) + 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 = ah.getGraph(ah.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 = ah.getBranch(graph, paramId) + local tc = { graph = graph, paramId = paramId } + table.insert(tests, { + name = "Param_" .. ah.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 = ah.getFullParamName(graph, paramId) + local branchToDelete = ah.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 = { ah.dataType.INTEGER.type, ah.dataType.FLOAT.type, ah.dataType.DOUBLE.type, + ah.dataType.STRING.type, ah.dataType.ENUM.type, ah.dataType.BOOLEAN.type } + local tcs = createTestCases(ah.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 = tdg.valueType.INVALID_TYPE + table.insert(tests, { + name = "Param_" .. ah.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] = ah.eventType.RESPONSE, + [m.rpc.on] = ah.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.getTestsForGetVD(pTestTypes) + for param in m.spairs(m.getVDParams()) do + m.Title("VD parameter: " .. param) + for _, tt in pairs(pTestTypes) do + local tests = m.getTests(m.rpc.get, tt, param) + if #tests > 0 then + m.Title("Test type: " .. m.getKeyByValue(m.testType, tt)) + for _, t in pairs(tests) do + m.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.getTestsForOnVD(pTestTypes) + for param in m.spairs(m.getVDParams()) do + m.Title("VD parameter: " .. param) + for _, tt in pairs(pTestTypes) do + local tests = m.getTests(m.rpc.on, tt, param) + if #tests > 0 then + m.Title("Test type: " .. m.getKeyByValue(m.testType, tt)) + for _, t in pairs(tests) do + m.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 = ah.getGraph(ah.apiType.HMI, ah.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 = ah.getBranch(fullGraph, k) + local params = tdg.getParamValues(graph) + out[name] = params[name] + end + end + return out +end + +m.vdValues = getDefaultValues() + return m From ede9f29bf0beb150e94bfe5765a9a30634c44003 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 25 Nov 2020 10:58:14 -0500 Subject: [PATCH 04/10] Update existing scripts --- .../GetVehicleData/001_GetVD_Success_flow.lua | 13 ++++-- ...4_GetVD_HMI_responds_with_invalid_data.lua | 13 +++--- .../006_GetVD_mandatory_parameters.lua | 40 +++++-------------- ...sion_is_greater_than_parameter_version.lua | 14 +++---- ...version_is_less_than_parameter_version.lua | 14 +++---- .../OnVehicleData/001_OnVD_Success.lua | 18 ++++----- .../004_OnVD_with_invalid_data.lua | 18 ++++----- .../006_OnVD_mandatory_parameters.lua | 24 +++++------ 8 files changed, 66 insertions(+), 88 deletions(-) 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..993347e635 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.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.getTestsForGetVD(testTypes) common.Title("Postconditions") common.Step("Stop SDL", common.postconditions) 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..7f2f3521e4 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.Step("Activate App", common.activateApp) 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.getTestsForGetVD(testTypes) common.Title("Postconditions") common.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..08fc63272d 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("Clean environment and update preloaded_pt file", common.preconditions) common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("RAI", common.registerApp) +common.Step("Register App", common.registerApp) +common.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.getTestsForGetVD(testTypes) common.Title("Postconditions") common.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..d0471216e5 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,19 +23,19 @@ local common = require('test_scripts/API/VehicleData/common') --[[ Scenario ]] -for param, version in common.spairs(common.versioningVD) do - common.Title("VD parameter: " .. param) +for _, test in common.spairs(common.getTests(common.rpc.get, common.testType.PARAM_VERSION)) do + common.Title("VD parameter: " .. test.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("Set App version", common.setAppVersion, { test.version, common.operator.increase }) common.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.Step("RPC " .. common.rpc.get, common.getVehicleData, { test.param }) + common.Step("RPC " .. common.rpc.sub, common.processSubscriptionRPC, { common.rpc.sub, test.param }) + common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { test.param, common.isExpected }) + common.Step("RPC " .. common.rpc.unsub, common.processSubscriptionRPC, { common.rpc.unsub, test.param }) common.Title("Postconditions") common.Step("Stop SDL", common.postconditions) 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..9b746e92b6 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,19 +26,19 @@ 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) +for _, test in common.spairs(common.getTests(common.rpc.get, common.testType.PARAM_VERSION)) do + common.Title("VD parameter: " .. test.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("Set App version", common.setAppVersion, { test.version, common.operator.decrease }) common.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.Step("RPC " .. common.rpc.get, common.processRPCFailure, { common.rpc.get, test.param, result }) + common.Step("RPC " .. common.rpc.sub, common.processRPCFailure, { common.rpc.sub, test.param, result }) + common.Step("RPC " .. common.rpc.on, common.sendOnVehicleData, { test.param, common.isNotExpected }) + common.Step("RPC " .. common.rpc.unsub, common.processRPCFailure, { common.rpc.unsub, test.param, result }) common.Title("Postconditions") common.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..4267db0da7 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.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.getTestsForOnVD(testTypes) common.Title("Postconditions") common.Step("Stop SDL", common.postconditions) 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..e03a744a53 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.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.getTestsForOnVD(testTypes) common.Title("Postconditions") common.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..a149b68ddb 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("Clean environment and update preloaded_pt file", common.preconditions) common.Step("Start SDL, HMI, connect Mobile, start Session", common.start) -common.Step("RAI", common.registerApp) +common.Step("Register App", common.registerApp) +common.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.getTestsForOnVD(testTypes) common.Title("Postconditions") common.Step("Stop SDL", common.postconditions) From f783052c3d84614bb10a8e34157dacdc17ca1846 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 25 Nov 2020 10:58:44 -0500 Subject: [PATCH 05/10] Add new scripts --- .../009_GetVD_min_max_boundary_values.lua | 49 +++++++++++++++++++ .../010_GetVD_enum_and_bool_values.lua | 40 +++++++++++++++ .../007_OnVD_min_max_boundary_values.lua | 44 +++++++++++++++++ .../008_OnVD_enum_and_bool_values.lua | 38 ++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 test_scripts/API/VehicleData/GetVehicleData/009_GetVD_min_max_boundary_values.lua create mode 100644 test_scripts/API/VehicleData/GetVehicleData/010_GetVD_enum_and_bool_values.lua create mode 100644 test_scripts/API/VehicleData/OnVehicleData/007_OnVD_min_max_boundary_values.lua create mode 100644 test_scripts/API/VehicleData/OnVehicleData/008_OnVD_enum_and_bool_values.lua 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..ec405f8078 --- /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.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("Activate App", common.activateApp) + +common.Title("Test") +common.getTestsForGetVD(testTypes) + +common.Title("Postconditions") +common.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..c661f5a0bd --- /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.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("Activate App", common.activateApp) + +common.Title("Test") +common.getTestsForGetVD(testTypes) + +common.Title("Postconditions") +common.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..8417028313 --- /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.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("Activate App", common.activateApp) + +common.Title("Test") +common.getTestsForOnVD(testTypes) + +common.Title("Postconditions") +common.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..1b3c312186 --- /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.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("Activate App", common.activateApp) + +common.Title("Test") +common.getTestsForOnVD(testTypes) + +common.Title("Postconditions") +common.Step("Stop SDL", common.postconditions) From bbd80009f4e4b4627d8bdb3ede9b9775077da8c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 25 Nov 2020 10:59:04 -0500 Subject: [PATCH 06/10] Remove old scripts --- ...uccess_deviceStatus_primaryAudioSource.lua | 80 -------------- ...s_flow_deviceStatus_primaryAudioSource.lua | 97 ----------------- ...with_one_param_in_gearStatus_structure.lua | 75 ------------- ...only_one_param_in_gearStatus_structure.lua | 75 ------------- ..._with_one_param_in_fuelRange_structure.lua | 103 ------------------ ..._only_one_param_in_fuelRange_structure.lua | 103 ------------------ ...m_in_stabilityControlsStatus_structure.lua | 48 -------- ...m_in_stabilityControlsStatus_structure.lua | 48 -------- ...boundary_values_windowStatus_structure.lua | 78 ------------- ...boundary_values_windowStatus_structure.lua | 78 ------------- 10 files changed, 785 deletions(-) delete mode 100644 test_scripts/API/VehicleData/AudioSource/001_Success_deviceStatus_primaryAudioSource.lua delete mode 100644 test_scripts/API/VehicleData/AudioSource/002_Success_flow_deviceStatus_primaryAudioSource.lua delete mode 100644 test_scripts/API/VehicleData/GearStatus/001_GetVehicleData_with_one_param_in_gearStatus_structure.lua delete mode 100644 test_scripts/API/VehicleData/GearStatus/002_OnVehicleData_with_only_one_param_in_gearStatus_structure.lua delete mode 100644 test_scripts/API/VehicleData/RefactorFuelInformation/001_GetVehicleData_with_one_param_in_fuelRange_structure.lua delete mode 100644 test_scripts/API/VehicleData/RefactorFuelInformation/002_OnVehicleData_with_only_one_param_in_fuelRange_structure.lua delete mode 100644 test_scripts/API/VehicleData/StabilityControlsStatus/001_GetVehicleData_with_one_param_in_stabilityControlsStatus_structure.lua delete mode 100644 test_scripts/API/VehicleData/StabilityControlsStatus/002_OnVehicleData_with_only_one_param_in_stabilityControlsStatus_structure.lua delete mode 100644 test_scripts/API/VehicleData/WindowStatus/001_GetVehicleData_boundary_values_windowStatus_structure.lua delete mode 100644 test_scripts/API/VehicleData/WindowStatus/002_OnVehicleData_boundary_values_windowStatus_structure.lua 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/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/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) From e9d5c9befcaaea2f436f66f19dc6c6686daf45ed Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Wed, 25 Nov 2020 10:59:19 -0500 Subject: [PATCH 07/10] Update VD test set --- test_sets/vehicle_data.txt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/test_sets/vehicle_data.txt b/test_sets/vehicle_data.txt index 956ad9a007..447999cb1e 100644 --- a/test_sets/vehicle_data.txt +++ b/test_sets/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 From 9de3ed1bf6bd60042148722868fb79b084c681a4 Mon Sep 17 00:00:00 2001 From: vjacheslav Date: Wed, 11 Nov 2020 15:43:07 +0200 Subject: [PATCH 08/10] Add seatOccupancy to existed scripts for vehicle data --- test_scripts/API/VehicleData/common.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_scripts/API/VehicleData/common.lua b/test_scripts/API/VehicleData/common.lua index 247beba3f7..647876fa69 100644 --- a/test_scripts/API/VehicleData/common.lua +++ b/test_scripts/API/VehicleData/common.lua @@ -92,7 +92,8 @@ m.vd = { handsOffSteering = "VEHICLEDATA_HANDSOFFSTEERING", stabilityControlsStatus = "VEHICLEDATA_STABILITYCONTROLSSTATUS", gearStatus = "VEHICLEDATA_GEARSTATUS", - windowStatus = "VEHICLEDATA_WINDOWSTATUS" + windowStatus = "VEHICLEDATA_WINDOWSTATUS", + seatOccupancy = "VEHICLEDATA_SEATOCCUPANCY" } m.operator = { From 8423b708cde67de71f69b1e1b2bce5817cabe46c Mon Sep 17 00:00:00 2001 From: vjacheslav Date: Wed, 11 Nov 2020 15:44:04 +0200 Subject: [PATCH 09/10] Add seatOccupancy to existed scripts for GNSD --- .../commonGenericNetSignalData.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test_scripts/API/VehicleData/GenericNetworkSignalData/commonGenericNetSignalData.lua b/test_scripts/API/VehicleData/GenericNetworkSignalData/commonGenericNetSignalData.lua index 2392cc3a5d..c34785be7b 100644 --- a/test_scripts/API/VehicleData/GenericNetworkSignalData/commonGenericNetSignalData.lua +++ b/test_scripts/API/VehicleData/GenericNetworkSignalData/commonGenericNetSignalData.lua @@ -286,6 +286,14 @@ local function VehicleDataItemsWithDataTableCreation() local myKeyParams = common.VehicleDataItemsWithData.myKey.params myKeyParams.e911Override.value = "ON" common.VehicleDataItemsWithData.myKey.APItype = "VEHICLEDATA_MYKEY" + local seatOccupancyParams = common.VehicleDataItemsWithData.seatOccupancy.params + seatOccupancyParams.seatsOccupied.value = { + { seatLocation = { grid = { col = 53, row = 53, level = 53, colspan = 53, rowspan = 53, levelspan = 53 }}, + conditionActive = true }} + seatOccupancyParams.seatsBelted.value = { + { seatLocation = { grid = { col = 54, row = 54, level = 54, colspan = 54, rowspan = 54, levelspan = 54 }}, + conditionActive = false }} + common.VehicleDataItemsWithData.seatOccupancy.APItype = "VEHICLEDATA_SEATOCCUPANCY" else utils.cprint(31, "VehicleDataItemsWithData are missed in preloaded file") end From 27af7bf38fc552476fd05276bac7416f39064523 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Tue, 1 Dec 2020 16:28:03 -0500 Subject: [PATCH 10/10] Add posibility to run tests only for specified VD parameter --- .../003_GetVD_disallowed_after_PTU.lua | 1 + .../003_OnVD_disallowed_after_PTU.lua | 2 + .../003_SubscribeVD_disallowed_after_PTU.lua | 1 + ...003_UnsubscribeVD_disallowed_after_PTU.lua | 2 + test_scripts/API/VehicleData/common.lua | 54 +++++++++++++++++-- 5 files changed, 55 insertions(+), 5 deletions(-) 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..caa089af12 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] = { 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..5d35c841fe 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] = { 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..96d7d20468 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] = { 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..4838ff5d14 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] = { diff --git a/test_scripts/API/VehicleData/common.lua b/test_scripts/API/VehicleData/common.lua index 247beba3f7..28ea26067b 100644 --- a/test_scripts/API/VehicleData/common.lua +++ b/test_scripts/API/VehicleData/common.lua @@ -168,9 +168,47 @@ local boundValueTypeMap = { [m.testType.UPPER_OUT_OF_BOUND] = tdg.valueType.UPPER_OUT_OF_BOUND, [m.testType.LOWER_OUT_OF_BOUND] = tdg.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 +--]] +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 + end + end + if #checkedExtVDParams > 0 then + for k in pairs(m.vd) do + if not utils.isTableContains(checkedExtVDParams, k) then + m.vd[k] = nil + end + end + 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 +end + +restrictAvailableVDParams() + --[[ @getAvailableVDParams: Return VD parameters available for processing --! @parameters: none --! @return: table with VD parameters @@ -191,7 +229,7 @@ local function getAvailableVDParams() for k in pairs(vdParams) do if m.vd[k] == nil then vdParams[k] = nil - m.cprint(color.magenta, "Disabled VD parameter:", k) + if not isRestricted then m.cprint(color.magenta, "Disabled VD parameter:", k) end end end return vdParams @@ -223,6 +261,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 @@ -946,10 +987,13 @@ local function getVersionTests() local tcs = createTestCases(ah.apiType.MOBILE, ah.eventType.REQUEST, rpc, m.isMandatory.ALL, m.isArray.ALL, m.isVersion.YES, {}) for _, tc in pairs(tcs) do - table.insert(tests, { - param = tc.graph[tc.paramId].name, - version = tc.graph[tc.paramId].since - }) + 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