Skip to content

Commit

Permalink
Script 1-2 GPS Shift for review
Browse files Browse the repository at this point in the history
  • Loading branch information
Myza Taras committed Nov 8, 2018
1 parent c3bb85f commit 871af55
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---------------------------------------------------------------------------------------------------
-- Proposal:
-- https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0192-button_subscription_response_from_hmi.md
-- User story: TBD
-- Use case: TBD
--
-- Requirement summary: TBD
--
-- Description:
-- In case:
-- 1) Mobile sends GetVehicleData(gps(shifted=true/false)) request
-- 2) SDL transfers this request to HMI
-- 3) HMI sends "shifted" item (boolean) in "gps" parameter (Common.GPSData) of GetVehicleData response
-- SDL does:
-- 1) Sends GetVehicleData response to mobile with "shifted" item in "gps" parameter
---------------------------------------------------------------------------------------------------

--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/API/VehicleData/GpsShiftSupport/commonGpsShift')

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

--[[ Local Functions ]]
local function pTUpdateFunc(tbl)
tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.fullAppID].groups = {"Base-4", "Location-1"}
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.registerApp)
runner.Step("PTU", common.policyTableUpdate, { pTUpdateFunc })
runner.Step("Activate App", common.activateApp)

runner.Title("Test")
for _, v in pairs(common.shiftValue) do
runner.Step("Get GPS VehicleData, gps-shifted " .. tostring(v), common.getVehicleData, { v })
end

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---------------------------------------------------------------------------------------------------
-- Proposal:
-- https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0192-button_subscription_response_from_hmi.md
-- User story: TBD
-- Use case: TBD
--
-- Requirement summary: TBD
--
-- Description:
-- In case:
-- 1) Mobile sends SubscribeOnVehicleData(gps(shifted=true/false)) request
-- 2) SDL transfers this request to HMI
-- 3) HMI sends "shifted" item (boolean) in "gps" parameter (Common.GPSData) of SubscribeOnVehicleData response
-- SDL does:
-- 1) Sends SubscribeOnVehicleData response to mobile with "shifted" item in "gps" parameter
---------------------------------------------------------------------------------------------------

--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/API/VehicleData/GpsShiftSupport/commonGpsShift')

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

--[[ Local Functions ]]
local function pTUpdateFunc(tbl)
tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.fullAppID].groups = {"Base-4", "Location-1"}
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.registerApp)
runner.Step("PTU", common.policyTableUpdate, { pTUpdateFunc })
runner.Step("Activate App", common.activateApp)

runner.Title("Test")
runner.Step("Subscribe on GPS VehicleData", common.subscribeVehicleData)
for _, v in pairs(common.shiftValue) do
runner.Step("Send On VehicleData with GpsShift " .. tostring(v), common.sendOnVehicleData, { v })
end


runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
75 changes: 75 additions & 0 deletions test_scripts/API/VehicleData/GpsShiftSupport/commonGpsShift.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---------------------------------------------------------------------------------------------------
-- Common module
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--[[ General configuration parameters ]]
config.defaultProtocolVersion = 2
--[[ Required Shared libraries ]]
local actions = require("user_modules/sequences/actions")
local test = require("user_modules/dummy_connecttest")

--[[ Variables ]]
local m = actions

m.shiftValue = {
true,
false
}

m.gpsParams = {
longitudeDegrees = 42.5,
latitudeDegrees = -83.3,
utcYear = 2013,
utcMonth = 2,
utcDay = 14,
utcHours = 13,
utcMinutes = 16,
utcSeconds = 54,
compassDirection = "SOUTHWEST",
pdop = 8.4,
hdop = 5.9,
vdop = 3.2,
actual = false,
satellites = 8,
dimension = "2D",
altitude = 7.7,
heading = 173.99,
speed = 2.78,
shifted
}

--[[ Functions ]]
function m.failTestCase(pCause)
test:FailTestCase(pCause)
end

function m.getVehicleData(pShiftValue)
m.gpsParams.shifted = pShiftValue
local cid = m.getMobileSession():SendRPC("GetVehicleData", { gps = true })
EXPECT_HMICALL("VehicleInfo.GetVehicleData", { gps = true })
:Do(function(_, data)
m.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", { gps = m.gpsParams })
end)
m.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS", gps = m.gpsParams })
end

function m.subscribeVehicleData()
local gpsResponseData = {
dataType = "VEHICLEDATA_GPS",
resultCode = "SUCCESS"
}
local cid = m.getMobileSession():SendRPC("SubscribeVehicleData", { gps = true })
EXPECT_HMICALL("VehicleInfo.SubscribeVehicleData", { gps = true })
:Do(function(_, data)
m.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", { gps = gpsResponseData })
end)
m.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS", gps = gpsResponseData })
end

function m.sendOnVehicleData(pShiftValue)
m.gpsParams.shifted = pShiftValue
m.getHMIConnection():SendNotification("VehicleInfo.OnVehicleData", { gps = m.gpsParams })
m.getMobileSession():ExpectNotification("OnVehicleData", { gps = m.gpsParams })
end

return m
2 changes: 2 additions & 0 deletions test_sets/gps_shift_support.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./test_scripts/API/VehicleData/GpsShiftSupport/001_GetVehicleData_gps_shifted_true.lua
./test_scripts/API/VehicleData/GpsShiftSupport/002_SubscribeOnVehicleData_gps_shift.lua

0 comments on commit 871af55

Please sign in to comment.