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

Add script to check #3524 issue #2464

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
78 changes: 78 additions & 0 deletions test_scripts/API/Additional_Submenus/007_non-existent_parentID.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---------------------------------------------------------------------------------------------------
-- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0148-template-additional-submenus.md#backwards-compatibility
-- Issue: https://github.com/smartdevicelink/sdl_core/issues/3524
---------------------------------------------------------------------------------------------------
-- Steps:
-- 1. App sends 'AddSubMenu' request with non-existent 'parentID'
--
-- Expected:
-- SDL does:
-- - not transfer request to HMI
-- - respond to App with: false:INVALID_ID
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('user_modules/sequences/actions')

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

--[[ Local Variables ]]
local parentId = 1
local child1Id = 2
local child2Id = 3
local nonExistentId = 4

--[[ Local Functions ]]
local function sendAddSubMenu_Success(pMenuId, pParentId)
local params = {
menuID = pMenuId,
menuName = "SubMenupositive" .. pMenuId,
parentID = pParentId
}
local hmiReqParams = {
menuID = params.menuID,
menuParams = {
position = params.position,
menuName = params.menuName,
parentID = params.parentID
},
appID = common.getHMIAppId()
}
local cid = common.getMobileSession():SendRPC("AddSubMenu", params)
common.getHMIConnection():ExpectRequest("UI.AddSubMenu", hmiReqParams)
:Do(function(_, data)
common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
common.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
common.getMobileSession():ExpectNotification("OnHashChange")
end

local function sendAddSubMenu_Failed(pMenuId, pParentId)
local params = {
menuID = pMenuId,
menuName = "SubMenupositive" .. pMenuId,
parentID = pParentId
}
local cid = common.getMobileSession():SendRPC("AddSubMenu", params)
common.getHMIConnection():ExpectRequest("UI.AddSubMenu")
:Times(0)
common.getMobileSession():ExpectResponse(cid, { success = false, resultCode = "INVALID_ID" })
common.getMobileSession():ExpectNotification("OnHashChange")
:Times(0)
end

--[[ 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.app.registerNoPTU)
runner.Step("Activate App", common.app.activate)

runner.Title("Test")
runner.Step("Add parent SubMenu", sendAddSubMenu_Success, { parentId })
runner.Step("Add child SubMenu for existent parentID", sendAddSubMenu_Success, { child1Id, parentId })
runner.Step("Add child SubMenu for non-existent parentID", sendAddSubMenu_Failed, { child2Id, nonExistentId })

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
3 changes: 2 additions & 1 deletion test_sets/additional_submenus_and_driver_distraction.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
./test_scripts/API/Additional_Submenus/004_delete_top_level_submenu_with_nested_submenus_and_commands.lua
./test_scripts/API/Additional_Submenus/005_duplicate_name_different_level_success.lua
./test_scripts/API/Additional_Submenus/006_duplicate_name_same_level_fail.lua
./test_scripts/API/DriverDistractionCapability/001_get_driver_distraction_capability.lua
./test_scripts/API/Additional_Submenus/007_non-existent_parentID.lua
./test_scripts/API/DriverDistractionCapability/001_get_driver_distraction_capability.lua