Skip to content

Commit

Permalink
Add script to check AddSubMenu for non-existent parentID (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
dboltovskyi authored Oct 20, 2020
1 parent 81dea89 commit d207ed9
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
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

0 comments on commit d207ed9

Please sign in to comment.