diff --git a/test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua b/test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua new file mode 100644 index 0000000000..5bbac853e4 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua @@ -0,0 +1,111 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow +-- +-- Requirement summary: +-- SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters +-- +-- Description: +-- App sends SendLocation with all available parameters. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request with allowed parameters to HMI +-- SDL receives response from HMI +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + :ValidIf (function(_,data) + if data.payload.info then + return false, "SDL sent redundant info parameter to mobile App " + else + return true + end + end) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation - all params", sendLocation, {requestParams}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/002_SendLocation_disallowed_by_policies.lua b/test_scripts/API/Navigation/SendLocation/002_SendLocation_disallowed_by_policies.lua new file mode 100644 index 0000000000..7f0b6bc035 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/002_SendLocation_disallowed_by_policies.lua @@ -0,0 +1,55 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. Request is valid, SendLocation RPC is not allowed by policies +-- 2. SDL responds DISALLOWED, success:false to request +-- +-- Description: +-- App requests SendLocation in different HMI levels +-- +-- Steps: +-- SDL receives SendLocation request in NONE, BACKGROUND, FULL, LIMITED +-- +-- Expected: +-- SDL responds DISALLOWED, success:false in NONE level, SUCCESS, success:true in BACKGROUND, FULL, LIMITED levels +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +--[[ Local Functions ]] +local function ptuUpdateFuncDissalowedRPC(tbl) + local SendLocstionRpcs = tbl.policy_table.functional_groupings["SendLocation"].rpcs + if SendLocstionRpcs["SendLocation"] then SendLocstionRpcs["SendLocation"] = nil end +end + +--[[ Local Functions ]] +local function sendLocationDisallowed(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "DISALLOWED" }) + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU, { "1", ptuUpdateFuncDissalowedRPC }) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation_rpc_disallowed", sendLocationDisallowed, { requestParams }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/003_SendLocation_without_address.lua b/test_scripts/API/Navigation/SendLocation/003_SendLocation_without_address.lua new file mode 100644 index 0000000000..03088dcc94 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/003_SendLocation_without_address.lua @@ -0,0 +1,96 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Alternative flow 2) +-- +-- Requirement summary: +-- App requests SendLocation without address and with longitudeDegrees, latitudeDegrees, deliveryMode +-- and other valid and allowed parameters +-- +-- Description: +-- SDL transfers the SendLocation requests without address to HMI + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request with allowed parameters to HMI +-- SDL receives response from HMI +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + :ValidIf (function(_,data) + if data.payload.info then + return false, "SDL sent redundant info parameter to mobile App " + else + return true + end + end) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation without address parameter", sendLocation, {requestParams}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/004_SendLocation_wo_mandatory.lua b/test_scripts/API/Navigation/SendLocation/004_SendLocation_wo_mandatory.lua new file mode 100644 index 0000000000..8925412efd --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/004_SendLocation_wo_mandatory.lua @@ -0,0 +1,107 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Alternative flow 2) +-- +-- Requirement summary: +-- App requests SendLocation with address, deliveryMode, other parameters +-- and without longitudeDegrees or latitudeDegrees or without both longitudeDegrees and latitudeDegrees +-- +-- Description: +-- App sends SendLocation without longitudeDegrees or latitudeDegrees parameters. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL respond to the App with resultCode=INVALID_DATA, success=false + +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, parametersToCut, self) + for _,paramToCutOff in pairs(parametersToCut) do + params[paramToCutOff] = nil + end + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "INVALID_DATA" }) + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation witout mandatory longitudeDegrees", sendLocation, {requestParams, {"longitudeDegrees"}}) +runner.Step("SendLocation witout mandatory latitudeDegrees", sendLocation, {requestParams, {"latitudeDegrees"}}) +runner.Step("SendLocation witout both mandatory params", + sendLocation, + {requestParams, {"longitudeDegrees", "latitudeDegrees"}}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/005_SendLocation_wo_mandatory_with_deliveryMode.lua b/test_scripts/API/Navigation/SendLocation/005_SendLocation_wo_mandatory_with_deliveryMode.lua new file mode 100644 index 0000000000..49961a252f --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/005_SendLocation_wo_mandatory_with_deliveryMode.lua @@ -0,0 +1,97 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Alternative flow 3) +-- +-- Requirement summary: +-- App requests SendLocation with deliveryMode, other valid and allowed parameters +-- and without address, latitudeDegrees and longitudeDegrees +-- +-- Description: +-- App sends SendLocation without addrress, longitudeDegrees or latitudeDegrees parameters. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL respond to the App with resultCode=INVALID_DATA, success=false + +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, parametersToCut, self) + for _,paramToCutOff in pairs(parametersToCut) do + params[paramToCutOff] = nil + end + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "INVALID_DATA" }) + + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation witout mandatory longitudeDegrees", sendLocation, {requestParams, {"longitudeDegrees"}}) +runner.Step("SendLocation witout mandatory latitudeDegrees", sendLocation, {requestParams, {"latitudeDegrees"}}) +runner.Step("SendLocation witout both mandatory params", + sendLocation, + {requestParams, {"longitudeDegrees", "latitudeDegrees"}}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/006_SendLocation_wo_deliveryMode.lua b/test_scripts/API/Navigation/SendLocation/006_SendLocation_wo_deliveryMode.lua new file mode 100644 index 0000000000..1d380211ea --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/006_SendLocation_wo_deliveryMode.lua @@ -0,0 +1,112 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Alternative flow 4) +-- +-- Requirement summary: +-- App requests SendLocation without deliveryMode and with other allowed and valid parameters +-- +-- Description: +-- App sends SendLocation will all available valid parameters except deliveryMode. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request with allowed parameters to HMI +-- SDL receives response from HMI +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" + + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + :ValidIf (function(_,data) + if data.payload.info then + print("SDL sent redundant info parameter to mobile App ") + return false + else + return true + end + end) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation - all params", sendLocation, {requestParams}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua b/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua new file mode 100644 index 0000000000..466b24dae3 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua @@ -0,0 +1,112 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 1: invalid types of parameters values) +-- +-- Requirement summary: +-- App requests SendLocation wit one parameter of wrong type, other parameters are valid +-- +-- Description: +-- App sends SendLocation with wrong types of parameters + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- App sends SendLocation with invalid payload (invalid json) + +-- Expected: + +-- SDL validates parameters of the request +-- SDL responds INVALID_DATA, success: false +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params):Times(0) + + self.mobileSession1:ExpectResponse(cid, {success = false, resultCode = "INVALID_DATA"}) + + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +for key,value in pairs(requestParams) do + local parametersToSend = requestParams + local function replaceType(val) + if (type(val) == "string") then + return 5 + else + return "5" + end + end + if (type(value) == "table") then + for subKey,subValue in pairs(value) do + parametersToSend[key][subKey] = replaceType(subValue) + runner.Step("SendLocation-invalid-type-of-" .. tostring(key) .. "-" .. tostring(subKey), + sendLocation, + {parametersToSend}) + end + else + parametersToSend[key] = replaceType(value) + runner.Step("SendLocation-invalid-type-of-" .. tostring(key), sendLocation, {parametersToSend}) + end +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/008_SendLocation_invalid_json.lua b/test_scripts/API/Navigation/SendLocation/008_SendLocation_invalid_json.lua new file mode 100644 index 0000000000..be62243719 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/008_SendLocation_invalid_json.lua @@ -0,0 +1,61 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 1: invalid json) +-- +-- Requirement summary: +-- App requests SendLocation request, but payload is actually corrupted. +-- +-- Description: +-- App sends SendLocation with invalid payload (invalid json) + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- App sends SendLocation with invalid payload (invalid json) + +-- Expected: + +-- SDL validates parameters of the request +-- SDL responds INVALID_DATA, success: false +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Functions ]] +local function sendLocation(self) + self.mobileSession1.correlationId = self.mobileSession1.correlationId + 1 + local msg = { + serviceType = 7, + frameInfo = 0, + rpcType = 0, + rpcFunctionId = 39, + rpcCorrelationId = self.mobileSession1.correlationId, + payload = '{"longitudeDegrees" 1.1, "latitudeDegrees":1.1}' --<<-- Missing ":" + } + self.mobileSession1:Send(msg) + + EXPECT_HMICALL("Navigation.SendLocation"):Times(0) + + self.mobileSession1:ExpectResponse(self.mobileSession1.correlationId, + { success = false, resultCode = "INVALID_DATA"}) + + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation-invalid-Json", sendLocation) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua b/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua new file mode 100644 index 0000000000..80b027a6a8 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua @@ -0,0 +1,149 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (all parameters has boundary values) +-- +-- Requirement summary: +-- App requests SendLocation with boundary values of all parameters +-- +-- Description: +-- App sends SendLocation with boundary values of params + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- App sends SendLocation with invalid payload (invalid json) + +-- Expected: + +-- SDL validates parameters of the request +-- SDL responds INVALID_DATA, success: false +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local maxFileName = string.rep("a", 238) .. ".png" -- 255 reduced to 242 due to docker limitation +local lowerBoundRequest = { + longitudeDegrees = -180.0, + latitudeDegrees = -90.0, + address = { + countryName = "a", + countryCode = "a", + postalCode = "a", + administrativeArea = "a", + subAdministrativeArea = "s", + locality = "a", + subLocality = "s", + thoroughfare = "s", + subThoroughfare = "s" + }, + timeStamp = { + second = 0, + minute = 0, + hour = 0, + day = 1, + month = 1, + year = 0, + tz_hour = -12, + tz_minute = 0 + }, + locationName ="a", + locationDescription ="a", + addressLines = {"a"}, + phoneNumber ="1", + deliveryMode = "PROMPT", + locationImage = + { + value ="a", + imageType ="DYNAMIC", + } +} + +local upperBoundRequest = { + longitudeDegrees = 180.0, + latitudeDegrees = 90.0, + address = { + countryName = string.rep("a", 200), + countryCode = string.rep("a", 50), + postalCode = string.rep("a", 16), + administrativeArea = string.rep("a", 200), + subAdministrativeArea = string.rep("a", 200), + locality = string.rep("a", 200), + subLocality = string.rep("a", 200), + thoroughfare = string.rep("a", 200), + subThoroughfare = string.rep("a", 200) + }, + timeStamp = { + second = 60, + minute = 59, + hour = 23, + day = 31, + month = 12, + year = 4095, + tz_hour = 14, + tz_minute = 59 + }, + locationName =string.rep("a", 500), + locationDescription = string.rep("a", 500), + addressLines = { + string.rep("a", 500), + string.rep("a", 500), + string.rep("a", 500), + string.rep("a", 500) + }, + phoneNumber =string.rep("a", 500), + deliveryMode = "PROMPT", + locationImage = + { + value = maxFileName, + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + local mobileImageValue = params.locationImage.value + params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/" .. mobileImageValue + + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + :ValidIf (function(_,data) + if data.payload.info then + print("SDL sent redundant info parameter to mobile App ") + return false + else + return true + end + end) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file with lower bound name", commonSendLocation.putFile, {"a"}) +runner.Step("Upload file with upper bound name", commonSendLocation.putFile, {maxFileName}) + +runner.Title("Test") +runner.Step("SendLocation-lower-bound-of-all-params", sendLocation, {lowerBoundRequest}) +runner.Step("SendLocation-upper-bound-of-all-params", sendLocation, {upperBoundRequest}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/010_SendLocation_out_of_bound.lua b/test_scripts/API/Navigation/SendLocation/010_SendLocation_out_of_bound.lua new file mode 100644 index 0000000000..35e1e3c60a --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/010_SendLocation_out_of_bound.lua @@ -0,0 +1,102 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 1: out of bounds) +-- +-- Requirement summary: +-- App requests SendLocation with some value that is out of bound +-- +-- Description: +-- App sends SendLocation with invalid value of parameter + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- App sends SendLocation with invalid payload (invalid json) + +-- Expected: + +-- SDL validates parameters of the request +-- SDL responds INVALID_DATA, success: false +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local outOfBoundLongitude = {-180.1, 180.1} +local outOfBoundLatitude = {-90.1, 90.1} + +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT" +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params):Times(0) + + self.mobileSession1:ExpectResponse(cid, {success = false, resultCode = "INVALID_DATA"}) + + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test - out of bound of longitudeDegrees") +for _, value in pairs(outOfBoundLongitude) do + local paramsToSend = requestParams + paramsToSend.longitudeDegrees = value + runner.Step("SendLocation - longitudeDegrees: " .. tostring(value), sendLocation, {paramsToSend}) +end + +runner.Title("Test - out of bound of latitudeDegrees") +for _, value in pairs(outOfBoundLatitude) do + local paramsToSend = requestParams + paramsToSend.latitudeDegrees = value + runner.Step("SendLocation - latitudeDegrees: " .. tostring(value), sendLocation, {paramsToSend}) +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/011_SendLocation_whitespaces.lua b/test_scripts/API/Navigation/SendLocation/011_SendLocation_whitespaces.lua new file mode 100644 index 0000000000..8635082277 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/011_SendLocation_whitespaces.lua @@ -0,0 +1,105 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 1: empty strings or whitespace as only symbol in string parameter) +-- +-- Requirement summary: +-- App requests SendLocation where string parameters are empty or with whitespaces +-- +-- Description: +-- App sends SendLocation with invalid payload (invalid json) + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- App sends SendLocation where string parameters are empty or with whitespaces + +-- Expected: + +-- SDL validates parameters of the request +-- SDL responds INVALID_DATA, success: false +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local stringParams = { + address = { + countryName = "a", + countryCode = "a", + postalCode = "a", + administrativeArea = "a", + subAdministrativeArea = "s", + locality = "a", + subLocality = "s", + thoroughfare = "s", + subThoroughfare = "s" + }, + locationName ="a", + locationDescription ="a", + addressLines = {"hello"}, + phoneNumber ="123456789", + locationImage = + { + value ="icon.png", + } +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + params["longitudeDegrees"] = 60 + params["latitudeDegrees"] = 60 + params["deliveryMode"] = "PROMPT" + params["locationImage"]["imageType"] = "DYNAMIC" + + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation"):Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "INVALID_DATA"}) + + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test - empty strings") +for key,value in pairs(stringParams) do + local parametersToSend = stringParams + if (type(value) == "table") then + for subKey,_ in pairs(value) do + parametersToSend[key][subKey] = "" + runner.Step("SendLocation-invalid-type-of-" .. tostring(subKey), sendLocation, {parametersToSend}) + end + else + parametersToSend[key] = "" + runner.Step("SendLocation-invalid-type-of-" .. tostring(key), sendLocation, {parametersToSend}) + end +end + +runner.Title("Test - whitespaces") +for key,value in pairs(stringParams) do + local parametersToSend = stringParams + if (type(value) == "table") then + for subKey,_ in pairs(value) do + parametersToSend[key][subKey] = " " + runner.Step("SendLocation-invalid-type-of-" .. tostring(subKey), sendLocation, {parametersToSend}) + end + else + parametersToSend[key] = " " + runner.Step("SendLocation-invalid-type-of-" .. tostring(key), sendLocation, {parametersToSend}) + end +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/012_SendLocation_cut_off_address.lua b/test_scripts/API/Navigation/SendLocation/012_SendLocation_cut_off_address.lua new file mode 100644 index 0000000000..86c2fbca31 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/012_SendLocation_cut_off_address.lua @@ -0,0 +1,110 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 2) +-- +-- Requirement summary: +-- Cut off parameter "address" from request to HMI in case it is empty +-- +-- Description: +-- App sends SendLocation with empty address parameter. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request without address parameter to HMI +-- SDL receives response from HMI +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local request_params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = {}, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function send_location(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" + + + EXPECT_HMICALL("Navigation.SendLocation") + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + :ValidIf(function (_, data) + if (data.params.address ~= nil) then + self:FailTestCase("address is present in SDL's request") + else + return true + end + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + :ValidIf (function(_,data) + if data.payload.info then + print("SDL sent redundant info parameter to mobile App ") + return false + else + return true + end + end) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation - all params", send_location, { request_params }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/013_SendLocation_unsupported_resource.lua b/test_scripts/API/Navigation/SendLocation/013_SendLocation_unsupported_resource.lua new file mode 100644 index 0000000000..4f889f0514 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/013_SendLocation_unsupported_resource.lua @@ -0,0 +1,81 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 3) +-- +-- Requirement summary: +-- UNSUPPORTED_RESOURCE in case Navi interface is not available on HMI +-- +-- Description: +-- App sends SendLocation will valid parameters but actually Navigation interface is unsupported. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request with allowed parameters to HMI +-- SDL receives response from HMI +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') +local hmi_values = require('user_modules/hmi_values') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode" + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT" +} + +--[[ Local Functions ]] +local function disableNavigationInterface() + local params = hmi_values.getDefaultHMITable() + params.Navigation.IsReady.params.available = false + return params +end + +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params):Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "UNSUPPORTED_RESOURCE"}) + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start, {disableNavigationInterface()}) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation - Navigation is not available/supported", sendLocation, {requestParams}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/014_SendLocation_unsupported_capability.lua b/test_scripts/API/Navigation/SendLocation/014_SendLocation_unsupported_capability.lua new file mode 100644 index 0000000000..1ccb35ed04 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/014_SendLocation_unsupported_capability.lua @@ -0,0 +1,79 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 4) +-- +-- Requirement summary: +-- UNSUPPORTED_RESOURCE in case sendLocation is unsupported while Navigation interface is available on HMI +-- +-- Description: +-- App sends SendLocation will valid parameters but actually Navigation interface is unsupported. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request with allowed parameters to HMI +-- SDL receives response from HMI +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') +local hmi_values = require('user_modules/hmi_values') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode" + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT" +} + +--[[ Local Functions ]] +local function disableSendLocationCapability() + local params = hmi_values.getDefaultHMITable() + params.UI.GetCapabilities.params.systemCapabilities.navigationCapability.sendLocationEnabled = false + return params +end + +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + EXPECT_HMICALL("Navigation.SendLocation", params):Times(0) + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "UNSUPPORTED_RESOURCE"}) + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start, {disableSendLocationCapability()}) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation - Navigation is not available/supported", sendLocation, {requestParams}) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/015_SendLocation_with_mandatory_params_and_disallowed_deliveryMode.lua b/test_scripts/API/Navigation/SendLocation/015_SendLocation_with_mandatory_params_and_disallowed_deliveryMode.lua new file mode 100644 index 0000000000..10b3d02dac --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/015_SendLocation_with_mandatory_params_and_disallowed_deliveryMode.lua @@ -0,0 +1,74 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Alternative flow 3) +-- +-- Requirement summary: +-- App requests SendLocation with deliveryMode, other valid and allowed parameters +-- and without address, latitudeDegrees and longitudeDegrees +-- +-- Description: +-- App sends SendLocation without addrress, longitudeDegrees or latitudeDegrees parameters. + +-- In case: +-- 1) mobile application sends SendLocation_request +-- 2) with “deliveryMode” parameter and other valid and allowed parameters +-- 3) and “deliveryMode” parameter is NOT allowed by Policies +-- +-- SDL must: +-- 1) cut off "deliveryMode" parameter from SendLocation request +-- 2) transfer SendLocation without "deliveryMode" parameter to HMI +-- 3) respond with to mobile app with added info: +-- "default value of delivery mode will be used" +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + deliveryMode = "PROMPT", +} + +local disallowedParams = { "deliveryMode" } + +--[[ Local Functions ]] +local function sendLocation(self) + local mobileSession = commonSendLocation.getMobileSession(self, 1) + local cid = self.mobileSession1:SendRPC("SendLocation", requestParams) + EXPECT_HMICALL("Navigation.SendLocation", { longitudeDegrees = 1.1, latitudeDegrees = 1.1 }) + :Do(function(_, data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", + { longitudeDegrees = 1.1, latitudeDegrees = 1.1 }) + end) + :ValidIf(function(_, data) + if data.params.deliveryMode then + return false, "Parameter 'deliveryMode' is not expected" + end + return true + end) + mobileSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS", + info = "default value of delivery mode will be used" }) +end + +local function pUpdateFunction(pTbl) + local params = pTbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters + commonSendLocation.filterTable(params, disallowedParams) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU, { 1, pUpdateFunction }) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, { "icon.png" }) + +runner.Title("Test") +runner.Step("SendLocation with both mandatory params and disallowed: deliveryMode", sendLocation) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/016_SendLocation_with_mandatory_params_allowed_and_disallowed_locationName_deliveryMode.lua b/test_scripts/API/Navigation/SendLocation/016_SendLocation_with_mandatory_params_allowed_and_disallowed_locationName_deliveryMode.lua new file mode 100644 index 0000000000..9dddcd297e --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/016_SendLocation_with_mandatory_params_allowed_and_disallowed_locationName_deliveryMode.lua @@ -0,0 +1,83 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Alternative flow 3) +-- +-- Requirement summary: +-- App requests SendLocation with deliveryMode, other valid and allowed parameters +-- and without address, latitudeDegrees and longitudeDegrees +-- +-- Description: +-- App sends SendLocation without addrress, longitudeDegrees or latitudeDegrees parameters. + +-- In case: +-- 1) mobile application sends SendLocation_request with: +-- 2) one or more requested parameters allowed by Policies +-- 3) one or more requested parameters disallowed by Policies +-- 4) and this request is allowed by Policies for this mobile application +-- +-- SDL must: +-- 1) transfer SendLocation with allowed parameters only to HMI +-- 2) respond with + success: (true OR false) + info: +-- " , parameters are disallowed by Policies" +-- NOTE: +-- in case with disallowed "deliveryMode" SDL must add to info also: "default value of deliveryMode will be used" +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + deliveryMode = "PROMPT", + locationName = "1 American Rd" +} + +local disallowedParams = { "deliveryMode", "locationName" } + +--[[ Local Functions ]] +local function sendLocation(self) + local mobileSession = commonSendLocation.getMobileSession(self, 1) + local cid = self.mobileSession1:SendRPC("SendLocation", requestParams) + EXPECT_HMICALL("Navigation.SendLocation", { longitudeDegrees = 1.1, latitudeDegrees = 1.1 }) + :Do(function(_, data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", + { longitudeDegrees = 1.1, latitudeDegrees = 1.1 }) + end) + :ValidIf(function(_, data) + local notExpParams = {} + for _, p in pairs(disallowedParams) do + if data.params[p] then + table.insert(notExpParams, p) + end + end + if #notExpParams > 0 then + return false, "Parameters [" .. table.concat(notExpParams, ", ") .. "] are not expected" + end + return true + end) + mobileSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS", + info = "default value of delivery mode will be used, 'locationName' parameter is disallowed by Policies" }) +end + +local function pUpdateFunction(pTbl) + local params = pTbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters + commonSendLocation.filterTable(params, disallowedParams) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU, { 1, pUpdateFunction }) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation with both mandatory params and 2 disallowed:locationName and deliveryMode", sendLocation) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua b/test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua new file mode 100644 index 0000000000..55942a9db4 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua @@ -0,0 +1,84 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- In case mobile application sends valid SendLocation request, SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +-- +-- Description: +-- App sends SendLocation request with duplicated correlation ID +-- +-- Steps: +-- mobile app requests SendLocation with duplicated correlation ID +-- +-- Expected: +-- SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + print("MOB->SDL: RQ1" ) + + params.appID = commonSendLocation.getHMIAppId() + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(exp,data) + print("SDL->HMI: RQ" .. exp.occurences) + local function request2() + print("MOB->SDL: RQ2") + local msg = { + serviceType = 7, + frameInfo = 0, + rpcType = 0, + rpcFunctionId = 39, + rpcCorrelationId = cid, + payload = '{"longitudeDegrees":1.1, "latitudeDegrees":1.1}' + } + self.mobileSession1:Send(msg) + end + if exp.occurences == 1 then + RUN_AFTER(request2, 500) + end + local function response() + print("HMI->SDL: RS" .. exp.occurences) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end + RUN_AFTER(response, 100) + end) + :Times(2) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + :Times(2) + :Do(function(exp) + print("SDL->MOB: RS" .. exp.occurences) + end) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation_duplicated_correlation_id", sendLocation, { requestParams }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/018_SendLocation_MandatoryOnly_Float.lua b/test_scripts/API/Navigation/SendLocation/018_SendLocation_MandatoryOnly_Float.lua new file mode 100644 index 0000000000..9f48b26251 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/018_SendLocation_MandatoryOnly_Float.lua @@ -0,0 +1,60 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- In case mobile application sends valid SendLocation request, SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +-- +-- Description: +-- App sends SendLocation request with only mandatory parameters with float values. +-- +-- Steps: +-- mobile app requests SendLocation with mandatory parameters longitudeDegrees, latitudeDegrees with float values +-- +-- Expected: +-- SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local request_params = { + longitudeDegrees = 1.1111111, + latitudeDegrees = 1.1111111 +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +--[[ Test ]] +runner.Title("Test") +runner.Step("SendLocation - mandatory only - float values", sendLocation, { request_params }) + +--[[ Postconditions ]] +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/019_SendLocation_MandatoryOnly_Int.lua b/test_scripts/API/Navigation/SendLocation/019_SendLocation_MandatoryOnly_Int.lua new file mode 100644 index 0000000000..b16433fd9e --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/019_SendLocation_MandatoryOnly_Int.lua @@ -0,0 +1,60 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- In case mobile application sends valid SendLocation request, SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +-- +-- Description: +-- App sends SendLocation request with only mandatory parameters with int values. +-- +-- Steps: +-- mobile app requests SendLocation with mandatory parameters longitudeDegrees, latitudeDegrees with int values +-- +-- Expected: +-- SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local request_params = { + longitudeDegrees = 1, + latitudeDegrees = 1 +} + +--[[ Local Functions ]] +local function send_location(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + params.appID = commonSendLocation.getHMIAppId() + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +--[[ Test ]] +runner.Title("Test") +runner.Step("SendLocation - mandatory only - int values", send_location, { request_params }) + +--[[ Postconditions ]] +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua b/test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua new file mode 100644 index 0000000000..a13904a55f --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua @@ -0,0 +1,272 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- In case mobile application sends valid SendLocation request, SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +-- +-- Description: +-- App sends SendLocation request with boundary value of parameters. +-- +-- Steps: +-- mobile app requests SendLocation with lower and upper bound value of parameters +-- +-- Expected: +-- SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') +local commonFunctions = require('user_modules/shared_testcases/commonFunctions') + +--[[ Local Variables ]] +local maxAdressLinesArraySize = 4 +local string500Char = string.rep("a", 500) +local string255Char = string.rep("a", 255) +local string200Char = string.rep("a", 200) + +local maxFileName = string.rep("a", 238) .. ".png" -- 255 reduced to 242 due to docker limitation + +local request_params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +local addressLinesArrayUpperBoundSize = {} +for i=1,maxAdressLinesArraySize do + addressLinesArrayUpperBoundSize[i] = "some string" +end +local addressLinesArrayUpperBoundSizeValue = {} +for i=1,maxAdressLinesArraySize do + addressLinesArrayUpperBoundSizeValue[i] = string500Char +end + +local DateTimeParams = +{ + millisecond = {lower = 0, upper = 999}, + second = {lower = 0, upper = 60}, + minute = {lower = 0, upper = 59}, + hour = {lower = 0, upper = 23}, + day = {lower = 1, upper = 31}, + month = {name = "month", lower = 1, upper = 12}, + --According to comfirmed information before 'should not be any min value specified', + -- so as min value specified negative value to check correct processing value not from positive range. + year = {lower = -1, upper = 4095}, + tz_hour = {lower = -12, upper = 14}, + tz_minute = {lower = 0, upper = 59}, +} + +local addressParams = +{ + "countryName", + "countryCode", + "postalCode", + "administrativeArea", + "subAdministrativeArea", + "locality", + "subLocality", + "thoroughfare", + "subThoroughfare", +} + +local boundValues ={ + longitudeDegrees = {lower = -180, upper = 180}, + latitudeDegrees = {lower = -90, upper = 90}, + locationName = {lower = "a", upper = string500Char}, + locationDescription = {lower = "a", upper = string500Char}, + phoneNumber = {lower = "a", upper = string500Char}, + addressLines = {lower = {"a"}, upper = {string500Char}} +} + +local locationImage = {lower = "a", upper = maxFileName} + +local deliveryModeEnum = { + "PROMPT", + "DESTINATION", + "QUEUE" +} + +--[[ Local Functions ]] +local function sendLocation(parameter, value, self) + local parameters = commonFunctions:cloneTable(request_params) + + parameters[parameter] = value + + local cid = self.mobileSession1:SendRPC("SendLocation", parameters) + + parameters.appID = commonSendLocation.getHMIAppId() + + EXPECT_HMICALL("Navigation.SendLocation", parameters) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + + +local function sendLocationAddress(subParam, value, self) + local parameters = commonFunctions:cloneTable(request_params) + + parameters["address"] = {} + parameters.address[subParam] = value + + local cid = self.mobileSession1:SendRPC("SendLocation", parameters) + + parameters.appID = commonSendLocation.getHMIAppId() + + EXPECT_HMICALL("Navigation.SendLocation", parameters) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + :ValidIf(function(_,data) + local ErrorMessage = "" + local ValidationStatus = true + for _,k in pairs(addressParams) do + if data.params.address[k] and not parameters.address[k] then + ErrorMessage = ErrorMessage .. k .. "\n" + ValidationStatus = false + end + end + + if ValidationStatus == false then + return false, "SDL sent redundant address parameters to HMI:\n" .. ErrorMessage + else + return true + end + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +local function sendLocationImage(value, self) + local parameters = commonFunctions:cloneTable(request_params) + + parameters["locationImage"] = {value = value, imageType = "DYNAMIC"} + + local cid = self.mobileSession1:SendRPC("SendLocation", parameters) + + parameters.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + parameters.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/" ..tostring(value) + + EXPECT_HMICALL("Navigation.SendLocation", parameters) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +local function sendLocationTimeStamp(paramVal, boundValue, self) + local parameters = commonFunctions:cloneTable(request_params) + + parameters.timeStamp = {} + parameters.timeStamp[paramVal] = boundValue + + local cid = self.mobileSession1:SendRPC("SendLocation", parameters) + + parameters.appID = commonSendLocation.getHMIAppId() + + if not parameters.timeStamp["tz_hour"] then + parameters.timeStamp["tz_hour"] = 0 + end + if not parameters.timeStamp["tz_minute"] then + parameters.timeStamp["tz_minute"] = 0 + end + + EXPECT_HMICALL("Navigation.SendLocation", parameters) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + :ValidIf(function(_,data) + local ErrorMessage = "" + local ValidationStatus = true + for key in pairs(DateTimeParams) do + if data.params.timeStamp[key] and + not parameters.timeStamp[key] then + ErrorMessage = ErrorMessage .. key .. "\n" + ValidationStatus = false + end + end + + if ValidationStatus == false then + return false, "SDL sent redundant address parameters to HMI:\n" .. ErrorMessage + else + return true + end + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"a"}) +runner.Step("Upload file", commonSendLocation.putFile, {maxFileName}) + +--[[ Test ]] +--[[ Lower bound set]] +runner.Title("Test") +runner.Title("Lower bound value") +for key,value in pairs(boundValues) do + runner.Step("SendLocation_lower_" .. tostring(key), sendLocation, + { key, value.lower }) +end + +runner.Step("SendLocation_lower_locationImage", sendLocationImage, + { locationImage.lower }) + +for _, value in pairs(addressParams) do + runner.Step("SendLocation_lower_address_" .. tostring(value), sendLocationAddress, + { value, "a" }) +end + +for key, value in pairs(DateTimeParams) do + runner.Step("SendLocation_lower_timeStamp_" .. tostring(key), sendLocationTimeStamp, + { key, value.lower}) +end + +--[[ Upper bound set]] +runner.Title("Upper bound value") +for key,value in pairs(boundValues) do + runner.Step("SendLocation_upper_" .. tostring(key), sendLocation, + { key, value.upper }) +end + +runner.Step("SendLocation_upper_locationImage", sendLocationImage, + { locationImage.upper }) + +for _, value in pairs(addressParams) do + runner.Step("SendLocation_upper_address_" .. tostring(value), sendLocationAddress, + { value, string200Char }) +end + +for key, value in pairs(DateTimeParams) do + runner.Step("SendLocation_upper_timeStamp_" .. tostring(key), sendLocationTimeStamp, + { key, value.upper}) +end + +runner.Step("SendLocation_address_array_max_size", sendLocation,{ "addressLines", addressLinesArrayUpperBoundSize}) +runner.Step("SendLocation_address_array_max_size_max_value", sendLocation, + { "addressLines", addressLinesArrayUpperBoundSizeValue}) + +for _, value in pairs(deliveryModeEnum) do + runner.Step("SendLocation_deliveryMode_enum_" .. tostring(value), sendLocation, + { "deliveryMode", value}) +end + +--[[ Postconditions ]] +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/021_SendLocation_out_of_bound_values.lua b/test_scripts/API/Navigation/SendLocation/021_SendLocation_out_of_bound_values.lua new file mode 100644 index 0000000000..b48b3dd863 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/021_SendLocation_out_of_bound_values.lua @@ -0,0 +1,191 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. Request is invalid: Wrong json, parameters of wrong type, string parameters with empty values or whitespace as the +-- only symbol, out of bounds, wrong characters, missing mandatory parameters +-- 2. SDL responds INVALID_DATA, success:false +-- +-- Description: +-- App sends SendLocation request with out of bounds values of locationName, locationDescription, addressLines, +-- phoneNumber, locationImage, timeStamp, address, deliveryMode parameters. +-- +-- Steps: +-- mobile app requests SendLocation with out of bounds values +-- +-- Expected: +-- SDL responds INVALID_DATA, success:false +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') +local commonFunctions = require('user_modules/shared_testcases/commonFunctions') + +--[[ Local Variables ]] +local string501char = string.rep ("a", 501) +local string201char = string.rep ("a", 201) +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +local outBoundValuesForStrings = { outLower = "", outUpper = string501char } + +local StringParam = { + "locationName", + "locationDescription", + "addressLines", + "phoneNumber" +} + +local addressParams = { + "countryName", + "countryCode", + "postalCode", + "administrativeArea", + "subAdministrativeArea", + "locality", + "subLocality", + "thoroughfare", + "subThoroughfare" +} + +local DateTimeParams = { + millisecond = { name = "millisecond", outLower = -1, outUpper = 1000 }, + second = { name = "second", outLower = -1, outUpper = 61 }, + minute = { name = "minute", outLower = -1, outUpper = 60 }, + hour = { name = "hour", outLower = -1, outUpper = 24 }, + day = { name = "day", outLower = 0, outUpper = 32 }, + month = { name = "month", outLower = 0, outUpper = 13 }, + year = { name = "year", outUpper = 4096 }, + tz_hour = { name = "tz_hour", outLower = -13, outUpper = 15 }, + tz_minute = { name = "tz_minute", outLower = -1, outUpper = 60 } +} + +local emptyArray = {} +local addressLinesArrayOutUpperBound = {} +for i=1, 5 do + addressLinesArrayOutUpperBound[i] = "a" +end + +--[[ Local Functions ]] +local function sendLocation(parameter, paramValue, self) + local params = commonFunctions:cloneTable(requestParams) + params[parameter] = paramValue + + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "INVALID_DATA" }) + commonSendLocation.delayedExp() +end + +local function sendLocationAddressLines(paramValue, self) + local params = commonFunctions:cloneTable(requestParams) + params.addressLines = paramValue + + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "INVALID_DATA" }) + commonSendLocation.delayedExp() +end + +local function sendLocationTimeStamp(innerParam, paramValue, self) + local params = commonFunctions:cloneTable(requestParams) + params["timeStamp"] = {} + params.timeStamp[innerParam] = paramValue + + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "INVALID_DATA" }) + commonSendLocation.delayedExp() +end + +local function sendLocationAddress(innerParam, paramValue, self) + local params = commonFunctions:cloneTable(requestParams) + params["address"] = {} + params.address[innerParam] = paramValue + + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "INVALID_DATA" }) + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +--[[ Test ]] +--[[ Out lower bound test block ]] +--[[ Parameters: locationName, locationDescription, addressLines, phoneNumber ]] +runner.Title("Test") +runner.Title("Out of lower bound values") +for _, ArrayValue in pairs(StringParam) do + runner.Step("SendLocation_out_lower" .. tostring(ArrayValue), sendLocation, + { ArrayValue, outBoundValuesForStrings.outLower }) +end + +--[[ Parameter: addressLines ]] +runner.Step("SendLocation_addressLines_out_lower_array_value", sendLocationAddressLines, + {{ outBoundValuesForStrings.outLower }}) +runner.Step("SendLocation_addressLines_out_lower_array size", sendLocationAddressLines, + { emptyArray }) + +--[[ Parameter: timeStamp ]] +for _, ArrayValue in pairs(DateTimeParams) do + if ArrayValue.name ~= "year" then + runner.Step("SendLocation_timeStamp_out_lower_" .. tostring(ArrayValue.name), sendLocationTimeStamp, + { ArrayValue.name, ArrayValue.outLower }) + -- check 'year out of lower bound' is ommited because according to corfimmed information before SDL don't have + -- lower bound value and don't process any out of lower bound values of year parameter. + end +end + +--[[ Out upper bound test block ]] +--[[ Parameters: locationName, locationDescription, addressLines, phoneNumber ]] +runner.Title("Out of upper bound values") +for _, ArrayValue in pairs(StringParam) do + runner.Step("SendLocation_out upper" .. tostring(ArrayValue), sendLocation, + { ArrayValue, outBoundValuesForStrings.outUpper }) +end + +--[[ Parameter: addressLines ]] +runner.Step("SendLocation_addressLines_out_upper_array_value", sendLocationAddressLines, + {{ outBoundValuesForStrings.outUpper }}) +runner.Step("SendLocation_addressLines_out_upper_array_size", sendLocationAddressLines, + { addressLinesArrayOutUpperBound }) + +--[[ Parameter: timeStamp ]] +for _, ArrayValue in pairs(DateTimeParams) do + runner.Step("SendLocation_timeStamp_out_upper_" .. tostring(ArrayValue.name), sendLocationTimeStamp, + { ArrayValue.name, ArrayValue.outUpper }) +end + +--[[ Parameter: address ]] +for _, ArrayValue in pairs(addressParams) do + runner.Step("SendLocation_address_out_upper_" .. tostring(ArrayValue), sendLocationAddress, + { ArrayValue, string201char }) +end + +--[[ Parameter: deliveryMode ]] +runner.Step("SendLocation_deliveryMode_out_bound", sendLocation, + { "deliveryMode", "DYNAMIC" }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/022_SendLocation_fake_another_request_params.lua b/test_scripts/API/Navigation/SendLocation/022_SendLocation_fake_another_request_params.lua new file mode 100644 index 0000000000..6a1e89ae44 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/022_SendLocation_fake_another_request_params.lua @@ -0,0 +1,148 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- In case mobile application sends valid SendLocation request, SDL must: +-- 1) transfer Navigation.SendLocation to HMI +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +-- +-- Description: +-- App sends SendLocation request with fake, from another RPC parameters. +-- +-- Steps: +-- mobile app requests SendLocation with fake, from another RPC parameters. +-- +-- Expected: +-- SDL must: +-- 1) transfer Navigation.SendLocation to HMI without fake params +-- 2) on getting Navigation.SendLocation ("SUCCESS") response from HMI, respond with (resultCode: SUCCESS, success:true) +-- to mobile application. +--------------------------------------------------------------------------------------------------- + +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParamsWithFake = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + locationName ="location Name", + locationDescription ="location Description", + addressLines = { + "line1", + "line2" + }, + phoneNumber ="phone Number", + locationImage = { + value ="icon.png", + imageType ="DYNAMIC", + fakeParam ="fakeParam" + }, + fakeParam ="fakeParam", + timeStamp = { + millisecond = 10, + fakeParam ="fakeParam" + } +} + +local requetsParamAnotherRequest = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + locationName ="location Name", + locationDescription ="location Description", + addressLines = { + "line1", + "line2" + }, + phoneNumber ="phone Number", + locationImage = { + value ="icon.png", + imageType ="DYNAMIC", + cmdID = 10 + }, + cmdID = 10, + timeStamp = { + millisecond = 10, + cmdID = 10 + } +} + +local expectedRequestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + locationName ="location Name", + locationDescription ="location Description", + addressLines = { + "line1", + "line2" + }, + phoneNumber ="phone Number", + locationImage = { + value ="icon.png", + imageType ="DYNAMIC" + }, + timeStamp = { + millisecond = 10 + } +} + +--[[ Local Functions ]] +local function sendLocation(params, paramsHMI, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + paramsHMI.appID = commonSendLocation.getHMIAppId() + local deviceID = commonSendLocation.getDeviceMAC() + paramsHMI.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" + .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" + + EXPECT_HMICALL("Navigation.SendLocation", paramsHMI) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + :ValidIf(function(_, data) + local ErrorMessage + local CheckStatus = true + + if + data.params.fakeParam or + data.params.locationImage.fakeParam or + data.params.timeStamp.fakeParam then + ErrorMessage = "SDL sends to HMI fake parameters" + CheckStatus = false + elseif + data.params.cmdID or + data.params.locationImage.cmdID or + data.params.timeStamp.cmdID then + ErrorMessage = "SDL sends to HMI parameters from another RPC" + CheckStatus = false + end + + if CheckStatus == false then + return false, ErrorMessage + else + return true + end + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +--[[ Scenario ]] +--[[ Preconditions ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, { "icon.png" }) + +--[[ Test ]] +runner.Title("Test") +runner.Step("SendLocation_fake_parameters", sendLocation, { requestParamsWithFake, expectedRequestParams }) +runner.Step("SendLocation_another_request_parameters", sendLocation, + { requetsParamAnotherRequest, expectedRequestParams }) + +--[[ Postconditions ]] +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/023_SendLocation_app_not_registered.lua b/test_scripts/API/Navigation/SendLocation/023_SendLocation_app_not_registered.lua new file mode 100644 index 0000000000..ac46d6ea65 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/023_SendLocation_app_not_registered.lua @@ -0,0 +1,57 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. Request is invalid: Wrong json, parameters of wrong type, string parameters with empty values or whitespace as the +-- only symbol, out of bounds, wrong characters, missing mandatory parameters +-- 2. SDL responds INVALID_DATA, success:false +-- +-- Description: +-- SDL receives SendLocation request to not reqistered application +-- +-- Steps: +-- SDL receives SendLocation request to not reqistered application +-- +-- Expected: +-- SDL responds APPLICATION_NOT_REGISTERED, success:false +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') +local mobileSession = require('mobile_session') + +--[[ Local Functions ]] +local function sendLocation(self) + local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 + } + + local cid = self.mobileSession2:SendRPC("SendLocation", requestParams) + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession2:ExpectResponse(cid, { success = false, resultCode = "APPLICATION_NOT_REGISTERED" }) + commonSendLocation.delayedExp() +end + +local function CreationNewSession(self) + self.mobileSession2 = mobileSession.MobileSession( + self, + self.mobileConnection, + config.application2.registerAppInterfaceParams + ) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile", commonSendLocation.start) +runner.Step("Start session", CreationNewSession) + +runner.Title("Test") +runner.Step("SendLocation_APPLICATION_NOT_REGISTERED", sendLocation) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/024_SendLocation_diff_HMI_levels.lua b/test_scripts/API/Navigation/SendLocation/024_SendLocation_diff_HMI_levels.lua new file mode 100644 index 0000000000..03f5931fca --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/024_SendLocation_diff_HMI_levels.lua @@ -0,0 +1,87 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. Request is sent in NONE, BACKGROUND, FULL, LIMITED levels +-- 2. SDL responds DISALLOWED, success:false to request in NONE level and SUCCESS, success:true in other ones +-- +-- Description: +-- App requests SendLocation in different HMI levels +-- +-- Steps: +-- SDL receives SendLocation request in NONE, BACKGROUND, FULL, LIMITED +-- +-- Expected: +-- SDL responds DISALLOWED, success:false in NONE level, SUCCESS, success:true in BACKGROUND, FULL, LIMITED levels +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ General configuration parameters ]] +config.application1.registerAppInterfaceParams.isMediaApplication = true +config.application1.registerAppInterfaceParams.appHMIType = {"NAVIGATION"} +config.application2.registerAppInterfaceParams.isMediaApplication = false +config.application2.registerAppInterfaceParams.appHMIType = {"NAVIGATION"} + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +--[[ Local Functions ]] +local function sendLocationDisallowed(params, self) + local cid = self.mobileSession2:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + + self.mobileSession2:ExpectResponse(cid, { success = false, resultCode = "DISALLOWED" }) + commonSendLocation.delayedExp() +end + +local function sendLocationSuccess(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + params.appID = commonSendLocation.getHMIAppId() + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +local function BringAppToLimitedLevel(self) + local appIDval = commonSendLocation.getHMIAppId(1) + self.hmiConnection:SendNotification("BasicCommunication.OnAppDeactivated", + { appID = appIDval }) + + self.mobileSession1:ExpectNotification("OnHMIStatus", { hmiLevel = "LIMITED" }) +end + +local function BringAppToBackgroundLevel(self) + commonSendLocation.activateApp(2, self) + + self.mobileSession1:ExpectNotification("OnHMIStatus",{ hmiLevel = "BACKGROUND" }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU first app", commonSendLocation.registerApplicationWithPTU) +runner.Step("RAI, PTU second app", commonSendLocation.registerApplicationWithPTU, { 2 }) +runner.Step("Activate first App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation_in_NONE", sendLocationDisallowed, { requestParams }) +runner.Step("SendLocation_in_FULL", sendLocationSuccess, { requestParams }) +runner.Step("Bring_app_to_limited", BringAppToLimitedLevel) +runner.Step("SendLocation_in_LIMITED", sendLocationSuccess, { requestParams }) +runner.Step("Bring_app_to_background", BringAppToBackgroundLevel) +runner.Step("SendLocation_in_BACKGROUND", sendLocationSuccess, { requestParams }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/025_SendLocation_without_HMI_response.lua b/test_scripts/API/Navigation/SendLocation/025_SendLocation_without_HMI_response.lua new file mode 100644 index 0000000000..6a802edbd2 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/025_SendLocation_without_HMI_response.lua @@ -0,0 +1,44 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. HMI sends invalid response to SDL +-- 2. SDL responds GENERIC_ERROR, success:false +-- +-- Description: +-- SDL responds GENERIC_ERROR, success:false in case of receiving invalid response from HMI +-- +-- Steps: +-- App requests SendLocation +-- HMI does not respond to SDL +-- Expected: +-- SDL responds GENERIC_ERROR, success:false +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Functions ]] +local function sendLocation(self) + local params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 + } + local cid = self.mobileSession1:SendRPC("SendLocation", params) + EXPECT_HMICALL("Navigation.SendLocation") + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) + :Timeout(11000) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU first app", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate first App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation_without_response_from_HMI", sendLocation) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/026_SendLocation_parameters_omitted_in_policy_table.lua b/test_scripts/API/Navigation/SendLocation/026_SendLocation_parameters_omitted_in_policy_table.lua new file mode 100644 index 0000000000..309908f748 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/026_SendLocation_parameters_omitted_in_policy_table.lua @@ -0,0 +1,90 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. Request is valid, SendLocation RPC is not allowed by policies +-- 2. SDL responds DISALLOWED, success:false to request +-- +-- Description: +-- App requests SendLocation in case parameters section is omitted in PT +-- +-- Steps: +-- SDL receives allowed SendLocation request and parameters section is omitted in PT +-- +-- Expected: +-- SDL proceed with this request +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function ptuUpdateFuncDissalowedRPC(tbl) + local SendLocstionRpcs = tbl.policy_table.functional_groupings["SendLocation"].rpcs + if SendLocstionRpcs["SendLocation"].parameters then SendLocstionRpcs["SendLocation"].parameters = nil end +end + +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + EXPECT_HMICALL("Navigation.SendLocation") + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU, { "1", ptuUpdateFuncDissalowedRPC }) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation_parameters_omitted_in_policy_table", sendLocation, { requestParams }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_empty_in_policy_table.lua b/test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_empty_in_policy_table.lua new file mode 100644 index 0000000000..edcff61d39 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_empty_in_policy_table.lua @@ -0,0 +1,90 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. Request is valid, SendLocation RPC is not allowed by policies +-- 2. SDL responds DISALLOWED, success:false to request +-- +-- Description: +-- App requests SendLocation in case parameters section is empty in PT +-- +-- Steps: +-- SDL receives allowed SendLocation request and parameters section is empty in PT +-- +-- Expected: +-- SDL responds DISALLOWED, success:false +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') +local json = require("json") + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function ptuUpdateFuncDissalowedRPC(tbl) + local SendLocstionRpcs = tbl.policy_table.functional_groupings["SendLocation"].rpcs + SendLocstionRpcs["SendLocation"].parameters = json.EMPTY_ARRAY +end + +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + commonSendLocation.delayedExp() + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "DISALLOWED" }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU, { "1", ptuUpdateFuncDissalowedRPC }) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation_parameters_empty_in_policy_table", sendLocation, { requestParams }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua b/test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua new file mode 100644 index 0000000000..4261136762 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua @@ -0,0 +1,82 @@ +--------------------------------------------------------------------------------------------- +-- Requirements: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- +-- Requirement summary: +-- 1. Request is valid, SendLocation RPC is not allowed by policies +-- 2. SDL responds DISALLOWED, success:false to request +-- +-- Description: +-- App requests SendLocation and all parameters from request are not presented in parameters section in PT +-- +-- Steps: +-- SDL receives allowed SendLocation request with all not allowed parameters +-- +-- Expected: +-- SDL responds DISALLOWED, success:false +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +--[[ Local Functions ]] +local function ptuUpdateFuncDissalowedRPC(tbl) + local SendLocstionRpcs = tbl.policy_table.functional_groupings["SendLocation"].rpcs + SendLocstionRpcs["SendLocation"].parameters = { "address" } +end + +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + EXPECT_HMICALL("Navigation.SendLocation") + :Times(0) + commonSendLocation.delayedExp() + self.mobileSession1:ExpectResponse(cid, { + success = false, + resultCode = "DISALLOWED", + info = "Requested parameters are disallowed by Policies" + }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU, { "1", ptuUpdateFuncDissalowedRPC }) +runner.Step("Activate App", commonSendLocation.activateApp) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation_all_parameters_in_request_disallowed", sendLocation, { requestParams }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/029_SendLocation_invalid_characters.lua b/test_scripts/API/Navigation/SendLocation/029_SendLocation_invalid_characters.lua new file mode 100644 index 0000000000..40617018c6 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/029_SendLocation_invalid_characters.lua @@ -0,0 +1,117 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Exception 1: invalid types of parameters values) +-- +-- Requirement summary: +-- App requests SendLocation wit one parameter of wrong type, other parameters are valid +-- +-- Description: +-- App sends SendLocation with wrong types of parameters + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- App sends SendLocation with invalid characters \t, \n, whitespace only + +-- Expected: + +-- SDL validates parameters of the request +-- SDL responds INVALID_DATA, success: false +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + addressLines = + { + "line1" + }, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timeStamp = { + millisecond = 0, + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + phoneNumber = "phone Number", + deliveryMode = "PROMPT", + locationImage = + { + value = "icon.png", + imageType = "DYNAMIC", + } +} + +local invalidCharacters = { + newLine = "str\ning", + tab = "str\ting", + whitespace = " " +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + EXPECT_HMICALL("Navigation.SendLocation", params):Times(0) + self.mobileSession1:ExpectResponse(cid, {success = false, resultCode = "INVALID_DATA"}) + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +for key,value in pairs(requestParams) do + for keyInvalChar, valueInvalCharacters in pairs(invalidCharacters) do + if (type(value) == "table") then + for subKey,subValue in pairs(value) do + local parametersToSend = {} + parametersToSend[key] = {} + parametersToSend[key][subKey] = subValue + if type(subValue) == "string" then + parametersToSend[key][subKey] = valueInvalCharacters + runner.Step("SendLocation_invalid_character_" .. tostring(key) .. "_" .. tostring(subKey) .. "_" .. keyInvalChar, + sendLocation, {parametersToSend}) + end + end + else + local parametersToSend = {} + parametersToSend[key] = value + if type(parametersToSend[key]) == "string" then + parametersToSend[key] = valueInvalCharacters + runner.Step("SendLocation_invalid_character_" .. tostring(key) .. "_" .. keyInvalChar, + sendLocation, {parametersToSend}) + end + end + end +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/030_SendLocation_several_responses_to_request.lua b/test_scripts/API/Navigation/SendLocation/030_SendLocation_several_responses_to_request.lua new file mode 100644 index 0000000000..e0f8db2b23 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/030_SendLocation_several_responses_to_request.lua @@ -0,0 +1,70 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow +-- +-- Requirement summary: +-- SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters +-- +-- Description: +-- App sends SendLocation with all available parameters. +-- +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL +-- +-- Steps: +-- appID requests SendLocation +-- Expected: +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request with allowed parameters to HMI +-- SDL receives responses from HMI, process first received response +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local requestParams = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +--[[ Local Functions ]] +local function sendLocation(params, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + params.appID = commonSendLocation.getHMIAppId() + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + local function response1() + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end + local function response2() + self.hmiConnection:SendError(data.id, data.method, "ABORTED", "Error message") + end + local function response3() + self.hmiConnection:SendError(data.id, data.method, "REJECTED", "Error message") + end + RUN_AFTER(response1, 300) + RUN_AFTER(response2, 600) + RUN_AFTER(response3, 900) + end) + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + commonSendLocation.delayedExp() +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", commonSendLocation.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation.start) +runner.Step("RAI, PTU", commonSendLocation.registerApplicationWithPTU) +runner.Step("Activate App", commonSendLocation.activateApp) + +runner.Title("Test") +runner.Step("SendLocation_several_response", sendLocation, {requestParams}) +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/031_SendLocation_transfer_result_code.lua b/test_scripts/API/Navigation/SendLocation/031_SendLocation_transfer_result_code.lua new file mode 100644 index 0000000000..909d511fb6 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/031_SendLocation_transfer_result_code.lua @@ -0,0 +1,116 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/24 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/TRS/embedded_navi/SendLocation_TRS.md +-- Item: Use Case 1: Main Flow (Alternative flow 1) +-- +-- Requirement summary: +-- SDL transfer HMI's result code to Mobile +-- +-- Description: +-- App sends SendLocation will valid parameters, Navi interface is working. + +-- Pre-conditions: +-- a. HMI and SDL are started +-- b. appID is registered on SDL + +-- Steps: +-- appID requests SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters + +-- Expected: + +-- SDL validates parameters of the request +-- SDL checks if Navi interface is available on HMI +-- SDL checks if SendLocation is allowed by Policies +-- SDL checks if deliveryMode is allowed by Policies +-- SDL transfers the request with allowed parameters to HMI +-- SDL receives response from HMI +-- SDL transfers response to mobile app +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local common = require('test_scripts/API/Navigation/commonSendLocation') + +--[[ Local Variables ]] +local resultCodes = { + success = common.getSuccessResultCodes("SendLocation"), + failure = common.getFailureResultCodes("SendLocation"), + unexpected = common.getUnexpectedResultCodes("SendLocation"), + unmapped = common.getUnmappedResultCodes("SendLocation") +} + +local params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +--[[ Local Functions ]] +local function sendLocationSuccess(pResultCodeMap, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, pResultCodeMap.hmi, {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = pResultCodeMap.mobile }) +end + +local function sendLocationUnsuccess(pResultCodeMap, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendError(data.id, data.method, pResultCodeMap.hmi, "Error error") + end) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = pResultCodeMap.mobile }) + :ValidIf(function(_,data) + if not data.payload.info then + return false, "SDL doesn't resend info parameter to mobile App" + end + return true + end) +end + +local function sendLocationUnexpected(pResultCodeMap, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + if pResultCodeMap.success then + self.hmiConnection:SendResponse(data.id, data.method, pResultCodeMap.hmi, {}) + else + self.hmiConnection:SendError(data.id, data.method, pResultCodeMap.hmi, "Error error") + end + end) + + self.mobileSession1:ExpectResponse(cid, { success = pResultCodeMap.success, resultCode = pResultCodeMap.mobile }) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", common.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +runner.Step("RAI, PTU", common.registerApplicationWithPTU) +runner.Step("Activate App", common.activateApp) + +runner.Title("Test") +runner.Step("Result Codes", common.printResultCodes, { resultCodes }) + +runner.Title("Successful codes") +for _, item in pairs(resultCodes.success) do + runner.Step("SendLocation with " .. item.hmi .. " resultCode", sendLocationSuccess, { item }) +end + +runner.Title("Erroneous codes") +for _, item in pairs(resultCodes.failure) do + runner.Step("SendLocation with " .. item.hmi .. " resultCode", sendLocationUnsuccess, { item }) +end + +runner.Title("Unexpected codes") +for _, item in pairs(resultCodes.unexpected) do + runner.Step("SendLocation with " .. item.hmi .. " resultCode", sendLocationUnexpected, { item }) +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua new file mode 100644 index 0000000000..8b83020f78 --- /dev/null +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -0,0 +1,474 @@ +--------------------------------------------------------------------------------------------------- +-- SendLocation common module +--------------------------------------------------------------------------------------------------- +--[[ General configuration parameters ]] +config.mobileHost = "127.0.0.1" +config.defaultProtocolVersion = 2 + +--[[ Required Shared libraries ]] +local mobile_session = require("mobile_session") +local json = require("modules/json") + +local commonFunctions = require("user_modules/shared_testcases/commonFunctions") +local commonSteps = require("user_modules/shared_testcases/commonSteps") +local commonTestCases = require("user_modules/shared_testcases/commonTestCases") +local commonPreconditions = require('user_modules/shared_testcases/commonPreconditions') +local events = require("events") + +local api_loader = require("modules/api_loader") +local mobile_api = api_loader.init("data/MOBILE_API.xml") +local mobile_api_schema = mobile_api.interface[next(mobile_api.interface)] +local hmi_api = api_loader.init("data/HMI_API.xml") +local hmi_api_schema = hmi_api.interface["Common"] + +--[[ Local Variables ]] +local ptu_table = {} +local hmiAppIds = {} + +local commonSendLocation = {} + +commonSendLocation.timeout = 2000 +commonSendLocation.minTimeout = 500 + +local successCodes = { + "SUCCESS", + "WARNINGS", + "WRONG_LANGUAGE", + "RETRY", + "SAVED" +} + +local excludedCodes = { + "UNSUPPORTED_RESOURCE" -- excluded due to unresolved clarification +} + +local function getAvailableParams() + local out = {} + for k in pairs(mobile_api_schema.type["request"].functions["SendLocation"].param) do + table.insert(out, k) + end + return out +end + +local function allowSDL(self) + self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality", { + allowed = true, + source = "GUI", + device = { + id = commonSendLocation.getDeviceMAC(), + name = commonSendLocation.getDeviceName() + } + }) +end + +local function checkIfPTSIsSentAsBinary(bin_data) + if not (bin_data ~= nil and string.len(bin_data) > 0) then + commonFunctions:userPrint(31, "PTS was not sent to Mobile in payload of OnSystemRequest") + end +end + +function commonSendLocation.getSendLocationConfig() + return { + keep_context = false, + steal_focus = false, + priority = "NONE", + default_hmi = "NONE", + groups = { "Base-4", "SendLocation" } + } +end + +local function getPTUFromPTS(tbl) + tbl.policy_table.consumer_friendly_messages.messages = nil + tbl.policy_table.device_data = nil + tbl.policy_table.module_meta = nil + tbl.policy_table.usage_and_error_counts = nil + tbl.policy_table.functional_groupings["DataConsent-2"].rpcs = json.null + tbl.policy_table.module_config.preloaded_pt = nil + tbl.policy_table.module_config.preloaded_date = nil +end + +local function jsonFileToTable(pFileName) + local f = io.open(pFileName, "r") + local content = f:read("*all") + f:close() + return json.decode(content) +end + +local function ptu(self, id, pUpdateFunction) + local function getAppsCount() + local count = 0 + for _ in pairs(hmiAppIds) do + count = count + 1 + end + return count + end + + local policy_file_name = "PolicyTableUpdate" + local policy_file_path = commonFunctions:read_parameter_from_smart_device_link_ini("SystemFilesPath") + local pts_file_name = commonFunctions:read_parameter_from_smart_device_link_ini("PathToSnapshot") + local ptu_file_name = os.tmpname() + local requestId = self.hmiConnection:SendRequest("SDL.GetURLS", { service = 7 }) + EXPECT_HMIRESPONSE(requestId) + :Do(function() + self.hmiConnection:SendNotification("BasicCommunication.OnSystemRequest", + { requestType = "PROPRIETARY", fileName = pts_file_name }) + getPTUFromPTS(ptu_table) + local function updatePTU(tbl) + tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters = {} + for _, v in pairs(getAvailableParams()) do + table.insert(tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters, v) + end + tbl.policy_table.app_policies[commonSendLocation.getMobileAppId(id)] = commonSendLocation.getSendLocationConfig() + end + updatePTU(ptu_table) + if pUpdateFunction then + pUpdateFunction(ptu_table) + end + local function tableToJsonFile(tbl, file_name) + local f = io.open(file_name, "w") + f:write(json.encode(tbl)) + f:close() + end + tableToJsonFile(ptu_table, ptu_file_name) + + local event = events.Event() + event.matches = function(self, e) return self == e end + EXPECT_EVENT(event, "PTU event") + :Timeout(11000) + + for id = 1, getAppsCount() do + local mobileSession = commonSendLocation.getMobileSession(id, self) + mobileSession:ExpectNotification("OnSystemRequest", { requestType = "PROPRIETARY" }) + :Do(function(_, d2) + print("App ".. id .. " was used for PTU") + RAISE_EVENT(event, event, "PTU event") + checkIfPTSIsSentAsBinary(d2.binaryData) + local corIdSystemRequest = mobileSession:SendRPC("SystemRequest", { requestType = "PROPRIETARY", fileName = policy_file_name }, ptu_file_name) + EXPECT_HMICALL("BasicCommunication.SystemRequest") + :Do(function(_, d3) + self.hmiConnection:SendResponse(d3.id, "BasicCommunication.SystemRequest", "SUCCESS", { }) + self.hmiConnection:SendNotification("SDL.OnReceivedPolicyUpdate", + { policyfile = policy_file_path .. "/" .. policy_file_name }) + end) + mobileSession:ExpectResponse(corIdSystemRequest, { success = true, resultCode = "SUCCESS" }) + :Do(function() os.remove(ptu_file_name) end) + end) + :Times(AtMost(1)) + end + end) +end + +function commonSendLocation.preconditions() + commonFunctions:SDLForceStop() + commonSteps:DeletePolicyTable() + commonSteps:DeleteLogsFiles() +end + +--[[Module functions]] + +function commonSendLocation.activateApp(pAppId, self) + self, pAppId = commonSendLocation.getSelfAndParams(pAppId, self) + if not pAppId then pAppId = 1 end + local pHMIAppId = hmiAppIds[config["application" .. pAppId].registerAppInterfaceParams.appID] + local mobSession = commonSendLocation.getMobileSession(pAppId, self) + local requestId = self.hmiConnection:SendRequest("SDL.ActivateApp", { appID = pHMIAppId }) + EXPECT_HMIRESPONSE(requestId) + mobSession:ExpectNotification("OnHMIStatus", + {hmiLevel = "FULL", audioStreamingState = "AUDIBLE", systemContext = "MAIN"}) + commonTestCases:DelayedExp(commonSendLocation.minTimeout) +end + +function commonSendLocation.backupHMICapabilities() + local hmiCapabilitiesFile = commonFunctions:read_parameter_from_smart_device_link_ini("HMICapabilities") + commonPreconditions:BackupFile(hmiCapabilitiesFile) +end + +function commonSendLocation.delayedExp(timeout) + if not timeout then timeout = commonSendLocation.timeout end + commonTestCases:DelayedExp(timeout) +end + +function commonSendLocation.getDeviceName() + return config.mobileHost .. ":" .. config.mobilePort +end + +function commonSendLocation.getDeviceMAC() + local cmd = "echo -n " .. commonSendLocation.getDeviceName() .. " | sha256sum | awk '{printf $1}'" + local handle = io.popen(cmd) + local result = handle:read("*a") + handle:close() + return result +end + +function commonSendLocation.getSelfAndParams(...) + local out = { } + local selfIdx = nil + for i,v in pairs({...}) do + if type(v) == "table" and v.isTest then + table.insert(out, v) + selfIdx = i + break + end + end + local idx = 2 + for i = 1, table.maxn({...}) do + if i ~= selfIdx then + out[idx] = ({...})[i] + idx = idx + 1 + end + end + return table.unpack(out, 1, table.maxn(out)) +end + +function commonSendLocation.getHMIAppId(pAppId) + if not pAppId then pAppId = 1 end + return hmiAppIds[config["application" .. pAppId].registerAppInterfaceParams.appID] +end + +function commonSendLocation.getMobileSession(pAppId, self) + self, pAppId = commonSendLocation.getSelfAndParams(pAppId, self) + if not pAppId then pAppId = 1 end + return self["mobileSession" .. pAppId] +end + +function commonSendLocation.getMobileAppId(pAppId) + if not pAppId then pAppId = 1 end + return config["application" .. pAppId].registerAppInterfaceParams.appID +end + +function commonSendLocation.getPathToSDL() + return config.pathToSDL +end + +function commonSendLocation.postconditions() + StopSDL() +end + +function commonSendLocation.putFile(pFileName, self) + self, pFileName = commonSendLocation.getSelfAndParams(pFileName, self) + local cid = self.mobileSession1:SendRPC( + "PutFile", + {syncFileName = pFileName, fileType = "GRAPHIC_PNG", persistentFile = false, systemFile = false}, + "files/icon.png") + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS"}) +end + +function commonSendLocation.registerApplicationWithPTU(pAppId, pUpdateFunction, self) + self, pAppId, pUpdateFunction = commonSendLocation.getSelfAndParams(pAppId, pUpdateFunction, self) + if not pAppId then pAppId = 1 end + self["mobileSession" .. pAppId] = mobile_session.MobileSession(self, self.mobileConnection) + self["mobileSession" .. pAppId]:StartService(7) + :Do(function() + local corId = self["mobileSession" .. pAppId]:SendRPC("RegisterAppInterface", + config["application" .. pAppId].registerAppInterfaceParams) + EXPECT_HMINOTIFICATION("BasicCommunication.OnAppRegistered", + { application = { appName = config["application" .. pAppId].registerAppInterfaceParams.appName } }) + :Do(function(_, d1) + hmiAppIds[config["application" .. pAppId].registerAppInterfaceParams.appID] = d1.params.application.appID + EXPECT_HMINOTIFICATION("SDL.OnStatusUpdate", + {status = "UPDATE_NEEDED"}, {status = "UPDATING"}, {status = "UP_TO_DATE" }) + :Times(3) + EXPECT_HMICALL("BasicCommunication.PolicyUpdate") + :Do(function(_, d2) + self.hmiConnection:SendResponse(d2.id, d2.method, "SUCCESS", { }) + ptu_table = jsonFileToTable(d2.params.file) + ptu(self, pAppId, pUpdateFunction) + end) + end) + self["mobileSession" .. pAppId]:ExpectResponse(corId, { success = true, resultCode = "SUCCESS" }) + :Do(function() + self["mobileSession" .. pAppId]:ExpectNotification("OnHMIStatus", + {hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN"}) + :Times(1) + self["mobileSession" .. pAppId]:ExpectNotification("OnPermissionsChange") + :Times(AtLeast(1)) -- todo: issue with SDL --> notification is sent twice + end) + end) +end + +function commonSendLocation.registerApplication(id, self) + self, id = commonSendLocation.getSelfAndParams(id, self) + if not id then id = 1 end + self["mobileSession" .. id] = mobile_session.MobileSession(self, self.mobileConnection) + self["mobileSession" .. id]:StartService(7) + :Do(function() + local corId = self["mobileSession" .. id]:SendRPC("RegisterAppInterface", + config["application" .. id].registerAppInterfaceParams) + EXPECT_HMINOTIFICATION("BasicCommunication.OnAppRegistered", + {application = {appName = config["application" .. id].registerAppInterfaceParams.appName}}) + :Do(function(_, d1) + hmiAppIds[config["application" .. id].registerAppInterfaceParams.appID] = d1.params.application.appID + end) + self["mobileSession" .. id]:ExpectResponse(corId, { success = true, resultCode = "SUCCESS" }) + :Do(function() + self["mobileSession" .. id]:ExpectNotification("OnHMIStatus", + { hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN" }) + :Times(AtLeast(1)) -- issue with SDL --> notification is sent twice + self["mobileSession" .. id]:ExpectNotification("OnPermissionsChange") + end) + end) +end + +function commonSendLocation.restoreHMICapabilities() + local hmiCapabilitiesFile = commonFunctions:read_parameter_from_smart_device_link_ini("HMICapabilities") + commonPreconditions:RestoreFile(hmiCapabilitiesFile) +end + +function commonSendLocation.start(pHMIParams, self) + self, pHMIParams = commonSendLocation.getSelfAndParams(pHMIParams, self) + self:runSDL() + commonFunctions:waitForSDLStart(self) + :Do(function() + self:initHMI(self) + :Do(function() + commonFunctions:userPrint(35, "HMI initialized") + self:initHMI_onReady(pHMIParams) + :Do(function() + commonFunctions:userPrint(35, "HMI is ready") + self:connectMobile() + :Do(function() + commonFunctions:userPrint(35, "Mobile connected") + allowSDL(self) + end) + end) + end) + end) +end + +function commonSendLocation.unregisterApp(pAppId, self) + local mobSession = commonSendLocation.getMobileSession(pAppId, self) + local hmiAppId = commonSendLocation.getHMIAppId(pAppId) + local cid = mobSession:SendRPC("UnregisterAppInterface",{}) + EXPECT_HMINOTIFICATION("BasicCommunication.OnAppUnregistered", { appID = hmiAppId, unexpectedDisconnect = false }) + mobSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS"}) +end + +local function getMobileResultCodes() + local out = {} + for k in pairs(mobile_api_schema.enum["Result"]) do + table.insert(out, k) + end + return out +end + +local function getExpectedResultCodes(pFunctionName) + return mobile_api_schema.type["response"].functions[pFunctionName].param.resultCode.resultCodes +end + +local function getHMIResultCodes() + local out = {} + for k in pairs(hmi_api_schema.enum["Result"]) do + table.insert(out, k) + end + return out +end + +local function isContain(pTbl, pValue) + for _, v in pairs(pTbl) do + if v == pValue then return true end + end + return false +end + +function commonSendLocation.getKeysFromItemsTable(pTbl, pKey) + local out = {} + for _, item in pairs(pTbl) do + if not isContain(out, item[pKey]) then + table.insert(out, item[pKey]) + end + end + return out +end + +local function getResultCodesMap() + local out = {} + for _, v in pairs(getHMIResultCodes()) do + if not isContain(excludedCodes, v) then + if isContain(getMobileResultCodes(), v) then + table.insert(out, { mobile = v, hmi = v }) + else + table.insert(out, { mobile = nil, hmi = v }) + end + end + end + return out +end + +function commonSendLocation.getSuccessResultCodes(pFunctionName) + local out = {} + for _, item in pairs(getResultCodesMap()) do + if isContain(getExpectedResultCodes(pFunctionName), item.mobile) and isContain(successCodes, item.mobile) then + table.insert(out, { mobile = item.mobile, hmi = item.hmi }) + end + end + return out +end + +function commonSendLocation.getFailureResultCodes(pFunctionName) + local out = {} + for _, item in pairs(getResultCodesMap()) do + if isContain(getExpectedResultCodes(pFunctionName), item.mobile) and not isContain(successCodes, item.mobile) then + table.insert(out, { mobile = item.mobile, hmi = item.hmi }) + end + end + return out +end + +function commonSendLocation.getUnexpectedResultCodes(pFunctionName) + local out = {} + for _, item in pairs(getResultCodesMap()) do + local success = false + if isContain(successCodes, item.mobile) then success = true end + if item.mobile ~= nil and not isContain(getExpectedResultCodes(pFunctionName), item.mobile) then + table.insert(out, { mobile = item.mobile, hmi = item.hmi, success = success }) + end + end + return out +end + +function commonSendLocation.getUnmappedResultCodes() + local out = {} + for _, item in pairs(getResultCodesMap()) do + if item.mobile == nil then + table.insert(out, { mobile = item.mobile, hmi = item.hmi }) + end + end + return out +end + +function commonSendLocation.printResultCodes(pResultCodes) + local function printItem(pItem) + for _, v in pairs(pItem) do + local msg = v.hmi + if v.mobile and v.mobile ~= v.hmi then msg = msg .. "\t" .. v.mobile end + print("", msg) + end + end + print("Success:") + printItem(pResultCodes.success) + print("Failure:") + printItem(pResultCodes.failure) + print("Unexpected:") + printItem(pResultCodes.unexpected) + print("Unmapped:") + printItem(pResultCodes.unmapped) +end + +--[[ @filterTable: remove from 1st table items provided in 2nd table +--! @parameters: +--! pFilteredTbl - table which will be filtered +--! pValuesTbl - table with values that are going to be removed +--]] +function commonSendLocation.filterTable(pFilteredTbl, pValuesTbl) + local i = 1 + while i <= #pFilteredTbl do + if isContain(pValuesTbl, pFilteredTbl[i]) then + table.remove(pFilteredTbl, i) + else + i = i + 1 + end + end +end + +return commonSendLocation diff --git a/test_scripts/Smoke/API/027_UpdateTurnList_PositiveCase_SUCCESS.lua b/test_scripts/Smoke/API/027_UpdateTurnList_PositiveCase_SUCCESS.lua index 7a2e80c5da..4f99584363 100644 --- a/test_scripts/Smoke/API/027_UpdateTurnList_PositiveCase_SUCCESS.lua +++ b/test_scripts/Smoke/API/027_UpdateTurnList_PositiveCase_SUCCESS.lua @@ -72,7 +72,7 @@ local requestParams = { local responseUiParams = commonFunctions:cloneTable(requestParams) responseUiParams.turnList[1].navigationText = { fieldText = requestParams.turnList[1].navigationText, - fieldName = "turnText" + fieldName = "navigationText" } responseUiParams.turnList[1].turnIcon.value = commonSmoke.getPathToFileInStorage(requestParams.turnList[1].turnIcon.value) responseUiParams.softButtons[1].image.value = commonSmoke.getPathToFileInStorage(requestParams.softButtons[1].image.value) diff --git a/test_scripts/smoke_api.lua b/test_scripts/smoke_api.lua index a03e98210b..c6af915f6a 100644 --- a/test_scripts/smoke_api.lua +++ b/test_scripts/smoke_api.lua @@ -2771,12 +2771,6 @@ local function displayCap_textFields_Value() rows = 1, width = 500 }, - { - characterSet = "TYPE2SET", - name = "turnText", - rows = 1, - width = 500 - }, { characterSet = "TYPE2SET", name = "menuTitle", @@ -3452,7 +3446,7 @@ local function setExTurnList(size) navigationText = { fieldText = "Text", - fieldName = "turnText" + fieldName = "navigationText" }, turnIcon = { @@ -3469,7 +3463,7 @@ local function setExTurnList(size) navigationText = { fieldText = "Text"..i, - fieldName = "turnText" + fieldName = "navigationText" }, turnIcon = { diff --git a/test_sets/SendLocation.txt b/test_sets/SendLocation.txt new file mode 100644 index 0000000000..d1932a609c --- /dev/null +++ b/test_sets/SendLocation.txt @@ -0,0 +1,31 @@ +./test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua +./test_scripts/API/Navigation/SendLocation/002_SendLocation_disallowed_by_policies.lua +./test_scripts/API/Navigation/SendLocation/003_SendLocation_without_address.lua +./test_scripts/API/Navigation/SendLocation/004_SendLocation_wo_mandatory.lua +./test_scripts/API/Navigation/SendLocation/005_SendLocation_wo_mandatory_with_deliveryMode.lua +./test_scripts/API/Navigation/SendLocation/006_SendLocation_wo_deliveryMode.lua +./test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua +./test_scripts/API/Navigation/SendLocation/008_SendLocation_invalid_json.lua +./test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua +./test_scripts/API/Navigation/SendLocation/010_SendLocation_out_of_bound.lua +./test_scripts/API/Navigation/SendLocation/011_SendLocation_whitespaces.lua +./test_scripts/API/Navigation/SendLocation/012_SendLocation_cut_off_address.lua +./test_scripts/API/Navigation/SendLocation/013_SendLocation_unsupported_resource.lua +./test_scripts/API/Navigation/SendLocation/014_SendLocation_unsupported_capability.lua +./test_scripts/API/Navigation/SendLocation/015_SendLocation_with_mandatory_params_and_disallowed_deliveryMode.lua +./test_scripts/API/Navigation/SendLocation/016_SendLocation_with_mandatory_params_allowed_and_disallowed_locationName_deliveryMode.lua +./test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua +./test_scripts/API/Navigation/SendLocation/018_SendLocation_MandatoryOnly_Float.lua +./test_scripts/API/Navigation/SendLocation/019_SendLocation_MandatoryOnly_Int.lua +./test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua +./test_scripts/API/Navigation/SendLocation/021_SendLocation_out_of_bound_values.lua +./test_scripts/API/Navigation/SendLocation/022_SendLocation_fake_another_request_params.lua +./test_scripts/API/Navigation/SendLocation/023_SendLocation_app_not_registered.lua +./test_scripts/API/Navigation/SendLocation/024_SendLocation_diff_HMI_levels.lua +./test_scripts/API/Navigation/SendLocation/025_SendLocation_without_HMI_response.lua +./test_scripts/API/Navigation/SendLocation/026_SendLocation_parameters_omitted_in_policy_table.lua +./test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_empty_in_policy_table.lua +./test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua +./test_scripts/API/Navigation/SendLocation/029_SendLocation_invalid_characters.lua +./test_scripts/API/Navigation/SendLocation/030_SendLocation_several_responses_to_request.lua +./test_scripts/API/Navigation/SendLocation/031_SendLocation_transfer_result_code.lua