Skip to content

Commit

Permalink
Scripts for 3858 issue (#2648)
Browse files Browse the repository at this point in the history
* Scripts for 3858 issue

* fixup! Scripts for 3858 issue

* Moved scripts to 8_2 scripts
  • Loading branch information
GetmanetsIrina committed Jun 15, 2022
1 parent 5a7f57d commit cdaea29
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---------------------------------------------------------------------------------------------------
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3858
---------------------------------------------------------------------------------------------------
-- Description: Check that SDL transfers success result code in result structure from HMI to the mobile app
-- during processing of CreateInteractionChoiceSet

-- Precondition:
-- 1. SDL and HMI are started
-- 2. Mobile app is registered and activated
--
-- Steps:
-- 1. Mobile app requests CreateInteractionChoiceSet RPC with vrCommands
-- 2. SDL sends VR.AddCommand(type="Choice") request to the HMI
-- 3. HMI responds with success result code in result structure to VR.AddCommand
--
-- SDL does:
-- 1. send CreateInteractionChoiceSet(success = true, resultCode = <code received from HMI>) response to the mobile app
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/Defects/8_2/3858/common_3858')

--[[ Test Configuration ]]
runner.testSettings.isSelfIncluded = false

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("Register App", common.registerApp)
runner.Step("Activate App", common.activateApp)

runner.Title("Test")
for choiceId, resultCode in ipairs(common.tcs) do
local response = { code = resultCode, structure = common.responsesStructures.result }
runner.Title("Test case: '" .. tostring(resultCode) .. "'" )
runner.Step("CreateInteractionChoiceSet response with success = true", common.createInteractionChoiceSet,
{ choiceId, response })
runner.Step("PerformInteraction with added choice set", common.performInteraction,{ choiceId })
end

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---------------------------------------------------------------------------------------------------
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3858
---------------------------------------------------------------------------------------------------
-- Description: Check that SDL transfers success result code in error structure from HMI to the mobile app
-- during processing of CreateInteractionChoiceSet

-- Precondition:
-- 1. SDL and HMI are started
-- 2. Mobile app is registered and activated
--
-- Steps:
-- 1. Mobile app requests CreateInteractionChoiceSet RPC with vrCommands
-- 2. SDL sends VR.AddCommand(type="Choice") request to the HMI
-- 3. HMI responds with success result code in error structure to VR.AddCommand
--
-- SDL does:
-- 1. send CreateInteractionChoiceSet(success = true, resultCode = <code received from HMI>) response to the mobile app
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/Defects/8_2/3858/common_3858')

--[[ Test Configuration ]]
runner.testSettings.isSelfIncluded = false

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("Register App", common.registerApp)
runner.Step("Activate App", common.activateApp)

runner.Title("Test")
for choiceId, resultCode in ipairs(common.tcs) do
local response = { code = resultCode, structure = common.responsesStructures.error }
runner.Title("Test case: '" .. tostring(resultCode) .. "'" )
runner.Step("CreateInteractionChoiceSet response with success = true", common.createInteractionChoiceSet,
{ choiceId, response })
runner.Step("PerformInteraction with added choice set", common.performInteraction,{ choiceId })
end

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)

156 changes: 156 additions & 0 deletions test_scripts/Defects/8_2/3858/common_3858.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---------------------------------------------------------------------------------------------------
-- Common module
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local actions = require("user_modules/sequences/actions")

--[[ Module ]]
local m = {}

--[[ Proxy Functions ]]
m.start = actions.start
m.preconditions = actions.preconditions
m.postconditions = actions.postconditions
m.getMobileSession = actions.getMobileSession
m.getHMIConnection = actions.getHMIConnection
m.registerApp = actions.registerApp
m.activateApp = actions.activateApp
m.getHMIAppId = actions.app.getHMIId

--[[ Common Variables ]]
m.tcs = {
[01] = "WARNINGS",
[02] = "TRUNCATED_DATA",
[03] = "RETRY",
[04] = "SAVED",
[05] = "WRONG_LANGUAGE",
[06] = "UNSUPPORTED_RESOURCE"
}

