Skip to content

Commit

Permalink
Update for changes regarding PTU
Browse files Browse the repository at this point in the history
  • Loading branch information
GetmanetsIrina authored and HSavynetska committed Jun 6, 2019
1 parent 0a05c8d commit 07d4d9d
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 35 deletions.
8 changes: 4 additions & 4 deletions test_scripts/API/SDL_Passenger_Mode/001_OnDD_PT_true.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
-- 1) OnDriverDistraction notification is allowed by Policy for (FULL, LIMITED, BACKGROUND, NONE) HMILevel
-- 2) In Policy "lock_screen_dismissal_enabled" parameter is defined with correct value (true)
-- 3) App registered (HMI level NONE)
-- 4) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 4) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- SDL does:
-- 1) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled" parameter
-- (value corresponds to the one defined in Policy) and all mandatory fields
-- 2) Send OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" parameter
-- 1) Send OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" parameter
-- and all mandatory fields
-- 2) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled" parameter
-- (value corresponds to the one defined in Policy) and all mandatory fields
--
-- Note: Cover all HMI levels
---------------------------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions test_scripts/API/SDL_Passenger_Mode/002_OnDD_PT_false.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
-- 1) OnDriverDistraction notification is allowed by Policy for (FULL, LIMITED, BACKGROUND, NONE) HMILevel
-- 2) In Policy "lock_screen_dismissal_enabled" parameter is defined with correct value (false)
-- 3) App registered (HMI level NONE)
-- 4) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 4) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- SDL does:
-- 1) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled" parameter
-- (value corresponds to the one defined in Policy) and all mandatory fields
-- 2) Send OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" parameter
-- 1) Send OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" parameter
-- and all mandatory fields
-- 2) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled" parameter
-- (value corresponds to the one defined in Policy) and all mandatory fields
--
-- Note: Cover all HMI levels
---------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-- 1) OnDriverDistraction notification is allowed by Policy for (FULL, LIMITED, BACKGROUND, NONE) HMILevel
-- 2) In Policy "lock_screen_dismissal_enabled" parameter is missing
-- 3) App registered (HMI level NONE)
-- 4) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 4) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- SDL does:
-- 1) Send OnDriverDistraction notification to mobile without "lockScreenDismissalEnabled" parameter,
-- but with all mandatory fields
Expand Down
19 changes: 13 additions & 6 deletions test_scripts/API/SDL_Passenger_Mode/004_OnDD_PTU_true.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
-- 1) OnDriverDistraction notification is allowed by Policy for (FULL, LIMITED, BACKGROUND, NONE) HMILevel
-- 2) In Policy "lock_screen_dismissal_enabled" parameter is missing
-- 3) App registered (HMI level NONE)
-- 4) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 4) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- 5) Policy Table update ("lock_screen_dismissal_enabled" = true)
-- 6) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 6) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- SDL does:
-- 1) Send OnDriverDistraction notification to mobile without "lockScreenDismissalEnabled" before PTU
-- 2) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled"=true after PTU
-- 3) Send OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" after PTU
-- 1) Resend OnDriverDistraction notification to mobile without "lockScreenDismissalEnabled" before PTU
-- 2) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled"=true right after PTU
-- 3) Resend OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" after PTU
-- 4) Resend OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled"=true after PTU
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
Expand All @@ -28,6 +29,12 @@ local function ptUpdate(pPT)
pPT.policy_table.module_config.lock_screen_dismissal_enabled = lockScreenDismissalEnabled
end

local function ptuWithOnDD()
common.policyTableUpdate(ptUpdate)
common.getMobileSession():ExpectNotification("OnDriverDistraction",
{ state = "DD_ON", lockScreenDismissalEnabled = true })
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
Expand All @@ -37,7 +44,7 @@ runner.Step("Register App", common.registerApp)

runner.Title("Test")
runner.Step("OnDriverDistraction ON/OFF missing", common.onDriverDistraction, { nil })
runner.Step("Policy Table Update", common.policyTableUpdate, { ptUpdate })
runner.Step("Policy Table Update", ptuWithOnDD)
runner.Step("OnDriverDistraction ON/OFF true", common.onDriverDistraction, { lockScreenDismissalEnabled })

