Skip to content

Commit

Permalink
Added script with subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
GetmanetsIrina authored and dboltovskyi committed May 19, 2019
1 parent cfb26a8 commit 7fc419c
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---------------------------------------------------------------------------------------------------
-- Proposal:
-- https://github.com/smartdevicelink/sdl_evolution/blob/master/proposals/0199-Adding-GPS-Shift-support.md
-- Description:
-- In case:
-- 1) Mobile sends GetInteriorVehicleData request with subscribe=true
-- 2) SDL transfers this request to HMI
-- 3) HMI sends "shifted" item in "stationLocation" parameter of "moduleData" parameter of GetInteriorVehicleData
-- response
-- 4) Mobile sends another GetInteriorVehicleData request without subscribe parameter
-- SDL does:
-- 1) Cut all parameters except longitudeDegrees, latitudeDegrees, altitude from stationLocation and
-- send GetInteriorVehicleData response to mobile without "shifted" item in "stationLocation" structure of
-- "moduleData" parameter for the first request
-- 2) Send a GetInteriorVehicleData response without "shifted" item for the second request
---------------------------------------------------------------------------------------------------
--[[ Required Shared libraries ]]
local runner = require('user_modules/script_runner')
local common = require('test_scripts/API/VehicleData/GpsShiftSupport/commonGpsShift')
local commonRC = require("test_scripts/RC/commonRC")

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

-- [[ Local Functions ]]
local function getInteriorVehicleData(pShiftValue)
common.radioData.radioControlData.sisData.stationLocation.shifted = pShiftValue
local cid = common.getMobileSession():SendRPC("GetInteriorVehicleData", {
moduleType = "RADIO",
subscribe = true
})
EXPECT_HMICALL("RC.GetInteriorVehicleData", {
moduleType = "RADIO"
})
:Do(function(_, data)
common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {
moduleData = common.radioData,
isSubscribed = true
})
end)

local expectedRadioData = common.cloneTable(common.radioData)
expectedRadioData.radioControlData.sisData.stationLocation.shifted = nil
common.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS",
isSubscribed = true,
moduleData = expectedRadioData
})
:ValidIf(function(_, data)
return common.checkShifted(data.payload.moduleData.radioControlData.sisData.stationLocation.shifted, nil)
end)
end

local function getInteriorVehicleDataSubscribed()
local cid = common.getMobileSession():SendRPC("GetInteriorVehicleData", {
moduleType = "RADIO"
})
EXPECT_HMICALL("RC.GetInteriorVehicleData", {
moduleType = "RADIO"
})
:Times(0)

local expectedRadioData = common.cloneTable(common.radioData)
expectedRadioData.radioControlData.sisData.stationLocation.shifted = nil
common.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS",
moduleData = expectedRadioData
})
:ValidIf(function(_, data)
return common.checkShifted(data.payload.moduleData.radioControlData.sisData.stationLocation.shifted, nil)
end)
end

--[[ Scenario ]]
runner.Title("Preconditions")
runner.Step("Clean environment", commonRC.preconditions)
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
runner.Step("Register App", common.registerAppWOPTU)
runner.Step("Activate App", common.activateApp)

runner.Title("Test")
runner.Step("GetInteriorVehicleData subscription RADIO module, shifted true", getInteriorVehicleData, { true })
runner.Step("GetInteriorVehicleData RADIO module subscribed, without shifted", getInteriorVehicleDataSubscribed)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)
1 change: 1 addition & 0 deletions test_sets/gps_shift_support.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
./test_scripts/API/VehicleData/GpsShiftSupport/006_GetInteriorVehicleData_stationLocation_without_shift.lua
./test_scripts/API/VehicleData/GpsShiftSupport/007_OnInteriorVehicleData_stationLocation_shift.lua
./test_scripts/API/VehicleData/GpsShiftSupport/008_OnInteriorVehicleData_stationLocation_without_shift.lua
./test_scripts/API/VehicleData/GpsShiftSupport/009_GetInteriorVehicleData_stationLocation_shift_after_subscription.lua

0 comments on commit 7fc419c

Please sign in to comment.