m.responsesStructures = {
result = function(data, code) m.getHMIConnection():SendResponse(data.id, data.method, code, {}) end,
error = function(data, code) m.getHMIConnection():SendError(data.id, data.method, code, "Error message") end
}

--[[ Local Functions ]]
local function getCICSparams(choiceId)
local requestParams = {
interactionChoiceSetID = choiceId,
choiceSet = {
{
choiceID = choiceId,
menuName ="Choice" .. choiceId,
vrCommands = {
"Choice" .. choiceId
}
}
}
}

local vrRequest = {
cmdID = requestParams.interactionChoiceSetID,
type = "Choice",
vrCommands = requestParams.vrCommands
}

local allParams = {
requestParams = requestParams,
vrRequest = vrRequest
}

return allParams
end

local function getPIparams(choiceSetID)
local function getPromptValue(pText)
return {
{
text = pText,
type = "TEXT"
}
}
end

local initialPromptValue = getPromptValue("Make your choice")

local helpPromptValue = getPromptValue("Help Prompt")

local timeoutPromptValue = getPromptValue("Time out")

local vrHelpvalue = {
{
text = "New VRHelp",
position = 1
}
}
local requestParams = {
initialText = "StartPerformInteraction",
initialPrompt = initialPromptValue,
interactionMode = "BOTH",
interactionChoiceSetIDList = {
choiceSetID
},
helpPrompt = helpPromptValue,
timeoutPrompt = timeoutPromptValue,
timeout = 5000,
vrHelp = vrHelpvalue,
interactionLayout = "ICON_ONLY"
}
return requestParams
end

local function setExChoiceSet(pChoiceIDValues)
local exChoiceSet = { }
for i = 1, #pChoiceIDValues do
exChoiceSet[i] = {
choiceID = pChoiceIDValues[i],
menuName = "Choice" .. pChoiceIDValues[i]
}
end
return exChoiceSet
end

function m.createInteractionChoiceSet(choiceNumber, response)
local params = getCICSparams(choiceNumber)
local cid = m.getMobileSession():SendRPC("CreateInteractionChoiceSet", params.requestParams)

params.vrRequest.appID = m.getHMIAppId()
m.getHMIConnection():ExpectRequest("VR.AddCommand", params.vrRequest)
:Do(function(_, data)
response.structure(data, response.code)
end)

m.getMobileSession():ExpectResponse(cid, { success = true, resultCode = response.code })
m.getMobileSession():ExpectNotification("OnHashChange")
end

function m.performInteraction(choiceId)
local params = getPIparams(choiceId)
params.interactionMode = "BOTH"
local cid = m.getMobileSession():SendRPC("PerformInteraction", params)
m.getHMIConnection():ExpectRequest("VR.PerformInteraction", {
helpPrompt = params.helpPrompt,
initialPrompt = params.initialPrompt,
timeout = params.timeout,
timeoutPrompt = params.timeoutPrompt
})
:Do(function(_, data)
m.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", { choiceID = choiceId })
end)
m.getHMIConnection():ExpectRequest("UI.PerformInteraction", {
timeout = params.timeout,
choiceSet = setExChoiceSet(params.interactionChoiceSetIDList),
initialText = {
fieldName = "initialInteractionText",
fieldText = params.initialText
},
vrHelp = params.vrHelp,
vrHelpTitle = params.initialText
})
:Do(function(_, data)
m.getHMIConnection():SendError(data.id, data.method, "ABORTED", "Perform Interaction error response.")
end)
m.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS", choiceID = choiceId })
end

return m
4 changes: 3 additions & 1 deletion test_sets/Defects/Defects_release_8_2.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
./test_scripts/Defects/8_2/3912_PTS_With_WSS_App_Content_Length.lua
./test_scripts/Defects/8_2/3909_vrHelp_resumption_after_ResetGlobalProperties.lua
./test_scripts/Defects/8_2/3909_vrHelp_resumption_after_ResetGlobalProperties.lua
./test_scripts/Defects/8_2/3858/3858_1_CreateInteractionChoiceSet_custom_success_codes_result_structure.lua
./test_scripts/Defects/8_2/3858/3858_2_CreateInteractionChoiceSet_custom_success_codes_error_structure.lua

0 comments on commit cdaea29

Please sign in to comment.