Skip to content

Commit

Permalink
Script for issue 967
Browse files Browse the repository at this point in the history
  • Loading branch information
GetmanetsIrina committed Jul 31, 2018
1 parent 00cfe43 commit 3b2b556
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---------------------------------------------------------------------------------------------
-- GitHub issue https://github.com/SmartDeviceLink/sdl_core/issues/967
---------------------------------------------------------------------------------------------
-- Preconditions:
-- 1. Core, HMI started.
-- 2. App is registered on HMI and has HMI level BACKGROUND

-- Steps to reproduce:
-- 1. Send from HMI OnButtonEvent(CUSTOM_BUTTON, SHORT/LONG)

-- Expected result:
-- SDL resend it to BACKGROUND App.
---------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require("user_modules/sequences/actions")
local commonDefects = require("test_scripts/Defects/commonDefects")

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

--[[ Local Variables ]]
config.application1.registerAppInterfaceParams.appHMIType = { "MEDIA" }
config.application1.registerAppInterfaceParams.isMediaApplication = true

local showRequestParams = {
mainField1 = "mainField1",
softButtons = {
{
type = "TEXT",
text = "Button1",
softButtonID = 1,
systemAction = "DEFAULT_ACTION",
},
{
type = "TEXT",
text = "Button2",
softButtonID = 2,
systemAction = "DEFAULT_ACTION"
}
}
}

local pressMode = { "SHORT", "LONG" }

local rpcForPermissions = { "OnButtonEvent", "OnButtonPress"}

--[[ Local Functions ]]
local function Show()
local cid = common.getMobileSession():SendRPC("Show", showRequestParams)
EXPECT_HMICALL("UI.Show", { softButtons = showRequestParams.softButtons})
:Do(function(_,data)
common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", { })
end)
common.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
end

local function OnButtonEventPress(pBtnId, pPressMode)
local btnName = "CUSTOM_BUTTON"
local hmiAppId = common.getHMIAppId()
common.getHMIConnection():SendNotification("Buttons.OnButtonEvent",
{
name = btnName,
mode = "BUTTONDOWN",
customButtonID = pBtnId,
appID = hmiAppId
})
common.getHMIConnection():SendNotification("Buttons.OnButtonEvent",
{
name = btnName,
mode = "BUTTONUP",
customButtonID = pBtnId,
appID = hmiAppId
})
common.getHMIConnection():SendNotification("Buttons.OnButtonPress",
{
name = btnName,
mode = pPressMode,
customButtonID = pBtnId,
appID = hmiAppId
})
common.getMobileSession():ExpectNotification("OnButtonEvent",
{ buttonName = btnName, buttonEventMode = "BUTTONDOWN", customButtonID = pBtnId},
{ buttonName = btnName, buttonEventMode = "BUTTONUP", customButtonID = pBtnId })
:Times(2)
common.getMobileSession():ExpectNotification("OnButtonPress",
{ buttonName = btnName, buttonPressMode = pPressMode, customButtonID = pBtnId})
end

local function deactivateAppToLimited()
common.getHMIConnection():SendNotification("BasicCommunication.OnAppDeactivated", { appID = common.getHMIAppId() })
common.getMobileSession():ExpectNotification("OnHMIStatus",
{ hmiLevel = "LIMITED", audioStreamingState = "AUDIBLE", systemContext = "MAIN" })
end

