Skip to content

Commit f1eb5a8

Browse files
authored
Merge pull request #1745 from dboltovskyi/feature/lmn_additional_scripts
LMN: Add additional scripts on transferring HMI codes
2 parents 26c3f04 + 56c0a8b commit f1eb5a8

5 files changed

Lines changed: 430 additions & 14 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---------------------------------------------------------------------------------------------------
2+
-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/25
3+
-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/embedded_navi/Get%20Destination_and_Waypoints.md
4+
-- Item: Use Case 1: Main flow
5+
--
6+
-- Requirement summary:
7+
-- [GetWayPoints] As a mobile app I want to send a request to get the details of the destination
8+
-- and waypoints set on the system so that I can get last mile connectivity.
9+
--
10+
-- Description:
11+
-- In case:
12+
-- 1) Mobile application requests to get details of the destination and waypoints set on the system
13+
-- so that it can provide last mile connectivity.
14+
-- SDL must:
15+
-- 1) SDL transfers the request with valid and allowed parameters to HMI
16+
-- 2) SDL receives response from HMI
17+
-- 3) SDL transfers response to mobile application
18+
19+
---------------------------------------------------------------------------------------------------
20+
--[[ Required Shared libraries ]]
21+
local runner = require('user_modules/script_runner')
22+
local common = require('test_scripts/API/Navigation/commonNavigation')
23+
24+
--[[ Local Variables ]]
25+
local resultCodes = {
26+
success = common.getSuccessResultCodes("GetWayPoints"),
27+
failure = common.getFailureResultCodes("GetWayPoints"),
28+
unexpected = common.getUnexpectedResultCodes("GetWayPoints"),
29+
unmapped = common.getUnmappedResultCodes("GetWayPoints")
30+
}
31+
32+
local params = {
33+
wayPointType = "ALL"
34+
}
35+
36+
local validResponse = {
37+
wayPoints = {
38+
{
39+
coordinate =
40+
{
41+
latitudeDegrees = 0,
42+
longitudeDegrees = 0
43+
},
44+
locationName = "Home",
45+
addressLines = { "Odessa", "Street" }
46+
}
47+
}
48+
}
49+
50+
--[[ Local Functions ]]
51+
local function getWayPointsSuccess(pResultCodeMap, self)
52+
local cid = self.mobileSession1:SendRPC("GetWayPoints", params)
53+
54+
validResponse.appID = common.getHMIAppId()
55+
EXPECT_HMICALL("Navigation.GetWayPoints", params)
56+
:ValidIf(function(_, data)
57+
return data.params.appID == common.getHMIAppId()
58+
end)
59+
:Do(function(_,data)
60+
self.hmiConnection:SendResponse(data.id, data.method, pResultCodeMap.hmi, validResponse)
61+
end)
62+
self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = pResultCodeMap.mobile })
63+
end
64+
65+
local function getWayPointsUnsuccess(pResultCodeMap, self)
66+
local cid = self.mobileSession1:SendRPC("GetWayPoints", params)
67+
68+
EXPECT_HMICALL("Navigation.GetWayPoints", params)
69+
:ValidIf(function(_, data)
70+
return data.params.appID == common.getHMIAppId()
71+
end)
72+
:Do(function(_,data)
73+
self.hmiConnection:SendError(data.id, data.method, pResultCodeMap.hmi, "Error error")
74+
end)
75+
76+
self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = pResultCodeMap.mobile })
77+
:ValidIf(function(_,data)
78+
if not data.payload.info then
79+
return false, "SDL doesn't resend info parameter to mobile App"
80+
end
81+
return true
82+
end)
83+
end
84+
85+
local function getWayPointsUnexpected(pResultCodeMap, self)
86+
local cid = self.mobileSession1:SendRPC("GetWayPoints", params)
87+
88+
EXPECT_HMICALL("Navigation.GetWayPoints", params)
89+
:ValidIf(function(_, data)
90+
return data.params.appID == common.getHMIAppId()
91+
end)
92+
:Do(function(_,data)
93+
if pResultCodeMap.success then
94+
validResponse.appID = common.getHMIAppId()
95+
self.hmiConnection:SendResponse(data.id, data.method, pResultCodeMap.hmi, validResponse)
96+
else
97+
self.hmiConnection:SendError(data.id, data.method, pResultCodeMap.hmi, "Error error")
98+
end
99+
end)
100+
101+
self.mobileSession1:ExpectResponse(cid, { success = pResultCodeMap.success, resultCode = pResultCodeMap.mobile })
102+
end
103+
104+
--[[ Scenario ]]
105+
runner.Title("Preconditions")
106+
runner.Step("Clean environment", common.preconditions)
107+
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
108+
runner.Step("RAI, PTU", common.registerAppWithPTU)
109+
runner.Step("Activate App", common.activateApp)
110+
111+
runner.Title("Test")
112+
runner.Step("Result Codes", common.printResultCodes, { resultCodes })
113+
114+
runner.Title("Successful codes")
115+
for _, item in pairs(resultCodes.success) do
116+
runner.Step("GetWayPoints with " .. item.hmi .. " resultCode", getWayPointsSuccess, { item })
117+
end
118+
119+
runner.Title("Erroneous codes")
120+
for _, item in pairs(resultCodes.failure) do
121+
runner.Step("GetWayPoints with " .. item.hmi .. " resultCode", getWayPointsUnsuccess, { item })
122+
end
123+
124+
runner.Title("Unexpected codes")
125+
for _, item in pairs(resultCodes.unexpected) do
126+
runner.Step("GetWayPoints with " .. item.hmi .. " resultCode", getWayPointsUnexpected, { item })
127+
end
128+
129+
runner.Title("Postconditions")
130+
runner.Step("Stop SDL", common.postconditions)
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---------------------------------------------------------------------------------------------------
2+
-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/26
3+
-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/embedded_navi/Subscribe_to_Destination_and_Waypoints.md
4+
-- Item: Use Case 1: Main Flow
5+
--
6+
-- Requirement summary:
7+
-- [SubscribeWayPoints] As a mobile app I want to be able to subscribe on notifications about
8+
-- any changes to the destination or waypoints.
9+
--
10+
-- Description:
11+
-- In case:
12+
-- 1) mobile application sent valid and allowed by Policies SubscribeWayPoints_request to SDL
13+
--
14+
-- SDL must:
15+
-- 1) transfer SubscribeWayPoints_request_ to HMI
16+
-- 2) respond with <resultCode> received from HMI to mobile app
17+
18+
---------------------------------------------------------------------------------------------------
19+
--[[ Required Shared libraries ]]
20+
local runner = require('user_modules/script_runner')
21+
local common = require('test_scripts/API/Navigation/commonNavigation')
22+
local events = require("events")
23+
24+
--[[ Local Variables ]]
25+
local isSubscribed = false
26+
local resultCodes = {
27+
success = common.getSuccessResultCodes("SubscribeWayPoints"),
28+
failure = common.getFailureResultCodes("SubscribeWayPoints"),
29+
unexpected = common.getUnexpectedResultCodes("SubscribeWayPoints"),
30+
unmapped = common.getUnmappedResultCodes("SubscribeWayPoints")
31+
}
32+
33+
--[[ Local Functions ]]
34+
local function unsubscribeWayPoints(self)
35+
local event = events.Event()
36+
event.matches = function(e1, e2) return e1 == e2 end
37+
local ret = EXPECT_EVENT(event, "Precondition event")
38+
if isSubscribed then
39+
local cid = self.mobileSession1:SendRPC("UnsubscribeWayPoints", {})
40+
EXPECT_HMICALL("Navigation.UnsubscribeWayPoints")
41+
:Do(function(_,data)
42+
self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
43+
end)
44+
self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
45+
:Do(function(_, data)
46+
if data.payload.success then isSubscribed = false end
47+
RAISE_EVENT(event, event, "Precondition event")
48+
end)
49+
else
50+
local function raise_event()
51+
RAISE_EVENT(event, event, "Precondition event")
52+
end
53+
RUN_AFTER(raise_event, 100)
54+
end
55+
return ret
56+
end
57+
58+
local function subscribeWayPointsSuccess(pResultCodeMap, self)
59+
unsubscribeWayPoints(self)
60+
:Do(function()
61+
local cid = self.mobileSession1:SendRPC("SubscribeWayPoints", {})
62+
EXPECT_HMICALL("Navigation.SubscribeWayPoints")
63+
:Do(function(_,data)
64+
self.hmiConnection:SendResponse(data.id, data.method, pResultCodeMap.hmi, {})
65+
end)
66+
self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = pResultCodeMap.mobile })
67+
:Do(function(_, data)
68+
if data.payload.success then isSubscribed = true end
69+
end)
70+
end)
71+
end
72+
73+
local function subscribeWayPointsUnsuccess(pResultCodeMap, self)
74+
unsubscribeWayPoints(self)
75+
:Do(function()
76+
local cid = self.mobileSession1:SendRPC("SubscribeWayPoints", {})
77+
EXPECT_HMICALL("Navigation.SubscribeWayPoints")
78+
:Do(function(_,data)
79+
self.hmiConnection:SendError(data.id, data.method, pResultCodeMap.hmi, "Error error")
80+
end)
81+
82+
self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = pResultCodeMap.mobile })
83+
:ValidIf(function(_,data)
84+
if not data.payload.info then
85+
return false, "SDL doesn't resend info parameter to mobile App"
86+
end
87+
return true
88+
end)
89+
:Do(function(_, data)
90+
if data.payload.success then isSubscribed = true end
91+
end)
92+
end)
93+
end
94+
95+
local function subscribeWayPointsUnexpected(pResultCodeMap, self)
96+
unsubscribeWayPoints(self)
97+
:Do(function()
98+
local cid = self.mobileSession1:SendRPC("SubscribeWayPoints", {})
99+
100+
EXPECT_HMICALL("Navigation.SubscribeWayPoints")
101+
:Do(function(_,data)
102+
if pResultCodeMap.success then
103+
self.hmiConnection:SendResponse(data.id, data.method, pResultCodeMap.hmi, {})
104+
else
105+
self.hmiConnection:SendError(data.id, data.method, pResultCodeMap.hmi, "Error error")
106+
end
107+
end)
108+
109+
self.mobileSession1:ExpectResponse(cid, { success = pResultCodeMap.success, resultCode = pResultCodeMap.mobile })
110+
:Do(function(_, data)
111+
if data.payload.success then isSubscribed = true end
112+
end)
113+
end)
114+
end
115+
116+
--[[ Scenario ]]
117+
runner.Title("Preconditions")
118+
runner.Step("Clean environment", common.preconditions)
119+
runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start)
120+
runner.Step("RAI, PTU", common.registerAppWithPTU)
121+
runner.Step("Activate App", common.activateApp)
122+
123+
runner.Title("Test")
124+
runner.Step("Result Codes", common.printResultCodes, { resultCodes })
125+
126+
runner.Title("Successful codes")
127+
for _, item in pairs(resultCodes.success) do
128+
runner.Step("SubscribeWayPoints with " .. item.hmi .. " resultCode", subscribeWayPointsSuccess, { item })
129+
end
130+
131+
runner.Title("Erroneous codes")
132+
for _, item in pairs(resultCodes.failure) do
133+
runner.Step("SubscribeWayPoints with " .. item.hmi .. " resultCode", subscribeWayPointsUnsuccess, { item })
134+
end
135+
136+
runner.Title("Unexpected codes")
137+
for _, item in pairs(resultCodes.unexpected) do
138+
runner.Step("SubscribeWayPoints with " .. item.hmi .. " resultCode", subscribeWayPointsUnexpected, { item })
139+
end
140+
141+
runner.Title("Postconditions")
142+
runner.Step("Stop SDL", common.postconditions)

0 commit comments

Comments
 (0)