Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts for 3858 issue #2648

Merged
merged 4 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 succeed result code in result structure from HMI to the mobile app
ShobhitAd marked this conversation as resolved.
Show resolved Hide resolved
-- 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 succeed result code in result structure to VR.AddCommand
ShobhitAd marked this conversation as resolved.
Show resolved Hide resolved
--
-- 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_1/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 succeed result code in error structure from HMI to the mobile app
ShobhitAd marked this conversation as resolved.
Show resolved Hide resolved
-- 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 succeed result code in error structure to VR.AddCommand
ShobhitAd marked this conversation as resolved.
Show resolved Hide resolved
--
-- 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_1/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_1/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 = {
ShobhitAd marked this conversation as resolved.
Show resolved Hide resolved
[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
2 changes: 2 additions & 0 deletions test_sets/Defects/Defects_release_8_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
./test_scripts/Defects/8_1/3845/3845_4_PerformAudioPassThru_custom_success_codes_in_error_structure_to_ui.lua
./test_scripts/Defects/8_1/3845/3845_5_PerformAudioPassThru_custom_success_codes_in_error_structure_to_tts.lua
./test_scripts/Defects/8_1/3845/3845_6_PerformAudioPassThru_custom_success_codes_in_error_structure_to_tts_and_ui.lua
./test_scripts/Defects/8_1/3858/3858_1_CreateInteractionChoiceSet_custom_success_codes_result_structure.lua
./test_scripts/Defects/8_1/3858/3858_2_CreateInteractionChoiceSet_custom_success_codes_error_structure.lua