local function deactivateAppToBackground()
common.getHMIConnection():SendNotification("BasicCommunication.OnEventChanged",
{ isActive = true, eventName = "AUDIO_SOURCE" })
common.getMobileSession():ExpectNotification("OnHMIStatus",
{ hmiLevel = "BACKGROUND", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN" })
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", commonDefects.preconditionsWithPTUpdate, { rpcForPermissions })
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("RAI, PTU", common.registerAppWOPTU)
runner.Step("Activate App", common.activateApp)
runner.Step("Show", Show)

runner.Title("Test")
for _, value in pairs(pressMode) do
runner.Step("OnButtonEventPress in FULL level with mode " .. value, OnButtonEventPress, { 1, value })
end
runner.Step("Bring app App to LIMITED", deactivateAppToLimited)
for _, value in pairs(pressMode) do
runner.Step("OnButtonEventPress in LIMITED level with mode " .. value, OnButtonEventPress, { 1, value })
end
runner.Step("Bring app App to BACKGROUND", deactivateAppToBackground)
for _, value in pairs(pressMode) do
runner.Step("OnButtonEventPress in BACKGROUND level with mode " .. value, OnButtonEventPress, { 1, value })
end

runner.Title("Postconditions")
runner.Step("Stop SDL", commonDefects.postconditionsWithPreloadedRestore)
50 changes: 50 additions & 0 deletions test_scripts/Defects/commonDefects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ local mobile_session = require("mobile_session")
local events = require("events")
local json = require("modules/json")
local actions = require("user_modules/sequences/actions")
local utils = require('user_modules/utils')

--[[ Local Variables ]]
local preloadedPT = commonFunctions:read_parameter_from_smart_device_link_ini("PreloadedPT")

-- table with data for Policy Table Update
local ptu_table = {}
Expand Down Expand Up @@ -203,6 +205,18 @@ function commonDefect.preconditions()
commonSteps:DeleteLogsFiles()
end

--[[ @preconditionsWithPTUpdate: precondition steps with PT update
--! @parameters: none
--! @return: none
--]]
function commonDefect.preconditionsWithPTUpdate(pAdditionalRPCs)
commonFunctions:SDLForceStop()
commonSteps:DeletePolicyTable()
commonSteps:DeleteLogsFiles()
commonPreconditions:BackupFile(preloadedPT)
commonDefect.updatePreloadedPT(pAdditionalRPCs)
end

--[[ @start: starting sequence: starting of SDL, initialization of HMI, connect mobile
--! @parameters:
--! self - test object
Expand Down Expand Up @@ -257,6 +271,42 @@ function commonDefect.postconditions()
StopSDL()
end

--[[ @postconditionsWithPreloadedRestore: postcondition steps
--! @parameters: none
--! @return: none
--]]
function commonDefect.postconditionsWithPreloadedRestore()
StopSDL()
commonPreconditions:RestoreFile(preloadedPT)
end

--[[ @updatePreloadedPT: update PU with all needed RPC
--! @parameters: none
--! @return: none
--]]
function commonDefect.updatePreloadedPT(pAdditionalRPCs)
local preloadedFile = commonPreconditions:GetPathToSDL() .. preloadedPT
local pt = utils.jsonFileToTable(preloadedFile)
pt.policy_table.functional_groupings["DataConsent-2"].rpcs = json.null
if not pAdditionalRPCs then
pAdditionalRPCs = {
"SendLocation", "SubscribeVehicleData", "UnsubscribeVehicleData", "GetVehicleData", "UpdateTurnList",
"AlertManeuver", "DialNumber", "ReadDID", "GetDTCs", "ShowConstantTBT"
}
end
pt.policy_table.functional_groupings.NewTestCaseGroup = { rpcs = { } }
for _, v in pairs(pAdditionalRPCs) do
pt.policy_table.functional_groupings.NewTestCaseGroup.rpcs[v] = {
hmi_levels = { "BACKGROUND", "FULL", "LIMITED" }
}
end
pt.policy_table.app_policies["0000001"] = utils.cloneTable(pt.policy_table.app_policies.default)
pt.policy_table.app_policies["0000001"].groups = { "Base-4", "NewTestCaseGroup" }
pt.policy_table.app_policies["0000001"].keep_context = true
pt.policy_table.app_policies["0000001"].steal_focus = true
utils.tableToJsonFile(pt, preloadedFile)
end

--[[ @printSDLConfig: print information about SDL build options
--! @parameters: none
--! @return: none
Expand Down

0 comments on commit 3b2b556

Please sign in to comment.