runner.Title("Postconditions")
Expand Down
19 changes: 13 additions & 6 deletions test_scripts/API/SDL_Passenger_Mode/005_OnDD_PTU_false.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
-- 1) OnDriverDistraction notification is allowed by Policy for (FULL, LIMITED, BACKGROUND, NONE) HMILevel
-- 2) In Policy "lock_screen_dismissal_enabled" parameter is missing
-- 3) App registered (HMI level NONE)
-- 4) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 4) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- 5) Policy Table update ("lock_screen_dismissal_enabled" = false)
-- 6) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 6) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- SDL does:
-- 1) Send OnDriverDistraction notification to mobile without "lockScreenDismissalEnabled" before PTU
-- 2) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled"=false after PTU
-- 3) Send OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" after PTU
-- 1) Resend OnDriverDistraction notification to mobile without "lockScreenDismissalEnabled" before PTU
-- 2) Send OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled"=false right after PTU
-- 3) Resend OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" after PTU
-- 4) Resend OnDriverDistraction(DD_ON) notification to mobile with "lockScreenDismissalEnabled"=false after PTU
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
Expand All @@ -28,6 +29,12 @@ local function ptUpdate(pPT)
pPT.policy_table.module_config.lock_screen_dismissal_enabled = lockScreenDismissalEnabled
end

local function ptuWithOnDD()
common.policyTableUpdate(ptUpdate)
common.getMobileSession():ExpectNotification("OnDriverDistraction",
{ state = "DD_ON", lockScreenDismissalEnabled = false })
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
Expand All @@ -37,7 +44,7 @@ runner.Step("Register App", common.registerApp)

runner.Title("Test")
runner.Step("OnDriverDistraction ON/OFF missing", common.onDriverDistraction, { nil })
runner.Step("Policy Table Update", common.policyTableUpdate, { ptUpdate })
runner.Step("Policy Table Update", ptuWithOnDD)
runner.Step("OnDriverDistraction ON/OFF false", common.onDriverDistraction, { lockScreenDismissalEnabled })

runner.Title("Postconditions")
Expand Down
28 changes: 22 additions & 6 deletions test_scripts/API/SDL_Passenger_Mode/006_OnDD_PTU_missing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
-- 1) OnDriverDistraction notification is allowed by Policy for (FULL, LIMITED, BACKGROUND, NONE) HMILevel
-- 2) In Policy "lock_screen_dismissal_enabled" parameter is defined with correct value (true)
-- 3) App registered (HMI level NONE)
-- 4) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 4) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- 5) Policy Table update ("lock_screen_dismissal_enabled" = nil)
-- 6) HMI sends OnDriverDistraction notifications with state=DD_ON and then with state=DD_OFF one by one
-- 6) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- SDL does:
-- 1) Send OnDriverDistraction(DD_ON) notification to mobile with lockScreenDismissalEnabled=true before PTU
-- 2) Send OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" before PTU
-- 3) Send OnDriverDistraction notification to mobile without "lockScreenDismissalEnabled" after PTU
-- 1) Resend OnDriverDistraction(DD_OFF) notification to mobile without "lockScreenDismissalEnabled" before PTU
-- 2) Resend OnDriverDistraction(DD_ON) notification to mobile with lockScreenDismissalEnabled=true before PTU
-- 3) Send OnDriverDistraction(DD_ON) notification to mobile without "lockScreenDismissalEnabled" right after PTU
-- 4) Resend OnDriverDistraction notification to mobile without "lockScreenDismissalEnabled" after PTU
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
Expand All @@ -28,6 +29,21 @@ local function ptUpdate(pPT)
pPT.policy_table.module_config.lock_screen_dismissal_enabled = lockScreenDismissalEnabled
end

local function ptuWithOnDD()
local function msg(pValue)
return "Parameter `lockScreenDismissalEnabled` is transfered to Mobile with `" .. tostring(pValue) .. "` value"
end
common.policyTableUpdate(ptUpdate)
common.getMobileSession():ExpectNotification("OnDriverDistraction",
{ state = "DD_ON" })
:ValidIf(function(_, d)
if d.payload.lockScreenDismissalEnabled ~= nil then
return false, d.payload.state .. ": " .. msg(d.payload.lockScreenDismissalEnabled)
end
return true
end)
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
Expand All @@ -37,7 +53,7 @@ runner.Step("Register App", common.registerApp)

runner.Title("Test")
runner.Step("OnDriverDistraction ON/OFF true", common.onDriverDistraction, { true })
runner.Step("Policy Table Update", common.policyTableUpdate, { ptUpdate })
runner.Step("Policy Table Update", ptuWithOnDD)
runner.Step("OnDriverDistraction ON/OFF missing", common.onDriverDistraction, { lockScreenDismissalEnabled })

