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 main menu updating tests #2435

Merged
merged 3 commits into from
Aug 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---------------------------------------------------------------------------------------------------
-- Description:
-- HMI sends capability with DynamicUpdateCapabilities parameter

-- Pre-conditions:
-- a. HMI and SDL are started
-- b. appID is registered and activated on SDL
-- c. appID is currently in Background, Full or Limited HMI level

-- Steps:
-- HMI sends DISPLAYS system capability update with Dynamic Update capabilities

-- Expected:
-- Mobile receives capability update with correct params.
---------------------------------------------------------------------------------------------------

--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/Smoke/commonSmoke')

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

--[[ Local Variables ]]
local onSystemCapabilityUpdatedParams = {
systemCapability = {
systemCapabilityType = "DISPLAYS",
displayCapabilities = {
{
displayName = "displayName",
windowTypeSupported = {
{
type = "MAIN",
maximumNumberOfWindows = 1
},
{
type = "WIDGET",
maximumNumberOfWindows = 2
}
},
windowCapabilities = {
{
dynamicUpdateCapabilities = {
supportedDynamicImageFieldNames = {"subMenuIcon", "menuIcon"},
supportsDynamicSubMenus = true
},
menuLayoutsAvailable = { "LIST", "TILES" },
textFields = {
{
name = "mainField1",
characterSet = "TYPE2SET",
width = 1,
rows = 1
}
},
imageFields = {
{
name = "choiceImage",
imageTypeSupported = { "GRAPHIC_PNG"
},
imageResolution = {
resolutionWidth = 35,
resolutionHeight = 35
}
}
},
imageTypeSupported = {
"STATIC"
},
templatesAvailable = {
"Template1", "Template2", "Template3", "Template4", "Template5"
},
numCustomPresetsAvailable = 100,
buttonCapabilities = {
{
longPressAvailable = true,
name = "VOLUME_UP",
shortPressAvailable = true,
upDownAvailable = false
}
},
softButtonCapabilities = {
{
shortPressAvailable = true,
longPressAvailable = true,
upDownAvailable = true,
imageSupported = true,
textSupported = true
}
}
}
}
}
}
}
}

--[[ Local Functions ]]
local function updateDisplayCapabilities()
local mobileSession = common.getMobileSession()
local hmi = common.getHMIConnection()
onSystemCapabilityUpdatedParams.appID = common.getHMIAppId()
hmi:SendNotification("BasicCommunication.OnSystemCapabilityUpdated", onSystemCapabilityUpdatedParams)

onSystemCapabilityUpdatedParams.appID = nil
mobileSession:ExpectNotification("OnSystemCapabilityUpdated", onSystemCapabilityUpdatedParams)
end

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

runner.Title("Test")
runner.Step("Sending Dynamic Update Capabilities", updateDisplayCapabilities)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
86 changes: 86 additions & 0 deletions test_scripts/API/MainMenuUpdating/002_on_update_file_success.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---------------------------------------------------------------------------------------------------
-- HMI requests a missing cmdIcon be updated from mobile

-- Pre-conditions:
-- a. HMI and SDL are started
-- b. appID is registered and activated on SDL
-- c. mobile sends an addcommand with an image that does not exist

-- Steps:
-- User opens the menu, and the hmi sends UI.OnUpdateFile

-- Expected:
-- Mobile receives notification that the file should be updated
---------------------------------------------------------------------------------------------------

--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/Smoke/commonSmoke')

--[[ Test Configuration ]]
runner.testSettings.isSelfIncluded = false
local missingFile = "missing_file.png"
local addCommandParams = {
cmdID = 50,
cmdIcon = {
value = missingFile,
imageType = "DYNAMIC"
},
menuParams = {
position = 4,
menuName = "Command Missing Image"
}
}

local onUpdateFileParams = {
fileName = missingFile
}

local hmiOnUpdateFileParams = {
fileName = missingFile,
appID = nil
}


--[[ Local Functions ]]
local function AddCommandNoImage()
local mobileSession = common.getMobileSession()
local hmi = common.getHMIConnection()
local cid = mobileSession:SendRPC("AddCommand", addCommandParams)

--hmi side: expect UI.AddCommand request
local hmiCommands = addCommandParams
hmiCommands.cmdIcon.value = common.getPathToFileInStorage(missingFile)
hmi:ExpectRequest("UI.AddCommand", hmiCommands)
:Do(function(_,data)
--hmi side: sending UI.AddCommand response
hmi:SendResponse(data.id, data.method, "SUCCESS", {})
end)

--mobile side: expect AddCommand response
mobileSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
end


local function ShowMenuRequestFile()
local mobileSession = common.getMobileSession()
local hmi = common.getHMIConnection()
hmiOnUpdateFileParams.appID = common.getHMIAppId()
hmi:SendNotification("UI.OnUpdateFile", hmiOnUpdateFileParams)
mobileSession:ExpectNotification("OnUpdateFile", onUpdateFileParams)
end

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

runner.Title("Test")
runner.Step("Add command with non-existing image", AddCommandNoImage)
runner.Step("Show menu and request File", ShowMenuRequestFile)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---------------------------------------------------------------------------------------------------
-- HMI requests a subemenu is populated

-- Pre-conditions:
-- a. HMI and SDL are started
-- b. appID is registered and activated on SDL
-- c. mobile sends an addSubMenu request with no other contents

-- Steps:
-- User opens the menu, and the hmi sends UI.OnUpdateSubMenu

-- Expected:
-- Mobile receives notification that the submenu should be updated
---------------------------------------------------------------------------------------------------

--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/Smoke/commonSmoke')

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

local addSubMenu = {
menuID = 50,
menuName = "Sub Menu"
}

local addSubMenuHMI = {
menuID = 50,
menuParams = {
menuName = "Sub Menu"
}
}

local onUpdateSubMenu = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like how you added appID = nil on the other notification that it is added dynamically to

menuID = 50,
updateSubCells = true
}


--[[ Local Functions ]]
local function AddSubMenuNoCommands()
local mobileSession = common.getMobileSession()
local hmi = common.getHMIConnection()
local cid = mobileSession:SendRPC("AddSubMenu", addSubMenu)

--hmi side: expect UI.AddCommand request
hmi:ExpectRequest("UI.AddSubMenu", addSubMenuHMI)
:Do(function(_,data)
--hmi side: sending UI.AddCommand response
hmi:SendResponse(data.id, data.method, "SUCCESS", {})
end)

--mobile side: expect AddCommand response
mobileSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
end


local function ShowMenuRequestCommands()
local mobileSession = common.getMobileSession()
local hmi = common.getHMIConnection()
onUpdateSubMenu.appID = common.getHMIAppId()
hmi:SendNotification("UI.OnUpdateSubMenu", onUpdateSubMenu)
onUpdateSubMenu.appID = nil
mobileSession:ExpectNotification("OnUpdateSubMenu", onUpdateSubMenu)
end

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

runner.Title("Test")
runner.Step("Add command with non-existing image", AddSubMenuNoCommands)
runner.Step("Show menu and request submenu commands", ShowMenuRequestCommands)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
3 changes: 3 additions & 0 deletions test_sets/main_menu_updating_and_pagination.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
./test_scripts/API/MainMenuUpdating/001_dynamic_update_capabilities_success.lua
./test_scripts/API/MainMenuUpdating/003_on_update_sub_menu_success.lua
./test_scripts/API/MainMenuUpdating/002_on_update_file_success.lua