runner.Title("Postconditions")
Expand Down
144 changes: 144 additions & 0 deletions test_scripts/API/SDL_Passenger_Mode/009_OnDD_PTU_several_apps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---------------------------------------------------------------------------------------------------
-- Proposal: https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0119-SDL-passenger-mode.md
-- Description:
-- In case:
-- 1) OnDriverDistraction notification is allowed by Policy for (FULL, LIMITED, BACKGROUND) HMILevel
-- 2) In Policy "lock_screen_dismissal_enabled" parameter is defined with correct value (false)
-- 3) HMI sends OnDriverDistraction notification with all mandatory fields (state = "DD_ON")
-- 3) App1 registered (HMI level NONE)
-- 4) App2 registered (HMI level NONE)
-- 5) App1 is activated(HMI level FULL)
-- 6) Policy Table update ("lock_screen_dismissal_enabled" = true)
-- 7) App2 is activated(HMI level FULL)
-- 8) HMI sends OnDriverDistraction notifications with state=DD_OFF and then with state=DD_ON one by one
-- SDL does:
-- 1) Send OnDriverDistraction notification to mobile App1 with "lockScreenDismissalEnabled"=false after activation
-- 2) Send OnDriverDistraction(DD_ON) notification to mobile App1 with "lockScreenDismissalEnabled"=true right after PTU
-- 3) Send OnDriverDistraction(DD_ON) notification to mobile App2 with "lockScreenDismissalEnabled"=true after activation
-- 3) Resend OnDriverDistraction(DD_OFF) notification to both mobile apps without "lockScreenDismissalEnabled"
-- 4) Resend OnDriverDistraction(DD_ON) notification to both mobile apps with "lockScreenDismissalEnabled"=true after PTU
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/API/SDL_Passenger_Mode/commonPassengerMode')

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

--[[ Local Variables ]]
local lockScreenDismissalEnabled = true

--[[ Local Functions ]]
local function ptUpdate(pPT)
pPT.policy_table.module_config.lock_screen_dismissal_enabled = lockScreenDismissalEnabled
end

local function updatePreloadedPT(pLockScreenDismissalEnabled)
local function updatePT(pPT)
pPT.policy_table.functional_groupings["Base-4"].rpcs.OnDriverDistraction.hmi_levels = { "FULL", "LIMITED", "BACKGROUND"}
end
common.updatePreloadedPT(pLockScreenDismissalEnabled, updatePT)
end

local function ptuWithOnDD()
common.policyTableUpdate(ptUpdate)
common.getMobileSession():ExpectNotification("OnDriverDistraction",
{ state = "DD_ON", lockScreenDismissalEnabled = true })

common.getMobileSession(2):ExpectNotification("OnDriverDistraction")
:Times(0)
end

local function activateApp(pAppIdExpect, pAppIdNotExpect, pLockScreenDismissalEnabledValue)
common.activateApp(pAppIdExpect)
common.getMobileSession(pAppIdExpect):ExpectNotification("OnDriverDistraction",
{ state = "DD_ON", lockScreenDismissalEnabled = pLockScreenDismissalEnabledValue })
common.getMobileSession(pAppIdNotExpect):ExpectNotification("OnDriverDistraction")
:Times(0)
end

local function onDriverDistractionTwoApps(pLockScreenDismissalEnabled)
local function msg(pValue)
return "Parameter `lockScreenDismissalEnabled` is transfered to Mobile with `" .. tostring(pValue) .. "` value"
end
common.getHMIConnection():SendNotification("UI.OnDriverDistraction", { state = "DD_OFF" })
common.getHMIConnection():SendNotification("UI.OnDriverDistraction", { state = "DD_ON" })
common.getMobileSession():ExpectNotification("OnDriverDistraction",
{ state = "DD_OFF" },
{ state = "DD_ON", lockScreenDismissalEnabled = pLockScreenDismissalEnabled })
:ValidIf(function(e, d)
if e.occurences == 1 and d.payload.lockScreenDismissalEnabled ~= nil then
return false, d.payload.state .. ": " .. msg(d.payload.lockScreenDismissalEnabled)
end
return true
end)
:ValidIf(function(e, d)
if e.occurences == 2 and pLockScreenDismissalEnabled == nil and d.payload.lockScreenDismissalEnabled ~= nil then
return false, d.payload.state .. ": " .. msg(d.payload.lockScreenDismissalEnabled)
end
return true
end)
:Times(2)

common.getMobileSession(2):ExpectNotification("OnDriverDistraction",
{ state = "DD_OFF" },
{ state = "DD_ON", lockScreenDismissalEnabled = pLockScreenDismissalEnabled })
:ValidIf(function(e, d)
if e.occurences == 1 and d.payload.lockScreenDismissalEnabled ~= nil then
return false, d.payload.state .. ": " .. msg(d.payload.lockScreenDismissalEnabled)
end
return true
end)
:ValidIf(function(e, d)
if e.occurences == 2 and pLockScreenDismissalEnabled == nil and d.payload.lockScreenDismissalEnabled ~= nil then
return false, d.payload.state .. ": " .. msg(d.payload.lockScreenDismissalEnabled)
end
return true
end)
:Times(2)
end

local function onDriverDistraction()
common.getHMIConnection():SendNotification("UI.OnDriverDistraction", { state = "DD_ON" })
end

local function registerApp()
common.getMobileSession(2):StartService(7)
:Do(function()
local corId = common.getMobileSession(2):SendRPC("RegisterAppInterface", common.getConfigAppParams(2))
common.getHMIConnection():ExpectNotification("BasicCommunication.OnAppRegistered",
{ application = { appName = common.getConfigAppParams(2).appName } })
:Do(function(_, d1)
common.setHMIAppId(d1.params.application.appID, 2)
common.getHMIConnection():ExpectRequest("BasicCommunication.PolicyUpdate")
:Do(function(_, d2)
common.getHMIConnection():SendResponse(d2.id, d2.method, "SUCCESS", { })
end)
end)
common.getMobileSession(2):ExpectResponse(corId, { success = true, resultCode = "SUCCESS" })
:Do(function()
common.getMobileSession(2):ExpectNotification("OnHMIStatus",
{ hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN" })
common.getMobileSession(2):ExpectNotification("OnPermissionsChange")
:Times(AnyNumber())
end)
end)
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Set LockScreenDismissalEnabled", updatePreloadedPT, { false })
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("onDriverDistraction DD_ON", onDriverDistraction)
runner.Step("Register App1", common.registerAppWOPTU, { 1 })
runner.Step("Register App2", registerApp)
runner.Step("App1 activation HMI level FULL", activateApp, { 1, 2, false })

runner.Title("Test")
runner.Step("Policy Table Update", ptuWithOnDD)
runner.Step("App2 activation HMI level FULL", activateApp, { 2, 1, lockScreenDismissalEnabled })
runner.Step("OnDriverDistraction ON/OFF true", onDriverDistractionTwoApps, { lockScreenDismissalEnabled })

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
16 changes: 8 additions & 8 deletions test_scripts/API/SDL_Passenger_Mode/commonPassengerMode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ local preloadedPT = commonFunctions:read_parameter_from_smart_device_link_ini("P

--[[ Common Functions ]]
local registerAppOrig = c.registerApp
function c.registerApp()
registerAppOrig()
c.getMobileSession():ExpectNotification("OnDriverDistraction", { state = "DD_OFF" })
function c.registerApp(pAppId)
registerAppOrig(pAppId)
c.getMobileSession(pAppId):ExpectNotification("OnDriverDistraction", { state = "DD_OFF" })
end

function c.onDriverDistraction(pLockScreenDismissalEnabled)
local function msg(pValue)
return "Parameter `lockScreenDismissalEnabled` is transfered to Mobile with `" .. tostring(pValue) .. "` value"
end
c.getHMIConnection():SendNotification("UI.OnDriverDistraction", { state = "DD_ON" })
c.getHMIConnection():SendNotification("UI.OnDriverDistraction", { state = "DD_OFF" })
c.getHMIConnection():SendNotification("UI.OnDriverDistraction", { state = "DD_ON" })
c.getMobileSession():ExpectNotification("OnDriverDistraction",
{ state = "DD_ON", lockScreenDismissalEnabled = pLockScreenDismissalEnabled },
{ state = "DD_OFF" })
{ state = "DD_OFF" },
{ state = "DD_ON", lockScreenDismissalEnabled = pLockScreenDismissalEnabled })
:ValidIf(function(e, d)
if e.occurences == 1 and pLockScreenDismissalEnabled == nil and d.payload.lockScreenDismissalEnabled ~= nil then
if e.occurences == 1 and d.payload.lockScreenDismissalEnabled ~= nil then
return false, d.payload.state .. ": " .. msg(d.payload.lockScreenDismissalEnabled)
end
return true
end)
:ValidIf(function(e, d)
if e.occurences == 2 and d.payload.lockScreenDismissalEnabled ~= nil then
if e.occurences == 2 and pLockScreenDismissalEnabled == nil and d.payload.lockScreenDismissalEnabled ~= nil then
return false, d.payload.state .. ": " .. msg(d.payload.lockScreenDismissalEnabled)
end
return true
Expand Down
Loading

0 comments on commit 07d4d9d

Please sign in to comment.