From dd33f7f5fbc829d124d7d8ef8d19f8bcf8941ade Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Mon, 11 Sep 2017 17:05:09 +0300 Subject: [PATCH 01/29] removed rc related functions from common --- .../SendLocation/001_SendLocation_success.lua | 101 +++++++ .../API/SendLocation/common_send_location.lua | 272 ++++++++++++++++++ 2 files changed, 373 insertions(+) create mode 100644 test_scripts/API/SendLocation/001_SendLocation_success.lua create mode 100644 test_scripts/API/SendLocation/common_send_location.lua diff --git a/test_scripts/API/SendLocation/001_SendLocation_success.lua b/test_scripts/API/SendLocation/001_SendLocation_success.lua new file mode 100644 index 0000000000..3cc0d0036f --- /dev/null +++ b/test_scripts/API/SendLocation/001_SendLocation_success.lua @@ -0,0 +1,101 @@ +--------------------------------------------------------------------------------------------------- +-- User story: https://github.com/smartdevicelink/sdl_requirements/issues/3 +-- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/SetInteriorVehicleData.md +-- Item: Use Case 1: Main Flow +-- +-- Requirement summary: +-- [SDL_RC] Set available control module settings SetInteriorVehicleData +-- +-- Description: +-- In case: +-- 1) Application is registered with REMOTE_CONTROL appHMIType +-- 2) and sends valid SetInteriorVehicleData RPC with valid parameters +-- SDL must: +-- 1) Transfer this request to HMI +-- 2) Respond with received from HMI +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local common_send_location = require('test_scripts/API/SendLocation/common_send_location') + +--[[ Local Variables ]] +local request_params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1, + address = { + countryName = "countryName", + countryCode = "countryName", + postalCode = "postalCode", + administrativeArea = "administrativeArea", + subAdministrativeArea = "subAdministrativeArea", + locality = "locality", + subLocality = "subLocality", + thoroughfare = "thoroughfare", + subThoroughfare = "subThoroughfare" + }, + timestamp = { + second = 40, + minute = 30, + hour = 14, + day = 25, + month = 5, + year = 2017, + tz_hour = 5, + tz_minute = 30 + }, + locationName = "location Name", + locationDescription = "location Description", + addressLines = + { + "line1", + "line2", + }, + 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) + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + --hmi side: sending Navigation.SendLocation response + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) +end + +local function ptu_update_func(tbl) + tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.appID].groups = { "Base-4", "SendLocation" } +end + +local function put_file(file_name, self) + local CorIdPutFile = self.mobileSession1:SendRPC( + "PutFile", + {syncFileName = file_name, fileType = "GRAPHIC_PNG", persistentFile = false, systemFile = false}, + "files/icon.png") + + self.mobileSession1:ExpectResponse(CorIdPutFile, { success = true, resultCode = "SUCCESS"}) + :Timeout(10000) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", common_send_location.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", common_send_location.start) +runner.Step("RAI, PTU", common_send_location.rai_ptu) +runner.Step("Activate App", common_send_location.activate_app) +runner.Step("Upload file", put_file, {"icon.png"}) + +runner.Title("Test") +runner.Step("SendLocation - all params ", send_location, { request_params }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", common_send_location.postconditions) diff --git a/test_scripts/API/SendLocation/common_send_location.lua b/test_scripts/API/SendLocation/common_send_location.lua new file mode 100644 index 0000000000..d1db5576c1 --- /dev/null +++ b/test_scripts/API/SendLocation/common_send_location.lua @@ -0,0 +1,272 @@ +--------------------------------------------------------------------------------------------------- +-- RC common module +--------------------------------------------------------------------------------------------------- +--[[ General configuration parameters ]] +config.deviceMAC = "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0" +config.defaultProtocolVersion = 2 +config.ValidateSchema = false + +--[[ Required Shared libraries ]] +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 mobile_session = require("mobile_session") +local json = require("modules/json") +local hmi_values = require("user_modules/hmi_values") + +--[[ Local Variables ]] +local ptu_table = {} +local hmiAppIds = {} + +local common_send_location = {} + +common_send_location.timeout = 2000 +common_send_location.minTimeout = 500 +common_send_location.DEFAULT = "Default" + +local function allow_sdl(self) + self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality", + { allowed = true, source = "GUI", device = { id = config.deviceMAC, name = "127.0.0.1" } }) +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 common_send_location.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(file_name) + local f = io.open(file_name, "r") + local content = f:read("*all") + f:close() + return json.decode(content) +end + +local function ptu(self, ptu_update_func) + 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.parameters = {} + tbl.policy_table.functional_groupings.SendLocation.parameters[1] = "longitudeDegrees" + tbl.policy_table.functional_groupings.SendLocation.parameters[2] = "latitudeDegrees" + tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.appID] = common_send_location.getSendLocationConfig() + end + updatePTU(ptu_table) + if ptu_update_func then + ptu_update_func(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 = common_send_location.getMobileSession(self, id) + 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" }) + end) + :Times(AtMost(1)) + end + end) + os.remove(ptu_file_name) +end + +function common_send_location.preconditions() + commonFunctions:SDLForceStop() + commonSteps:DeletePolicyTable() + commonSteps:DeleteLogsFiles() +end + +--[[Module functions]] + +function common_send_location.activate_app(pAppId, self) + self, pAppId = common_send_location.getSelfAndParams(pAppId, self) + if not pAppId then pAppId = 1 end + local pHMIAppId = hmiAppIds[config["application" .. pAppId].registerAppInterfaceParams.appID] + local mobSession = common_send_location.getMobileSession(self, pAppId) + local requestId = self.hmiConnection:SendRequest("SDL.ActivateApp", { appID = pHMIAppId }) + EXPECT_HMIRESPONSE(requestId) + mobSession:ExpectNotification("OnHMIStatus", { hmiLevel = "FULL", audioStreamingState = "AUDIBLE", systemContext = "MAIN" }) + commonTestCases:DelayedExp(common_send_location.minTimeout) +end + +function common_send_location.backupHMICapabilities() + local hmiCapabilitiesFile = commonFunctions:read_parameter_from_smart_device_link_ini("HMICapabilities") + commonPreconditions:BackupFile(hmiCapabilitiesFile) +end + +function common_send_location.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 common_send_location.getHMIAppId(pAppId) + if not pAppId then pAppId = 1 end + return hmiAppIds[config["application" .. pAppId].registerAppInterfaceParams.appID] +end + +function common_send_location.getMobileSession(self, pAppId) + if not pAppId then pAppId = 1 end + return self["mobileSession" .. pAppId] +end + +function common_send_location.postconditions() + StopSDL() +end + +function common_send_location.rai_ptu(ptu_update_func, self) + self, ptu_update_func = common_send_location.getSelfAndParams(ptu_update_func, self) + common_send_location.rai_ptu_n(1, ptu_update_func, self) +end + +function common_send_location.rai_ptu_n(id, ptu_update_func, self) + self, id, ptu_update_func = common_send_location.getSelfAndParams(id, ptu_update_func, 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 + 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, ptu_update_func) + end) + 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 common_send_location.rai_n(id, self) + self, id = common_send_location.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 common_send_location.restoreHMICapabilities() + local hmiCapabilitiesFile = commonFunctions:read_parameter_from_smart_device_link_ini("HMICapabilities") + commonPreconditions:RestoreFile(hmiCapabilitiesFile) +end + +function common_send_location.start(pHMIParams, self) + self, pHMIParams = common_send_location.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") + allow_sdl(self) + end) + end) + end) + end) +end + +function common_send_location.unregisterApp(pAppId, self) + local mobSession = common_send_location.getMobileSession(self, pAppId) + local hmiAppId = common_send_location.getHMIAppId(pAppId) + local cid = mobSession:SendRPC("UnregisterAppInterface",{}) + EXPECT_HMINOTIFICATION("BasicCommunication.OnAppUnregistered", { appID = hmiAppId, unexpectedDisconnect = false }) + mobSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS"}) +end + +return common_send_location From 8c68d6b4be6f0e80ae1b68b7fd08f35c9c15104c Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Mon, 11 Sep 2017 17:53:50 +0300 Subject: [PATCH 02/29] Folder for SendLocation tests --- test_scripts/API/SendLocation/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test_scripts/API/SendLocation/.gitkeep diff --git a/test_scripts/API/SendLocation/.gitkeep b/test_scripts/API/SendLocation/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From ed582afe6e91b4813c2a2d9d0aafd61564ca6445 Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Tue, 12 Sep 2017 14:27:55 +0300 Subject: [PATCH 03/29] fix ptu in common_send_location --- .../SendLocation/001_SendLocation_success.lua | 5 +++++ .../API/SendLocation/common_send_location.lua | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/test_scripts/API/SendLocation/001_SendLocation_success.lua b/test_scripts/API/SendLocation/001_SendLocation_success.lua index 3cc0d0036f..545be66960 100644 --- a/test_scripts/API/SendLocation/001_SendLocation_success.lua +++ b/test_scripts/API/SendLocation/001_SendLocation_success.lua @@ -63,6 +63,11 @@ local request_params = { local function send_location(params, self) local cid = self.mobileSession1:SendRPC("SendLocation", params) + local deviceID = "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0" + params.locationImage.value = common_send_location.getPathToSDL() .. "/storage/" + params.locationImage.value = params.locationImage.value .. common_send_location.getHMIAppId(1) .. "_" .. deviceID + params.locationImage.value = params.locationImage.value .. "icon.png" + EXPECT_HMICALL("Navigation.SendLocation", params) :Do(function(_,data) --hmi side: sending Navigation.SendLocation response diff --git a/test_scripts/API/SendLocation/common_send_location.lua b/test_scripts/API/SendLocation/common_send_location.lua index d1db5576c1..105ebfc03d 100644 --- a/test_scripts/API/SendLocation/common_send_location.lua +++ b/test_scripts/API/SendLocation/common_send_location.lua @@ -7,12 +7,14 @@ config.defaultProtocolVersion = 2 config.ValidateSchema = false --[[ Required Shared libraries ]] +local mobile_session = require("mobile_session") +local json = require("modules/json") +local config = require("modules/config") + 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 mobile_session = require("mobile_session") -local json = require("modules/json") local hmi_values = require("user_modules/hmi_values") --[[ Local Variables ]] @@ -82,9 +84,9 @@ local function ptu(self, ptu_update_func) self.hmiConnection:SendNotification("BasicCommunication.OnSystemRequest", { requestType = "PROPRIETARY", fileName = pts_file_name }) getPTUFromPTS(ptu_table) local function updatePTU(tbl) - tbl.policy_table.functional_groupings.SendLocation.parameters = {} - tbl.policy_table.functional_groupings.SendLocation.parameters[1] = "longitudeDegrees" - tbl.policy_table.functional_groupings.SendLocation.parameters[2] = "latitudeDegrees" + tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters = {} + tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters[1] = "longitudeDegrees" + tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters[2] = "latitudeDegrees" tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.appID] = common_send_location.getSendLocationConfig() end updatePTU(ptu_table) @@ -114,6 +116,7 @@ local function ptu(self, ptu_update_func) EXPECT_HMICALL("BasicCommunication.SystemRequest") :Do(function(_, d3) self.hmiConnection:SendResponse(d3.id, "BasicCommunication.SystemRequest", "SUCCESS", { }) + os.execute("cp /tmp/fs/mp/images/ivsu_cache/PolicyTableUpdate ~/ptu.json") self.hmiConnection:SendNotification("SDL.OnReceivedPolicyUpdate", { policyfile = policy_file_path .. "/" .. policy_file_name }) end) mobileSession:ExpectResponse(corIdSystemRequest, { success = true, resultCode = "SUCCESS" }) @@ -178,6 +181,10 @@ function common_send_location.getMobileSession(self, pAppId) return self["mobileSession" .. pAppId] end +function common_send_location.getPathToSDL() + return config.pathToSDL +end + function common_send_location.postconditions() StopSDL() end From add13fa70618ef1a0ead422a85bd18d3652b8175 Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Tue, 12 Sep 2017 14:34:07 +0300 Subject: [PATCH 04/29] removed redundant function in script, appropriate logic already in common --- test_scripts/API/SendLocation/001_SendLocation_success.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test_scripts/API/SendLocation/001_SendLocation_success.lua b/test_scripts/API/SendLocation/001_SendLocation_success.lua index 545be66960..ba21634606 100644 --- a/test_scripts/API/SendLocation/001_SendLocation_success.lua +++ b/test_scripts/API/SendLocation/001_SendLocation_success.lua @@ -77,10 +77,6 @@ local function send_location(params, self) self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) end -local function ptu_update_func(tbl) - tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.appID].groups = { "Base-4", "SendLocation" } -end - local function put_file(file_name, self) local CorIdPutFile = self.mobileSession1:SendRPC( "PutFile", From 832d6254407af7ab00528891f2420dde899259ac Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Tue, 12 Sep 2017 16:49:54 +0300 Subject: [PATCH 05/29] fix hmiAppId to mobileAppId correction after review - renamed module, changed description, added function correction after review - added missed parameter millisecond correction after review - added check of info message corrections after review - functions renaming, delete redundant functions corrections after review - renamed common, fix in getMobileSession --- .../SendLocation/001_SendLocation_success.lua | 81 +++++++----- ...nd_location.lua => commonSendLocation.lua} | 117 +++++++++--------- 2 files changed, 110 insertions(+), 88 deletions(-) rename test_scripts/API/SendLocation/{common_send_location.lua => commonSendLocation.lua} (71%) diff --git a/test_scripts/API/SendLocation/001_SendLocation_success.lua b/test_scripts/API/SendLocation/001_SendLocation_success.lua index ba21634606..11afa34f2e 100644 --- a/test_scripts/API/SendLocation/001_SendLocation_success.lua +++ b/test_scripts/API/SendLocation/001_SendLocation_success.lua @@ -1,27 +1,44 @@ --------------------------------------------------------------------------------------------------- --- User story: https://github.com/smartdevicelink/sdl_requirements/issues/3 --- Use case: https://github.com/smartdevicelink/sdl_requirements/blob/master/detailed_docs/SetInteriorVehicleData.md +-- 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: --- [SDL_RC] Set available control module settings SetInteriorVehicleData +-- SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters -- -- Description: --- In case: --- 1) Application is registered with REMOTE_CONTROL appHMIType --- 2) and sends valid SetInteriorVehicleData RPC with valid parameters --- SDL must: --- 1) Transfer this request to HMI --- 2) Respond with received from HMI +-- App sends SendLocation will 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 common_send_location = require('test_scripts/API/SendLocation/common_send_location') +local commonSendLocation = require('test_scripts/API/SendLocation/commonSendLocation') --[[ Local Variables ]] local request_params = { longitudeDegrees = 1.1, latitudeDegrees = 1.1, + addressLines = + { + "line1", + "line2", + }, address = { countryName = "countryName", countryCode = "countryName", @@ -33,7 +50,8 @@ local request_params = { thoroughfare = "thoroughfare", subThoroughfare = "subThoroughfare" }, - timestamp = { + timeStamp = { + millisecond = 0, second = 40, minute = 30, hour = 14, @@ -45,11 +63,6 @@ local request_params = { }, locationName = "location Name", locationDescription = "location Description", - addressLines = - { - "line1", - "line2", - }, phoneNumber = "phone Number", deliveryMode = "PROMPT", locationImage = @@ -63,10 +76,11 @@ local request_params = { local function send_location(params, self) local cid = self.mobileSession1:SendRPC("SendLocation", params) - local deviceID = "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0" - params.locationImage.value = common_send_location.getPathToSDL() .. "/storage/" - params.locationImage.value = params.locationImage.value .. common_send_location.getHMIAppId(1) .. "_" .. deviceID - params.locationImage.value = params.locationImage.value .. "icon.png" + 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) @@ -75,28 +89,35 @@ local function send_location(params, self) 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 -local function put_file(file_name, self) +local function put_file(self) local CorIdPutFile = self.mobileSession1:SendRPC( "PutFile", - {syncFileName = file_name, fileType = "GRAPHIC_PNG", persistentFile = false, systemFile = false}, + {syncFileName = "icon.png", fileType = "GRAPHIC_PNG", persistentFile = false, systemFile = false}, "files/icon.png") self.mobileSession1:ExpectResponse(CorIdPutFile, { success = true, resultCode = "SUCCESS"}) - :Timeout(10000) end --[[ Scenario ]] runner.Title("Preconditions") -runner.Step("Clean environment", common_send_location.preconditions) -runner.Step("Start SDL, HMI, connect Mobile, start Session", common_send_location.start) -runner.Step("RAI, PTU", common_send_location.rai_ptu) -runner.Step("Activate App", common_send_location.activate_app) -runner.Step("Upload file", put_file, {"icon.png"}) +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", put_file) runner.Title("Test") -runner.Step("SendLocation - all params ", send_location, { request_params }) +runner.Step("SendLocation - all params", send_location, { request_params }) runner.Title("Postconditions") -runner.Step("Stop SDL", common_send_location.postconditions) +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/SendLocation/common_send_location.lua b/test_scripts/API/SendLocation/commonSendLocation.lua similarity index 71% rename from test_scripts/API/SendLocation/common_send_location.lua rename to test_scripts/API/SendLocation/commonSendLocation.lua index 105ebfc03d..6bf7ee9e8f 100644 --- a/test_scripts/API/SendLocation/common_send_location.lua +++ b/test_scripts/API/SendLocation/commonSendLocation.lua @@ -1,33 +1,30 @@ --------------------------------------------------------------------------------------------------- --- RC common module +-- SendLocation common module --------------------------------------------------------------------------------------------------- --[[ General configuration parameters ]] config.deviceMAC = "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0" config.defaultProtocolVersion = 2 -config.ValidateSchema = false --[[ Required Shared libraries ]] local mobile_session = require("mobile_session") local json = require("modules/json") -local config = require("modules/config") 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 hmi_values = require("user_modules/hmi_values") --[[ Local Variables ]] local ptu_table = {} local hmiAppIds = {} -local common_send_location = {} +local commonSendLocation = {} -common_send_location.timeout = 2000 -common_send_location.minTimeout = 500 -common_send_location.DEFAULT = "Default" +commonSendLocation.timeout = 2000 +commonSendLocation.minTimeout = 500 +commonSendLocation.DEFAULT = "Default" -local function allow_sdl(self) +local function allowSDL(self) self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality", { allowed = true, source = "GUI", device = { id = config.deviceMAC, name = "127.0.0.1" } }) end @@ -38,7 +35,7 @@ local function checkIfPTSIsSentAsBinary(bin_data) end end -function common_send_location.getSendLocationConfig() +function commonSendLocation.getSendLocationConfig() return { keep_context = false, steal_focus = false, @@ -58,17 +55,17 @@ local function getPTUFromPTS(tbl) tbl.policy_table.module_config.preloaded_date = nil end -local function jsonFileToTable(file_name) - local f = io.open(file_name, "r") +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, ptu_update_func) +local function ptu(self, id, pUpdateFunction) local function getAppsCount() local count = 0 - for _, _ in pairs(hmiAppIds) do + for _ in pairs(hmiAppIds) do count = count + 1 end return count @@ -87,11 +84,11 @@ local function ptu(self, ptu_update_func) tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters = {} tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters[1] = "longitudeDegrees" tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters[2] = "latitudeDegrees" - tbl.policy_table.app_policies[config.application1.registerAppInterfaceParams.appID] = common_send_location.getSendLocationConfig() + tbl.policy_table.app_policies[commonSendLocation.getMobileAppId(id)] = commonSendLocation.getSendLocationConfig() end updatePTU(ptu_table) - if ptu_update_func then - ptu_update_func(ptu_table) + if pUpdateFunction then + pUpdateFunction(ptu_table) end local function tableToJsonFile(tbl, file_name) local f = io.open(file_name, "w") @@ -106,17 +103,16 @@ local function ptu(self, ptu_update_func) :Timeout(11000) for id = 1, getAppsCount() do - local mobileSession = common_send_location.getMobileSession(self, id) + local mobileSession = commonSendLocation.getMobileSession(id, self) mobileSession:ExpectNotification("OnSystemRequest", { requestType = "PROPRIETARY" }) :Do(function(_, d2) - -- print("App ".. id .. " was used for PTU") + 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", { }) - os.execute("cp /tmp/fs/mp/images/ivsu_cache/PolicyTableUpdate ~/ptu.json") self.hmiConnection:SendNotification("SDL.OnReceivedPolicyUpdate", { policyfile = policy_file_path .. "/" .. policy_file_name }) end) mobileSession:ExpectResponse(corIdSystemRequest, { success = true, resultCode = "SUCCESS" }) @@ -127,7 +123,7 @@ local function ptu(self, ptu_update_func) os.remove(ptu_file_name) end -function common_send_location.preconditions() +function commonSendLocation.preconditions() commonFunctions:SDLForceStop() commonSteps:DeletePolicyTable() commonSteps:DeleteLogsFiles() @@ -135,23 +131,27 @@ end --[[Module functions]] -function common_send_location.activate_app(pAppId, self) - self, pAppId = common_send_location.getSelfAndParams(pAppId, self) +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 = common_send_location.getMobileSession(self, pAppId) + 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(common_send_location.minTimeout) + commonTestCases:DelayedExp(commonSendLocation.minTimeout) end -function common_send_location.backupHMICapabilities() +function commonSendLocation.backupHMICapabilities() local hmiCapabilitiesFile = commonFunctions:read_parameter_from_smart_device_link_ini("HMICapabilities") commonPreconditions:BackupFile(hmiCapabilitiesFile) end -function common_send_location.getSelfAndParams(...) +function commonSendLocation.getDeviceMAC() + return config.deviceMAC +end + +function commonSendLocation.getSelfAndParams(...) local out = { } local selfIdx = nil for i,v in pairs({...}) do @@ -171,59 +171,60 @@ function common_send_location.getSelfAndParams(...) return table.unpack(out, 1, table.maxn(out)) end -function common_send_location.getHMIAppId(pAppId) +function commonSendLocation.getHMIAppId(pAppId) if not pAppId then pAppId = 1 end return hmiAppIds[config["application" .. pAppId].registerAppInterfaceParams.appID] end -function common_send_location.getMobileSession(self, pAppId) +function commonSendLocation.getMobileSession(pAppId, self) + self, pAppId = commonSendLocation.getSelfAndParams(pAppId, self) if not pAppId then pAppId = 1 end return self["mobileSession" .. pAppId] end -function common_send_location.getPathToSDL() - return config.pathToSDL +function commonSendLocation.getMobileAppId(pAppId) + if not pAppId then pAppId = 1 end + return config["application" .. pAppId].registerAppInterfaceParams.appID end -function common_send_location.postconditions() - StopSDL() +function commonSendLocation.getPathToSDL() + return config.pathToSDL end -function common_send_location.rai_ptu(ptu_update_func, self) - self, ptu_update_func = common_send_location.getSelfAndParams(ptu_update_func, self) - common_send_location.rai_ptu_n(1, ptu_update_func, self) +function commonSendLocation.postconditions() + StopSDL() end -function common_send_location.rai_ptu_n(id, ptu_update_func, self) - self, id, ptu_update_func = common_send_location.getSelfAndParams(id, ptu_update_func, self) - if not id then id = 1 end - self["mobileSession" .. id] = mobile_session.MobileSession(self, self.mobileConnection) - self["mobileSession" .. id]:StartService(7) +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" .. id]:SendRPC("RegisterAppInterface", config["application" .. id].registerAppInterfaceParams) - EXPECT_HMINOTIFICATION("BasicCommunication.OnAppRegistered", { application = { appName = config["application" .. id].registerAppInterfaceParams.appName } }) + 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" .. id].registerAppInterfaceParams.appID] = d1.params.application.appID + 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, ptu_update_func) + ptu(self, pAppId, pUpdateFunction) end) end) - self["mobileSession" .. id]:ExpectResponse(corId, { success = true, resultCode = "SUCCESS" }) + self["mobileSession" .. pAppId]:ExpectResponse(corId, { success = true, resultCode = "SUCCESS" }) :Do(function() - self["mobileSession" .. id]:ExpectNotification("OnHMIStatus", { hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN" }) + self["mobileSession" .. pAppId]:ExpectNotification("OnHMIStatus", { hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN" }) :Times(AtLeast(1)) -- issue with SDL --> notification is sent twice - self["mobileSession" .. id]:ExpectNotification("OnPermissionsChange") + self["mobileSession" .. pAppId]:ExpectNotification("OnPermissionsChange") end) end) end -function common_send_location.rai_n(id, self) - self, id = common_send_location.getSelfAndParams(id, self) +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) @@ -242,13 +243,13 @@ function common_send_location.rai_n(id, self) end) end -function common_send_location.restoreHMICapabilities() +function commonSendLocation.restoreHMICapabilities() local hmiCapabilitiesFile = commonFunctions:read_parameter_from_smart_device_link_ini("HMICapabilities") commonPreconditions:RestoreFile(hmiCapabilitiesFile) end -function common_send_location.start(pHMIParams, self) - self, pHMIParams = common_send_location.getSelfAndParams(pHMIParams, self) +function commonSendLocation.start(pHMIParams, self) + self, pHMIParams = commonSendLocation.getSelfAndParams(pHMIParams, self) self:runSDL() commonFunctions:waitForSDLStart(self) :Do(function() @@ -261,19 +262,19 @@ function common_send_location.start(pHMIParams, self) self:connectMobile() :Do(function() commonFunctions:userPrint(35, "Mobile connected") - allow_sdl(self) + allowSDL(self) end) end) end) end) end -function common_send_location.unregisterApp(pAppId, self) - local mobSession = common_send_location.getMobileSession(self, pAppId) - local hmiAppId = common_send_location.getHMIAppId(pAppId) +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 -return common_send_location +return commonSendLocation From 31f49097b4f64a15fea459680edc9b8044a11b83 Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Mon, 18 Sep 2017 14:01:50 +0300 Subject: [PATCH 06/29] Added test checks retransfer of HMI result Codes - 002_SendLocation_transfer_result_code.lua --- .../002_SendLocation_transfer_result_code.lua | 88 +++++++++++++++++++ .../API/SendLocation/commonSendLocation.lua | 32 +++++++ 2 files changed, 120 insertions(+) create mode 100644 test_scripts/API/SendLocation/002_SendLocation_transfer_result_code.lua diff --git a/test_scripts/API/SendLocation/002_SendLocation_transfer_result_code.lua b/test_scripts/API/SendLocation/002_SendLocation_transfer_result_code.lua new file mode 100644 index 0000000000..bb6d0b2b1f --- /dev/null +++ b/test_scripts/API/SendLocation/002_SendLocation_transfer_result_code.lua @@ -0,0 +1,88 @@ +--------------------------------------------------------------------------------------------------- +-- 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 will 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/SendLocation/commonSendLocation') + +--[[ Local Variables ]] +local request_params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 +} + +--[[ Local Functions ]] +local function sendLocationSuccess(params, resultCodeValue, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendResponse(data.id, data.method, resultCodeValue, {}) + end) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = resultCodeValue }) +end + +local function sendLocationFailure(params, resultCodeValue, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendError(data.id, data.method, resultCodeValue, resultCodeValue) + end) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = resultCodeValue }) + :ValidIf (function(_,data) + if data.payload.info then + return true + else + print("SDL doesn't resend info parameter to mobile App.") + 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", put_file) + +runner.Title("Test") +for _, resultCodeValue in pairs(commonSendLocation.successResultCodes) do + runner.Step("SendLocation - " .. resultCodeValue, sendLocationSuccess, {request_params, resultCodeValue}) +end + +for _, resultCodeValue in pairs(commonSendLocation.failureResultCodes) do + runner.Step("SendLocation - " .. resultCodeValue, sendLocationFailure, {request_params, resultCodeValue}) +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/SendLocation/commonSendLocation.lua b/test_scripts/API/SendLocation/commonSendLocation.lua index 6bf7ee9e8f..cdad5742f5 100644 --- a/test_scripts/API/SendLocation/commonSendLocation.lua +++ b/test_scripts/API/SendLocation/commonSendLocation.lua @@ -23,6 +23,38 @@ local commonSendLocation = {} commonSendLocation.timeout = 2000 commonSendLocation.minTimeout = 500 commonSendLocation.DEFAULT = "Default" +commonSendLocation.successResultCodes = { + "SUCCESS", + "RETRY", + "WARNINGS", + "SAVED" +} + +commonSendLocation.failureResultCodes = { + "UNSUPPORTED_REQUEST", + "UNSUPPORTED_RESOURCE", + "DISALLOWED", + "REJECTED", + "ABORTED", + "IGNORED", + "IN_USE" , + "DATA_NOT_AVAILABLE", + "TIMED_OUT", + "INVALID_DATA", + "CHAR_LIMIT_EXCEEDED", + "INVALID_ID", + "DUPLICATE_NAME", + "APPLICATION_NOT_REGISTERED", + "WRONG_LANGUAGE", + "OUT_OF_MEMORY", + "TOO_MANY_PENDING_REQUESTS", + "NO_APPS_REGISTERED", + "NO_DEVICES_CONNECTED", + "GENERIC_ERROR", + "USER_DISALLOWED", + "TRUNCATED_DATA", + "READ_ONLY" +} local function allowSDL(self) self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality", From 23a0a245049c9651de1edb8c44ca5111968b21d4 Mon Sep 17 00:00:00 2001 From: Igor Kovalenko Date: Fri, 29 Sep 2017 16:08:21 +0300 Subject: [PATCH 07/29] SendLocation checks fix of cut off empty address script removed whitespaces, putFile moved to common corrected ValidIf return signature removed redundant empty lines corrected descriptions of all tests according to comments --- .../{ => Navigation}/SendLocation/.gitkeep | 0 .../SendLocation/001_SendLocation_success.lua | 38 ++--- .../002_SendLocation_transfer_result_code.lua | 41 +++-- .../003_SendLocation_without_address.lua | 96 ++++++++++++ .../004_SendLocation_wo_mandatory.lua | 107 +++++++++++++ ...ocation_wo_mandatory_with_deliveryMode.lua | 97 ++++++++++++ .../006_SendLocation_wo_deliveryMode.lua | 112 +++++++++++++ .../007_SendLocation_invalid_types.lua | 113 +++++++++++++ .../008_SendLocation_invalid_json.lua | 61 ++++++++ .../009_SendLocation_boundary.lua | 148 ++++++++++++++++++ .../010_SendLocation_out_of_bound.lua | 102 ++++++++++++ .../011_SendLocation_whitespaces.lua | 105 +++++++++++++ .../012_SendLocation_cut_off_address.lua | 110 +++++++++++++ .../013_SendLocation_unsupported_resource.lua | 81 ++++++++++ ...14_SendLocation_unsupported_capability.lua | 79 ++++++++++ .../commonSendLocation.lua | 74 ++++++--- 16 files changed, 1304 insertions(+), 60 deletions(-) rename test_scripts/API/{ => Navigation}/SendLocation/.gitkeep (100%) rename test_scripts/API/{ => Navigation}/SendLocation/001_SendLocation_success.lua (78%) rename test_scripts/API/{ => Navigation}/SendLocation/002_SendLocation_transfer_result_code.lua (69%) create mode 100644 test_scripts/API/Navigation/SendLocation/003_SendLocation_without_address.lua create mode 100644 test_scripts/API/Navigation/SendLocation/004_SendLocation_wo_mandatory.lua create mode 100644 test_scripts/API/Navigation/SendLocation/005_SendLocation_wo_mandatory_with_deliveryMode.lua create mode 100644 test_scripts/API/Navigation/SendLocation/006_SendLocation_wo_deliveryMode.lua create mode 100644 test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua create mode 100644 test_scripts/API/Navigation/SendLocation/008_SendLocation_invalid_json.lua create mode 100644 test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua create mode 100644 test_scripts/API/Navigation/SendLocation/010_SendLocation_out_of_bound.lua create mode 100644 test_scripts/API/Navigation/SendLocation/011_SendLocation_whitespaces.lua create mode 100644 test_scripts/API/Navigation/SendLocation/012_SendLocation_cut_off_address.lua create mode 100644 test_scripts/API/Navigation/SendLocation/013_SendLocation_unsupported_resource.lua create mode 100644 test_scripts/API/Navigation/SendLocation/014_SendLocation_unsupported_capability.lua rename test_scripts/API/{SendLocation => Navigation}/commonSendLocation.lua (85%) diff --git a/test_scripts/API/SendLocation/.gitkeep b/test_scripts/API/Navigation/SendLocation/.gitkeep similarity index 100% rename from test_scripts/API/SendLocation/.gitkeep rename to test_scripts/API/Navigation/SendLocation/.gitkeep diff --git a/test_scripts/API/SendLocation/001_SendLocation_success.lua b/test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua similarity index 78% rename from test_scripts/API/SendLocation/001_SendLocation_success.lua rename to test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua index 11afa34f2e..5bbac853e4 100644 --- a/test_scripts/API/SendLocation/001_SendLocation_success.lua +++ b/test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua @@ -7,7 +7,7 @@ -- SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters -- -- Description: --- App sends SendLocation will all available parameters. +-- App sends SendLocation with all available parameters. -- Pre-conditions: -- a. HMI and SDL are started @@ -28,17 +28,17 @@ --------------------------------------------------------------------------------------------------- --[[ Required Shared libraries ]] local runner = require('user_modules/script_runner') -local commonSendLocation = require('test_scripts/API/SendLocation/commonSendLocation') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') --[[ Local Variables ]] -local request_params = { +local requestParams = { longitudeDegrees = 1.1, latitudeDegrees = 1.1, - addressLines = - { + addressLines = + { "line1", "line2", - }, + }, address = { countryName = "countryName", countryCode = "countryName", @@ -65,15 +65,15 @@ local request_params = { locationDescription = "location Description", phoneNumber = "phone Number", deliveryMode = "PROMPT", - locationImage = - { + locationImage = + { value = "icon.png", imageType = "DYNAMIC", } } --[[ Local Functions ]] -local function send_location(params, self) +local function sendLocation(params, self) local cid = self.mobileSession1:SendRPC("SendLocation", params) params.appID = commonSendLocation.getHMIAppId() @@ -81,43 +81,31 @@ local function send_location(params, self) params.locationImage.value = commonSendLocation.getPathToSDL() .. "storage/" .. commonSendLocation.getMobileAppId(1) .. "_" .. deviceID .. "/icon.png" - EXPECT_HMICALL("Navigation.SendLocation", params) :Do(function(_,data) - --hmi side: sending Navigation.SendLocation response 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 false, "SDL sent redundant info parameter to mobile App " + else return true end end) end -local function put_file(self) - local CorIdPutFile = self.mobileSession1:SendRPC( - "PutFile", - {syncFileName = "icon.png", fileType = "GRAPHIC_PNG", persistentFile = false, systemFile = false}, - "files/icon.png") - - self.mobileSession1:ExpectResponse(CorIdPutFile, { 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", put_file) +runner.Step("Upload file", commonSendLocation.putFile, {"icon.png"}) runner.Title("Test") -runner.Step("SendLocation - all params", send_location, { request_params }) +runner.Step("SendLocation - all params", sendLocation, {requestParams}) runner.Title("Postconditions") runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_scripts/API/SendLocation/002_SendLocation_transfer_result_code.lua b/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua similarity index 69% rename from test_scripts/API/SendLocation/002_SendLocation_transfer_result_code.lua rename to test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua index bb6d0b2b1f..a3508846ec 100644 --- a/test_scripts/API/SendLocation/002_SendLocation_transfer_result_code.lua +++ b/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua @@ -1,13 +1,13 @@ --------------------------------------------------------------------------------------------------- -- 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 +-- Item: Use Case 1: Main Flow (Alternative flow 1) -- -- Requirement summary: --- SendLocation with address, longitudeDegrees, latitudeDegrees, deliveryMode and other parameters +-- SDL transfer HMI's result code to Mobile -- -- Description: --- App sends SendLocation will all available parameters. +-- App sends SendLocation will valid parameters, Navi interface is working. -- Pre-conditions: -- a. HMI and SDL are started @@ -28,10 +28,10 @@ --------------------------------------------------------------------------------------------------- --[[ Required Shared libraries ]] local runner = require('user_modules/script_runner') -local commonSendLocation = require('test_scripts/API/SendLocation/commonSendLocation') +local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') --[[ Local Variables ]] -local request_params = { +local requestParams = { longitudeDegrees = 1.1, latitudeDegrees = 1.1 } @@ -60,28 +60,45 @@ local function sendLocationFailure(params, resultCodeValue, self) :ValidIf (function(_,data) if data.payload.info then return true - else - print("SDL doesn't resend info parameter to mobile App.") - return true + else + return false, "SDL doesn't resend info parameter to mobile App." end end) end +local function sendLocationUnexpectedResponseFromHMI(params, resultCodeValue, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendError(data.id, data.method, resultCodeValue, resultCodeValue) + end) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) +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", put_file) -runner.Title("Test") +runner.Title("Test positive result codes") for _, resultCodeValue in pairs(commonSendLocation.successResultCodes) do - runner.Step("SendLocation - " .. resultCodeValue, sendLocationSuccess, {request_params, resultCodeValue}) + runner.Step("SendLocation - " .. resultCodeValue, sendLocationSuccess, {requestParams, resultCodeValue}) end +runner.Title("Test negative result codes") for _, resultCodeValue in pairs(commonSendLocation.failureResultCodes) do - runner.Step("SendLocation - " .. resultCodeValue, sendLocationFailure, {request_params, resultCodeValue}) + runner.Step("SendLocation - " .. resultCodeValue, sendLocationFailure, {requestParams, resultCodeValue}) +end + +runner.Title("Test not applicable for SendLocation result codes") +for _, resultCodeValue in pairs(commonSendLocation.unexpectedResultCodes) do + runner.Step("SendLocation - " .. resultCodeValue, + sendLocationUnexpectedResponseFromHMI, + {requestParams, resultCodeValue}) end runner.Title("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..c6eb5ccdc9 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua @@ -0,0 +1,113 @@ +--------------------------------------------------------------------------------------------------- +-- 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) + +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.Title("Test") + runner.Step("SendLocation-invalid-type-of-" .. tostring(key) .. "-" .. tostring(subKey), + sendLocation, + {parametersToSend}) + end + else + parametersToSend[key] = replaceType(value) + runner.Title("Test") + 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..ba59078572 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua @@ -0,0 +1,148 @@ +--------------------------------------------------------------------------------------------------- +-- 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 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 = string.rep("a", 251) .. ".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() + 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, {string.rep("a", 251) .. ".png"}) + +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/SendLocation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua similarity index 85% rename from test_scripts/API/SendLocation/commonSendLocation.lua rename to test_scripts/API/Navigation/commonSendLocation.lua index cdad5742f5..028baa8032 100644 --- a/test_scripts/API/SendLocation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -25,33 +25,35 @@ commonSendLocation.minTimeout = 500 commonSendLocation.DEFAULT = "Default" commonSendLocation.successResultCodes = { "SUCCESS", - "RETRY", - "WARNINGS", "SAVED" } commonSendLocation.failureResultCodes = { - "UNSUPPORTED_REQUEST", "UNSUPPORTED_RESOURCE", "DISALLOWED", "REJECTED", "ABORTED", - "IGNORED", + "INVALID_DATA", + "APPLICATION_NOT_REGISTERED", + "NO_APPS_REGISTERED", -- this code is equal to APPLICATION_NOT_REGISTERED in mobile API + "NO_DEVICES_CONNECTED", -- this code is equal to APPLICATION_NOT_REGISTERED in mobile API + "OUT_OF_MEMORY", + "TOO_MANY_PENDING_REQUESTS", + "GENERIC_ERROR", + "USER_DISALLOWED" +} + +commonSendLocation.unexpectedResultCodes = { + "WARNINGS", + "RETRY", + "UNSUPPORTED_REQUEST", "IN_USE" , "DATA_NOT_AVAILABLE", "TIMED_OUT", - "INVALID_DATA", "CHAR_LIMIT_EXCEEDED", "INVALID_ID", "DUPLICATE_NAME", - "APPLICATION_NOT_REGISTERED", "WRONG_LANGUAGE", - "OUT_OF_MEMORY", - "TOO_MANY_PENDING_REQUESTS", - "NO_APPS_REGISTERED", - "NO_DEVICES_CONNECTED", - "GENERIC_ERROR", - "USER_DISALLOWED", "TRUNCATED_DATA", "READ_ONLY" } @@ -110,7 +112,8 @@ local function ptu(self, id, pUpdateFunction) 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 }) + 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 = {} @@ -145,7 +148,8 @@ local function ptu(self, id, pUpdateFunction) 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 }) + self.hmiConnection:SendNotification("SDL.OnReceivedPolicyUpdate", + { policyfile = policy_file_path .. "/" .. policy_file_name }) end) mobileSession:ExpectResponse(corIdSystemRequest, { success = true, resultCode = "SUCCESS" }) end) @@ -170,7 +174,8 @@ function commonSendLocation.activateApp(pAppId, self) 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" }) + mobSession:ExpectNotification("OnHMIStatus", + {hmiLevel = "FULL", audioStreamingState = "AUDIBLE", systemContext = "MAIN"}) commonTestCases:DelayedExp(commonSendLocation.minTimeout) end @@ -179,6 +184,11 @@ function commonSendLocation.backupHMICapabilities() commonPreconditions:BackupFile(hmiCapabilitiesFile) end +function commonSendLocation.delayedExp(timeout) + if not timeout then timeout = commonSendLocation.timeout end + commonTestCases:DelayedExp(timeout) +end + function commonSendLocation.getDeviceMAC() return config.deviceMAC end @@ -227,17 +237,30 @@ 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 } }) + 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" }) + EXPECT_HMINOTIFICATION("SDL.OnStatusUpdate", + {status = "UPDATE_NEEDED"}, {status = "UPDATING"}, {status = "UP_TO_DATE" }) :Times(3) EXPECT_HMICALL("BasicCommunication.PolicyUpdate") :Do(function(_, d2) @@ -248,9 +271,11 @@ function commonSendLocation.registerApplicationWithPTU(pAppId, pUpdateFunction, 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(AtLeast(1)) -- issue with SDL --> notification is sent twice + 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 @@ -261,14 +286,17 @@ function commonSendLocation.registerApplication(id, self) 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 } }) + 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" }) + 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) From cc37e03e29223372513c777ae860cc9c08aedcc3 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 6 Oct 2017 17:20:16 +0300 Subject: [PATCH 08/29] Move title step outside of the loop --- .../Navigation/SendLocation/007_SendLocation_invalid_types.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua b/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua index c6eb5ccdc9..466b24dae3 100644 --- a/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua +++ b/test_scripts/API/Navigation/SendLocation/007_SendLocation_invalid_types.lua @@ -85,6 +85,7 @@ runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation. 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) @@ -97,14 +98,12 @@ for key,value in pairs(requestParams) do if (type(value) == "table") then for subKey,subValue in pairs(value) do parametersToSend[key][subKey] = replaceType(subValue) - runner.Title("Test") runner.Step("SendLocation-invalid-type-of-" .. tostring(key) .. "-" .. tostring(subKey), sendLocation, {parametersToSend}) end else parametersToSend[key] = replaceType(value) - runner.Title("Test") runner.Step("SendLocation-invalid-type-of-" .. tostring(key), sendLocation, {parametersToSend}) end end From db7095a765c0b0a60f11759adda0f264e3405574 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 6 Oct 2017 17:39:23 +0300 Subject: [PATCH 09/29] Add mapping for HMI and Mobile result codes --- .../002_SendLocation_transfer_result_code.lua | 18 ++++++++------ .../API/Navigation/commonSendLocation.lua | 24 +++++++++---------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua b/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua index a3508846ec..8704f18815 100644 --- a/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua +++ b/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua @@ -48,15 +48,19 @@ local function sendLocationSuccess(params, resultCodeValue, self) self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = resultCodeValue }) end -local function sendLocationFailure(params, resultCodeValue, self) +local function sendLocationFailure(params, resultCodeMap, self) local cid = self.mobileSession1:SendRPC("SendLocation", params) + local hmiCode = resultCodeMap.hmiCode + local mobileCode = resultCodeMap.mobileCode + if not mobileCode then mobileCode = hmiCode end + EXPECT_HMICALL("Navigation.SendLocation", params) :Do(function(_,data) - self.hmiConnection:SendError(data.id, data.method, resultCodeValue, resultCodeValue) + self.hmiConnection:SendError(data.id, data.method, hmiCode, hmiCode) end) - self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = resultCodeValue }) + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = mobileCode }) :ValidIf (function(_,data) if data.payload.info then return true @@ -86,17 +90,17 @@ runner.Step("Activate App", commonSendLocation.activateApp) runner.Title("Test positive result codes") for _, resultCodeValue in pairs(commonSendLocation.successResultCodes) do - runner.Step("SendLocation - " .. resultCodeValue, sendLocationSuccess, {requestParams, resultCodeValue}) + runner.Step("SendLocation " .. resultCodeValue, sendLocationSuccess, {requestParams, resultCodeValue}) end runner.Title("Test negative result codes") -for _, resultCodeValue in pairs(commonSendLocation.failureResultCodes) do - runner.Step("SendLocation - " .. resultCodeValue, sendLocationFailure, {requestParams, resultCodeValue}) +for _, resultCodeMap in pairs(commonSendLocation.failureResultCodes) do + runner.Step("SendLocation " .. resultCodeMap.hmiCode, sendLocationFailure, {requestParams, resultCodeMap}) end runner.Title("Test not applicable for SendLocation result codes") for _, resultCodeValue in pairs(commonSendLocation.unexpectedResultCodes) do - runner.Step("SendLocation - " .. resultCodeValue, + runner.Step("SendLocation " .. resultCodeValue, sendLocationUnexpectedResponseFromHMI, {requestParams, resultCodeValue}) end diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index 028baa8032..55c3eec56a 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -29,18 +29,18 @@ commonSendLocation.successResultCodes = { } commonSendLocation.failureResultCodes = { - "UNSUPPORTED_RESOURCE", - "DISALLOWED", - "REJECTED", - "ABORTED", - "INVALID_DATA", - "APPLICATION_NOT_REGISTERED", - "NO_APPS_REGISTERED", -- this code is equal to APPLICATION_NOT_REGISTERED in mobile API - "NO_DEVICES_CONNECTED", -- this code is equal to APPLICATION_NOT_REGISTERED in mobile API - "OUT_OF_MEMORY", - "TOO_MANY_PENDING_REQUESTS", - "GENERIC_ERROR", - "USER_DISALLOWED" + { hmiCode = "UNSUPPORTED_RESOURCE" }, + { hmiCode = "DISALLOWED" }, + { hmiCode = "REJECTED" }, + { hmiCode = "ABORTED" }, + { hmiCode = "INVALID_DATA" }, + { hmiCode = "APPLICATION_NOT_REGISTERED" }, + { hmiCode = "NO_APPS_REGISTERED", mobileCode = "APPLICATION_NOT_REGISTERED" }, + { hmiCode = "NO_DEVICES_CONNECTED", mobileCode = "APPLICATION_NOT_REGISTERED" }, + { hmiCode = "OUT_OF_MEMORY" }, + { hmiCode = "TOO_MANY_PENDING_REQUESTS" }, + { hmiCode = "GENERIC_ERROR" }, + { hmiCode = "USER_DISALLOWED" } } commonSendLocation.unexpectedResultCodes = { From b6f3b994c00f2a48d31d30d3bdf1c6b239d6468e Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 6 Oct 2017 18:50:10 +0300 Subject: [PATCH 10/29] Add new scripts based on found issues --- ...ory_params_and_disallowed_deliveryMode.lua | 74 +++++++++++++++ ...d_disallowed_locationName_deliveryMode.lua | 92 +++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 test_scripts/API/Navigation/SendLocation/015_SendLocation_with_mandatory_params_and_disallowed_deliveryMode.lua create mode 100644 test_scripts/API/Navigation/SendLocation/016_SendLocation_with_mandatory_params_allowed_and_disallowed_locationName_deliveryMode.lua 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..1abf531a51 --- /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 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 + for index, value in pairs(params) do + if ("deliveryMode" == value) then params[index] = nil 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, { 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", 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..78c88c749c --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/016_SendLocation_with_mandatory_params_allowed_and_disallowed_locationName_deliveryMode.lua @@ -0,0 +1,92 @@ +--------------------------------------------------------------------------------------------------- +-- 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 isContain(pTbl, pValue) + for _, v in pairs(pTbl) do + if v == pValue then return true end + end + return false +end + +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 + for index, value in pairs(params) do + if isContain(disallowedParams, value) then params[index] = nil 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, { 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) From 7fdfdc263169c713ad0e28dbbd7dac7d2bd48d2e Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Mon, 9 Oct 2017 14:19:26 +0300 Subject: [PATCH 11/29] Fix removing of elements in array --- ...cation_with_mandatory_params_and_disallowed_deliveryMode.lua | 2 +- ..._params_allowed_and_disallowed_locationName_deliveryMode.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 index 1abf531a51..3d4b133744 100644 --- 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 @@ -55,7 +55,7 @@ end local function pUpdateFunction(pTbl) local params = pTbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters for index, value in pairs(params) do - if ("deliveryMode" == value) then params[index] = nil end + if ("deliveryMode" == value) then table.remove(params, index) end end end 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 index 78c88c749c..618239f3bb 100644 --- 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 @@ -73,7 +73,7 @@ end local function pUpdateFunction(pTbl) local params = pTbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters for index, value in pairs(params) do - if isContain(disallowedParams, value) then params[index] = nil end + if isContain(disallowedParams, value) then table.remove(params, index) end end end From 42b264d7351b2c4571abab4372fa3526208fe23d Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Mon, 9 Oct 2017 14:22:37 +0300 Subject: [PATCH 12/29] Fix policy update - add all SendLocation parameters --- .../API/Navigation/commonSendLocation.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index 55c3eec56a..5d9e76d535 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -14,6 +14,10 @@ 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 mobile_api_loader = require("modules/api_loader") +local mobile_api = mobile_api_loader.init("data/MOBILE_API.xml") +local mobile_api_schema = mobile_api.interface["Ford Sync RAPI"] + --[[ Local Variables ]] local ptu_table = {} local hmiAppIds = {} @@ -58,6 +62,14 @@ commonSendLocation.unexpectedResultCodes = { "READ_ONLY" } +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 = config.deviceMAC, name = "127.0.0.1" } }) @@ -117,8 +129,9 @@ local function ptu(self, id, pUpdateFunction) getPTUFromPTS(ptu_table) local function updatePTU(tbl) tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters = {} - tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters[1] = "longitudeDegrees" - tbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters[2] = "latitudeDegrees" + 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) @@ -156,7 +169,7 @@ local function ptu(self, id, pUpdateFunction) :Times(AtMost(1)) end end) - os.remove(ptu_file_name) + -- os.remove(ptu_file_name) end function commonSendLocation.preconditions() From 8c3d306b71711384b5ce49e13f1cdb4cff16a35d Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Tue, 10 Oct 2017 10:39:57 +0300 Subject: [PATCH 13/29] Fix scripts on transferring HMI result codes --- .../002_SendLocation_transfer_result_code.lua | 105 ++++++------ .../API/Navigation/commonSendLocation.lua | 155 ++++++++++++++---- 2 files changed, 175 insertions(+), 85 deletions(-) diff --git a/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua b/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua index 8704f18815..4b47951782 100644 --- a/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua +++ b/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua @@ -28,82 +28,79 @@ --------------------------------------------------------------------------------------------------- --[[ Required Shared libraries ]] local runner = require('user_modules/script_runner') -local commonSendLocation = require('test_scripts/API/Navigation/commonSendLocation') +local common = require('test_scripts/API/Navigation/commonSendLocation') --[[ Local Variables ]] -local requestParams = { - longitudeDegrees = 1.1, - latitudeDegrees = 1.1 +local resultCodes = { + success = common.getSuccessResultCodes("SendLocation"), + failure = common.getFailureResultCodes("SendLocation"), + unexpected = common.getUnexpectedResultCodes("SendLocation") +} + +local params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 } --[[ Local Functions ]] -local function sendLocationSuccess(params, resultCodeValue, self) - local cid = self.mobileSession1:SendRPC("SendLocation", params) +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, resultCodeValue, {}) + 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 = resultCodeValue }) + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = pResultCodeMap.mobile }) end -local function sendLocationFailure(params, resultCodeMap, self) - local cid = self.mobileSession1:SendRPC("SendLocation", params) - - local hmiCode = resultCodeMap.hmiCode - local mobileCode = resultCodeMap.mobileCode - if not mobileCode then mobileCode = hmiCode end - - EXPECT_HMICALL("Navigation.SendLocation", params) - :Do(function(_,data) - self.hmiConnection:SendError(data.id, data.method, hmiCode, hmiCode) - end) +local function sendLocationUnsuccess(pResultCodeMap, isUnsupported, self) + local cid = self.mobileSession1:SendRPC("SendLocation", params) - self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = mobileCode }) - :ValidIf (function(_,data) - if data.payload.info then - return true - else - return false, "SDL doesn't resend info parameter to mobile App." - end + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(_,data) + self.hmiConnection:SendError(data.id, data.method, pResultCodeMap.hmi, "Error error") end) -end - -local function sendLocationUnexpectedResponseFromHMI(params, resultCodeValue, self) - local cid = self.mobileSession1:SendRPC("SendLocation", params) - EXPECT_HMICALL("Navigation.SendLocation", params) - :Do(function(_,data) - self.hmiConnection:SendError(data.id, data.method, resultCodeValue, resultCodeValue) + local appSuccess = false + local appResultCode = pResultCodeMap.mobile + if isUnsupported then + appResultCode = "GENERIC_ERROR" + end + + self.mobileSession1:ExpectResponse(cid, { success = appSuccess, resultCode = appResultCode }) + :ValidIf(function(_,data) + if not isUnsupported and not data.payload.info then + return false, "SDL doesn't resend info parameter to mobile App" + end + return true end) - - self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) 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 positive result codes") -for _, resultCodeValue in pairs(commonSendLocation.successResultCodes) do - runner.Step("SendLocation " .. resultCodeValue, sendLocationSuccess, {requestParams, resultCodeValue}) +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("Test negative result codes") -for _, resultCodeMap in pairs(commonSendLocation.failureResultCodes) do - runner.Step("SendLocation " .. resultCodeMap.hmiCode, sendLocationFailure, {requestParams, resultCodeMap}) +runner.Title("Erroneous codes") +for _, item in pairs(resultCodes.failure) do + runner.Step("SendLocation with " .. item.hmi .. " resultCode", sendLocationUnsuccess, { item, false }) end -runner.Title("Test not applicable for SendLocation result codes") -for _, resultCodeValue in pairs(commonSendLocation.unexpectedResultCodes) do - runner.Step("SendLocation " .. resultCodeValue, - sendLocationUnexpectedResponseFromHMI, - {requestParams, resultCodeValue}) +runner.Title("Unexpected codes") +for _, item in pairs(resultCodes.unexpected) do + runner.Step("SendLocation with " .. item.hmi .. " resultCode", sendLocationUnsuccess, { item, true }) end runner.Title("Postconditions") -runner.Step("Stop SDL", commonSendLocation.postconditions) +runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index 5d9e76d535..f4bef203f9 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -18,6 +18,10 @@ local mobile_api_loader = require("modules/api_loader") local mobile_api = mobile_api_loader.init("data/MOBILE_API.xml") local mobile_api_schema = mobile_api.interface["Ford Sync RAPI"] +local hmi_api_loader = require("modules/api_loader") +local hmi_api = hmi_api_loader.init("data/HMI_API.xml") +local hmi_api_schema = hmi_api.interface["Common"] + --[[ Local Variables ]] local ptu_table = {} local hmiAppIds = {} @@ -26,40 +30,18 @@ local commonSendLocation = {} commonSendLocation.timeout = 2000 commonSendLocation.minTimeout = 500 -commonSendLocation.DEFAULT = "Default" -commonSendLocation.successResultCodes = { + +local successCodes = { "SUCCESS", + "WARNINGS", + "WRONG_LANGUAGE", + "RETRY", "SAVED" } -commonSendLocation.failureResultCodes = { - { hmiCode = "UNSUPPORTED_RESOURCE" }, - { hmiCode = "DISALLOWED" }, - { hmiCode = "REJECTED" }, - { hmiCode = "ABORTED" }, - { hmiCode = "INVALID_DATA" }, - { hmiCode = "APPLICATION_NOT_REGISTERED" }, - { hmiCode = "NO_APPS_REGISTERED", mobileCode = "APPLICATION_NOT_REGISTERED" }, - { hmiCode = "NO_DEVICES_CONNECTED", mobileCode = "APPLICATION_NOT_REGISTERED" }, - { hmiCode = "OUT_OF_MEMORY" }, - { hmiCode = "TOO_MANY_PENDING_REQUESTS" }, - { hmiCode = "GENERIC_ERROR" }, - { hmiCode = "USER_DISALLOWED" } -} - -commonSendLocation.unexpectedResultCodes = { - "WARNINGS", - "RETRY", - "UNSUPPORTED_REQUEST", - "IN_USE" , - "DATA_NOT_AVAILABLE", - "TIMED_OUT", - "CHAR_LIMIT_EXCEEDED", - "INVALID_ID", - "DUPLICATE_NAME", - "WRONG_LANGUAGE", - "TRUNCATED_DATA", - "READ_ONLY" +local nonDirectResultCodes = { + { mobile = "APPLICATION_NOT_REGISTERED", hmi = "NO_APPS_REGISTERED" }, + { mobile = "APPLICATION_NOT_REGISTERED", hmi = "NO_DEVICES_CONNECTED" } } local function getAvailableParams() @@ -165,11 +147,11 @@ local function ptu(self, id, pUpdateFunction) { 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) - -- os.remove(ptu_file_name) end function commonSendLocation.preconditions() @@ -350,4 +332,115 @@ function commonSendLocation.unregisterApp(pAppId, self) 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 isContain(getMobileResultCodes(), v) then + table.insert(out, { mobile = v, hmi = v }) + elseif isContain(commonSendLocation.getKeysFromItemsTable(nonDirectResultCodes, "hmi"), v) then + for _, item in pairs(nonDirectResultCodes) do + if item.hmi == v then + table.insert(out, { mobile = item.mobile, hmi = item.hmi }) + end + end + else + table.insert(out, { mobile = nil, hmi = v }) + 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 + if item.mobile ~= nil and not isContain(getExpectedResultCodes(pFunctionName), item.mobile) then + table.insert(out, { mobile = item.mobile, hmi = item.hmi }) + 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) +end + return commonSendLocation From 38043ee43871f618981a39d4acb63c6069368032 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Tue, 10 Oct 2017 17:52:34 +0300 Subject: [PATCH 14/29] Fix issue with removing table items --- ...h_mandatory_params_and_disallowed_deliveryMode.lua | 10 +++++----- ...lowed_and_disallowed_locationName_deliveryMode.lua | 11 +---------- test_scripts/API/Navigation/commonSendLocation.lua | 11 +++++++++++ 3 files changed, 17 insertions(+), 15 deletions(-) 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 index 3d4b133744..10b3d02dac 100644 --- 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 @@ -33,13 +33,15 @@ local requestParams = { 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", + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", { longitudeDegrees = 1.1, latitudeDegrees = 1.1 }) end) :ValidIf(function(_, data) @@ -54,9 +56,7 @@ end local function pUpdateFunction(pTbl) local params = pTbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters - for index, value in pairs(params) do - if ("deliveryMode" == value) then table.remove(params, index) end - end + commonSendLocation.filterTable(params, disallowedParams) end --[[ Scenario ]] @@ -68,7 +68,7 @@ runner.Step("Activate App", commonSendLocation.activateApp) runner.Step("Upload file", commonSendLocation.putFile, { "icon.png" }) runner.Title("Test") -runner.Step("SendLocation with both mandatory params", sendLocation) +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 index 618239f3bb..9dddcd297e 100644 --- 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 @@ -39,13 +39,6 @@ local requestParams = { local disallowedParams = { "deliveryMode", "locationName" } --[[ Local Functions ]] -local function isContain(pTbl, pValue) - for _, v in pairs(pTbl) do - if v == pValue then return true end - end - return false -end - local function sendLocation(self) local mobileSession = commonSendLocation.getMobileSession(self, 1) local cid = self.mobileSession1:SendRPC("SendLocation", requestParams) @@ -72,9 +65,7 @@ end local function pUpdateFunction(pTbl) local params = pTbl.policy_table.functional_groupings.SendLocation.rpcs.SendLocation.parameters - for index, value in pairs(params) do - if isContain(disallowedParams, value) then table.remove(params, index) end - end + commonSendLocation.filterTable(params, disallowedParams) end --[[ Scenario ]] diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index f4bef203f9..80172cf13b 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -443,4 +443,15 @@ function commonSendLocation.printResultCodes(pResultCodes) printItem(pResultCodes.unexpected) end +function commonSendLocation.filterTable(pSourceTbl, pValuesTbl) + local i = 1 + while i <= #pSourceTbl do + if isContain(pValuesTbl, pSourceTbl[i]) then + table.remove(pSourceTbl, i) + else + i = i + 1 + end + end +end + return commonSendLocation From 1db7f9a5adc98048e098aafbdf485e8b80f988f9 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Tue, 10 Oct 2017 18:19:54 +0300 Subject: [PATCH 15/29] Remove .gitkeep file --- test_scripts/API/Navigation/SendLocation/.gitkeep | 0 test_scripts/API/Navigation/commonSendLocation.lua | 13 +++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) delete mode 100644 test_scripts/API/Navigation/SendLocation/.gitkeep diff --git a/test_scripts/API/Navigation/SendLocation/.gitkeep b/test_scripts/API/Navigation/SendLocation/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index 80172cf13b..10bbff36b5 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -443,11 +443,16 @@ function commonSendLocation.printResultCodes(pResultCodes) printItem(pResultCodes.unexpected) end -function commonSendLocation.filterTable(pSourceTbl, pValuesTbl) +--[[ @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 <= #pSourceTbl do - if isContain(pValuesTbl, pSourceTbl[i]) then - table.remove(pSourceTbl, i) + while i <= #pFilteredTbl do + if isContain(pValuesTbl, pFilteredTbl[i]) then + table.remove(pFilteredTbl, i) else i = i + 1 end From 1079a890a656e4a873afb41453fc46433b659aaa Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Thu, 12 Oct 2017 15:22:20 +0300 Subject: [PATCH 16/29] Add test set --- test_sets/SendLocation.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test_sets/SendLocation.txt diff --git a/test_sets/SendLocation.txt b/test_sets/SendLocation.txt new file mode 100644 index 0000000000..4378bed85e --- /dev/null +++ b/test_sets/SendLocation.txt @@ -0,0 +1,16 @@ +./test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua +./test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.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 From 0c5fd8c9296971bf89787eef8684a191761e70e8 Mon Sep 17 00:00:00 2001 From: GetmanetsIrina Date: Thu, 5 Oct 2017 13:09:47 +0300 Subject: [PATCH 17/29] New SendLocation scripts MandatoryOnly, boundary values --- .../018_SendLocation_MandatoryOnly_Float.lua | 60 ++++ .../019_SendLocation_MandatoryOnly_Int.lua | 60 ++++ ...20_SendLocation_boundary_by_parameters.lua | 270 ++++++++++++++++++ 3 files changed, 390 insertions(+) create mode 100644 test_scripts/API/Navigation/SendLocation/018_SendLocation_MandatoryOnly_Float.lua create mode 100644 test_scripts/API/Navigation/SendLocation/019_SendLocation_MandatoryOnly_Int.lua create mode 100644 test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua 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..40b4e0991e --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua @@ -0,0 +1,270 @@ +--------------------------------------------------------------------------------------------- +-- 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 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 = string255Char} + +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, {string255Char}) + +--[[ 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) From 855974b9a5b6f6e2a2b1309a74135ec831e65727 Mon Sep 17 00:00:00 2001 From: GetmanetsIrina Date: Tue, 17 Oct 2017 14:08:43 +0300 Subject: [PATCH 18/29] Regression SendLocation scripts. Changes according to review results --- .../021_SendLocation_out_of_bound_values.lua | 191 ++++++++++++++++++ ...ndLocation_fake_another_request_params.lua | 148 ++++++++++++++ .../023_SendLocation_app_not_registered.lua | 57 ++++++ .../024_SendLocation_diff_HMI_levels.lua | 87 ++++++++ .../025_SendLocation_duplicated_corr_id.lua | 72 +++++++ ...26_SendLocation_disallowed_by_policies.lua | 55 +++++ ...027_SendLocation_invalid_HMI_responses.lua | 88 ++++++++ 7 files changed, 698 insertions(+) create mode 100644 test_scripts/API/Navigation/SendLocation/021_SendLocation_out_of_bound_values.lua create mode 100644 test_scripts/API/Navigation/SendLocation/022_SendLocation_fake_another_request_params.lua create mode 100644 test_scripts/API/Navigation/SendLocation/023_SendLocation_app_not_registered.lua create mode 100644 test_scripts/API/Navigation/SendLocation/024_SendLocation_diff_HMI_levels.lua create mode 100644 test_scripts/API/Navigation/SendLocation/025_SendLocation_duplicated_corr_id.lua create mode 100644 test_scripts/API/Navigation/SendLocation/026_SendLocation_disallowed_by_policies.lua create mode 100644 test_scripts/API/Navigation/SendLocation/027_SendLocation_invalid_HMI_responses.lua 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_duplicated_corr_id.lua b/test_scripts/API/Navigation/SendLocation/025_SendLocation_duplicated_corr_id.lua new file mode 100644 index 0000000000..776b2cc807 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/025_SendLocation_duplicated_corr_id.lua @@ -0,0 +1,72 @@ +--------------------------------------------------------------------------------------------- +-- 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) + + local msg = { + serviceType = 7, + frameInfo = 0, + rpcType = 0, + rpcFunctionId = 39, + rpcCorrelationId = cid, + payload = '{"longitudeDegrees":1.1, "latitudeDegrees":1.1}' + } + + params.appID = commonSendLocation.getHMIAppId() + + EXPECT_HMICALL("Navigation.SendLocation", params) + :Do(function(exp,data) + if exp.occurences == 1 then + self.mobileSession1:Send(msg) + end + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + end) + :Times(2) + + self.mobileSession1:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + :Times(2) +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/026_SendLocation_disallowed_by_policies.lua b/test_scripts/API/Navigation/SendLocation/026_SendLocation_disallowed_by_policies.lua new file mode 100644 index 0000000000..7f0b6bc035 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/026_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/027_SendLocation_invalid_HMI_responses.lua b/test_scripts/API/Navigation/SendLocation/027_SendLocation_invalid_HMI_responses.lua new file mode 100644 index 0000000000..146fea1430 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/027_SendLocation_invalid_HMI_responses.lua @@ -0,0 +1,88 @@ +--------------------------------------------------------------------------------------------- +-- 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 responds with invalid respone(mandatory missing, invalid json, invalid value of parametes) +-- +-- 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 json = require("json") + +--[[ Local Variables ]] +local HMIresponses = { + method_Missing = { jsonrpc = "2.0", result = { code = 0 }}, + method_WrongType = { jsonrpc = "2.0", result = { method = 3 ,code = 0 }}, + method_WrongValue = { jsonrpc = "2.0", result = { method = "ANY" ,code = 0 }}, + method_AnotherRPC = { jsonrpc = "2.0", result = { method = "Navigation.ShowConstantTBT", code = 0 }}, + code_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation" }}, + code_WrongType = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = "0" }}, + code_WrongValue = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 1111 }}, + result_Missing = { jsonrpc = "2.0" }, + result_WrongType = { jsonrpc = "2.0", result = 0 } +} + +local HMIresponsesIdCheck = { + id_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 0 }}, + id_WrongType = { jsonrpc = "2.0", id = "35", result = { method = "Navigation.SendLocation", code = 0 }}, + id_WrongValue = { jsonrpc = "2.0", id = 1111, result = { method = "Navigation.SendLocation", code = 0 }}, +} + +--[[ Local Functions ]] +local function sendLocation(paramsResponse, idValue, self) + local params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 + } + + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Do(function(_,data) + if idValue == true then + paramsResponse.id = data.id + end + local text + if type(paramsResponse) ~= "string" then + text = json.encode(paramsResponse) + else + text = paramsResponse + end + self.hmiConnection:Send(text) + end) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) +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") +for key, value in pairs(HMIresponses) do + runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, true }) +end + +runner.Step("SendLocation_invalid_json", sendLocation, + { '"jsonrpc":"2.0","result":{"method""Navigation.SendLocation"}', false }) + +for key, value in pairs(HMIresponsesIdCheck) do + runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, false }) +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) From d43ba174babd77655d89cc09c8f87c92eddbd38b Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Thu, 2 Nov 2017 16:43:32 +0200 Subject: [PATCH 19/29] Reduce max file name length to 242 --- .../Navigation/SendLocation/009_SendLocation_boundary.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua b/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua index ba59078572..80b027a6a8 100644 --- a/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua +++ b/test_scripts/API/Navigation/SendLocation/009_SendLocation_boundary.lua @@ -27,6 +27,7 @@ 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, @@ -99,7 +100,7 @@ local upperBoundRequest = { deliveryMode = "PROMPT", locationImage = { - value = string.rep("a", 251) .. ".png", + value = maxFileName, imageType = "DYNAMIC", } } @@ -138,7 +139,7 @@ runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation. 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, {string.rep("a", 251) .. ".png"}) +runner.Step("Upload file with upper bound name", commonSendLocation.putFile, {maxFileName}) runner.Title("Test") runner.Step("SendLocation-lower-bound-of-all-params", sendLocation, {lowerBoundRequest}) From 596584bd4c2fdfb8dd86327e177410bf946790ab Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Thu, 2 Nov 2017 17:36:16 +0200 Subject: [PATCH 20/29] SendLocation: Update test set --- ...2_SendLocation_disallowed_by_policies.lua} | 0 .../002_SendLocation_transfer_result_code.lua | 106 ------------------ ...> 017_SendLocation_duplicated_corr_id.lua} | 0 ...027_SendLocation_invalid_HMI_responses.lua | 88 --------------- test_sets/SendLocation.txt | 10 +- 5 files changed, 9 insertions(+), 195 deletions(-) rename test_scripts/API/Navigation/SendLocation/{026_SendLocation_disallowed_by_policies.lua => 002_SendLocation_disallowed_by_policies.lua} (100%) delete mode 100644 test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua rename test_scripts/API/Navigation/SendLocation/{025_SendLocation_duplicated_corr_id.lua => 017_SendLocation_duplicated_corr_id.lua} (100%) delete mode 100644 test_scripts/API/Navigation/SendLocation/027_SendLocation_invalid_HMI_responses.lua diff --git a/test_scripts/API/Navigation/SendLocation/026_SendLocation_disallowed_by_policies.lua b/test_scripts/API/Navigation/SendLocation/002_SendLocation_disallowed_by_policies.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/026_SendLocation_disallowed_by_policies.lua rename to test_scripts/API/Navigation/SendLocation/002_SendLocation_disallowed_by_policies.lua diff --git a/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua b/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua deleted file mode 100644 index 4b47951782..0000000000 --- a/test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.lua +++ /dev/null @@ -1,106 +0,0 @@ ---------------------------------------------------------------------------------------------------- --- 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") -} - -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, isUnsupported, 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) - - local appSuccess = false - local appResultCode = pResultCodeMap.mobile - if isUnsupported then - appResultCode = "GENERIC_ERROR" - end - - self.mobileSession1:ExpectResponse(cid, { success = appSuccess, resultCode = appResultCode }) - :ValidIf(function(_,data) - if not isUnsupported and not data.payload.info then - return false, "SDL doesn't resend info parameter to mobile App" - end - return true - end) -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, false }) -end - -runner.Title("Unexpected codes") -for _, item in pairs(resultCodes.unexpected) do - runner.Step("SendLocation with " .. item.hmi .. " resultCode", sendLocationUnsuccess, { item, true }) -end - -runner.Title("Postconditions") -runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/API/Navigation/SendLocation/025_SendLocation_duplicated_corr_id.lua b/test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/025_SendLocation_duplicated_corr_id.lua rename to test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua diff --git a/test_scripts/API/Navigation/SendLocation/027_SendLocation_invalid_HMI_responses.lua b/test_scripts/API/Navigation/SendLocation/027_SendLocation_invalid_HMI_responses.lua deleted file mode 100644 index 146fea1430..0000000000 --- a/test_scripts/API/Navigation/SendLocation/027_SendLocation_invalid_HMI_responses.lua +++ /dev/null @@ -1,88 +0,0 @@ ---------------------------------------------------------------------------------------------- --- 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 responds with invalid respone(mandatory missing, invalid json, invalid value of parametes) --- --- 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 json = require("json") - ---[[ Local Variables ]] -local HMIresponses = { - method_Missing = { jsonrpc = "2.0", result = { code = 0 }}, - method_WrongType = { jsonrpc = "2.0", result = { method = 3 ,code = 0 }}, - method_WrongValue = { jsonrpc = "2.0", result = { method = "ANY" ,code = 0 }}, - method_AnotherRPC = { jsonrpc = "2.0", result = { method = "Navigation.ShowConstantTBT", code = 0 }}, - code_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation" }}, - code_WrongType = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = "0" }}, - code_WrongValue = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 1111 }}, - result_Missing = { jsonrpc = "2.0" }, - result_WrongType = { jsonrpc = "2.0", result = 0 } -} - -local HMIresponsesIdCheck = { - id_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 0 }}, - id_WrongType = { jsonrpc = "2.0", id = "35", result = { method = "Navigation.SendLocation", code = 0 }}, - id_WrongValue = { jsonrpc = "2.0", id = 1111, result = { method = "Navigation.SendLocation", code = 0 }}, -} - ---[[ Local Functions ]] -local function sendLocation(paramsResponse, idValue, self) - local params = { - longitudeDegrees = 1.1, - latitudeDegrees = 1.1 - } - - local cid = self.mobileSession1:SendRPC("SendLocation", params) - - EXPECT_HMICALL("Navigation.SendLocation") - :Do(function(_,data) - if idValue == true then - paramsResponse.id = data.id - end - local text - if type(paramsResponse) ~= "string" then - text = json.encode(paramsResponse) - else - text = paramsResponse - end - self.hmiConnection:Send(text) - end) - - self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) -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") -for key, value in pairs(HMIresponses) do - runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, true }) -end - -runner.Step("SendLocation_invalid_json", sendLocation, - { '"jsonrpc":"2.0","result":{"method""Navigation.SendLocation"}', false }) - -for key, value in pairs(HMIresponsesIdCheck) do - runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, false }) -end - -runner.Title("Postconditions") -runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_sets/SendLocation.txt b/test_sets/SendLocation.txt index 4378bed85e..c6ebe3ce77 100644 --- a/test_sets/SendLocation.txt +++ b/test_sets/SendLocation.txt @@ -1,5 +1,5 @@ ./test_scripts/API/Navigation/SendLocation/001_SendLocation_success.lua -./test_scripts/API/Navigation/SendLocation/002_SendLocation_transfer_result_code.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 @@ -14,3 +14,11 @@ ./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 From c21c31b51f279e85bbb7be342af00fdc00e73029 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 3 Nov 2017 15:48:56 +0200 Subject: [PATCH 21/29] SendLocation: Stabilize scripts --- .../017_SendLocation_duplicated_corr_id.lua | 34 +++++++++++++------ ...20_SendLocation_boundary_by_parameters.lua | 6 ++-- .../API/Navigation/commonSendLocation.lua | 10 +++--- 3 files changed, 31 insertions(+), 19 deletions(-) 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 index 776b2cc807..55942a9db4 100644 --- a/test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua +++ b/test_scripts/API/Navigation/SendLocation/017_SendLocation_duplicated_corr_id.lua @@ -33,29 +33,41 @@ local requestParams = { --[[ Local Functions ]] local function sendLocation(params, self) local cid = self.mobileSession1:SendRPC("SendLocation", params) - - local msg = { - serviceType = 7, - frameInfo = 0, - rpcType = 0, - rpcFunctionId = 39, - rpcCorrelationId = cid, - payload = '{"longitudeDegrees":1.1, "latitudeDegrees":1.1}' - } + 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 - self.mobileSession1:Send(msg) + RUN_AFTER(request2, 500) + end + local function response() + print("HMI->SDL: RS" .. exp.occurences) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) end - self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + 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 ]] 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 index 40b4e0991e..a13904a55f 100644 --- a/test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua +++ b/test_scripts/API/Navigation/SendLocation/020_SendLocation_boundary_by_parameters.lua @@ -31,6 +31,8 @@ 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 @@ -82,7 +84,7 @@ local boundValues ={ addressLines = {lower = {"a"}, upper = {string500Char}} } -local locationImage = {lower = "a", upper = string255Char} +local locationImage = {lower = "a", upper = maxFileName} local deliveryModeEnum = { "PROMPT", @@ -212,7 +214,7 @@ runner.Step("Start SDL, HMI, connect Mobile, start Session", commonSendLocation. 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, {string255Char}) +runner.Step("Upload file", commonSendLocation.putFile, {maxFileName}) --[[ Test ]] --[[ Lower bound set]] diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index 10bbff36b5..9817572133 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -14,12 +14,10 @@ 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 mobile_api_loader = require("modules/api_loader") -local mobile_api = mobile_api_loader.init("data/MOBILE_API.xml") -local mobile_api_schema = mobile_api.interface["Ford Sync RAPI"] - -local hmi_api_loader = require("modules/api_loader") -local hmi_api = hmi_api_loader.init("data/HMI_API.xml") +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 ]] From 728f8009a6e7fb239404a7c408b99090da06d7fa Mon Sep 17 00:00:00 2001 From: GetmanetsIrina Date: Mon, 13 Nov 2017 12:02:25 +0200 Subject: [PATCH 22/29] Additional SendLocation scripts --- ...25_SendLocation_disallowed_by_policies.lua | 55 ++++++++ .../026_SendLocation_without_HMI_response.lua | 44 +++++++ ...ion_parameters_omitted_in_policy_table.lua | 90 ++++++++++++++ ...ation_parameters_empty_in_policy_table.lua | 90 ++++++++++++++ ...cation_requested_parameters_disallowed.lua | 78 ++++++++++++ .../030_SendLocation_invalid_characters.lua | 117 ++++++++++++++++++ ...dLocation_several_responses_to_request.lua | 60 +++++++++ test_sets/SendLocation.txt | 8 ++ 8 files changed, 542 insertions(+) create mode 100644 test_scripts/API/Navigation/SendLocation/025_SendLocation_disallowed_by_policies.lua create mode 100644 test_scripts/API/Navigation/SendLocation/026_SendLocation_without_HMI_response.lua create mode 100644 test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_omitted_in_policy_table.lua create mode 100644 test_scripts/API/Navigation/SendLocation/028_SendLocation_parameters_empty_in_policy_table.lua create mode 100644 test_scripts/API/Navigation/SendLocation/029_SendLocation_requested_parameters_disallowed.lua create mode 100644 test_scripts/API/Navigation/SendLocation/030_SendLocation_invalid_characters.lua create mode 100644 test_scripts/API/Navigation/SendLocation/031_SendLocation_several_responses_to_request.lua diff --git a/test_scripts/API/Navigation/SendLocation/025_SendLocation_disallowed_by_policies.lua b/test_scripts/API/Navigation/SendLocation/025_SendLocation_disallowed_by_policies.lua new file mode 100644 index 0000000000..8a44f337e0 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/025_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(1000) +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/026_SendLocation_without_HMI_response.lua b/test_scripts/API/Navigation/SendLocation/026_SendLocation_without_HMI_response.lua new file mode 100644 index 0000000000..6a802edbd2 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/026_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/027_SendLocation_parameters_omitted_in_policy_table.lua b/test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_omitted_in_policy_table.lua new file mode 100644 index 0000000000..4d89ffdeb5 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/027_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 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", + }, + 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/028_SendLocation_parameters_empty_in_policy_table.lua b/test_scripts/API/Navigation/SendLocation/028_SendLocation_parameters_empty_in_policy_table.lua new file mode 100644 index 0000000000..edcff61d39 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/028_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/029_SendLocation_requested_parameters_disallowed.lua b/test_scripts/API/Navigation/SendLocation/029_SendLocation_requested_parameters_disallowed.lua new file mode 100644 index 0000000000..7eb9c4d544 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/029_SendLocation_requested_parameters_disallowed.lua @@ -0,0 +1,78 @@ +--------------------------------------------------------------------------------------------- +-- 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" }) +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/030_SendLocation_invalid_characters.lua b/test_scripts/API/Navigation/SendLocation/030_SendLocation_invalid_characters.lua new file mode 100644 index 0000000000..40617018c6 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/030_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/031_SendLocation_several_responses_to_request.lua b/test_scripts/API/Navigation/SendLocation/031_SendLocation_several_responses_to_request.lua new file mode 100644 index 0000000000..37fc422704 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/031_SendLocation_several_responses_to_request.lua @@ -0,0 +1,60 @@ +--------------------------------------------------------------------------------------------------- +-- 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) + self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) + self.hmiConnection:SendError(data.id, data.method, "ABORTED", "Error message") + self.hmiConnection:SendError(data.id, data.method, "REJECTED", "Error message") + 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.Title("Test") +runner.Step("SendLocation_several_response", sendLocation, {requestParams}) +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_sets/SendLocation.txt b/test_sets/SendLocation.txt index c6ebe3ce77..063bb97fe3 100644 --- a/test_sets/SendLocation.txt +++ b/test_sets/SendLocation.txt @@ -22,3 +22,11 @@ ./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_disallowed_by_policies.lua +./test_scripts/API/Navigation/SendLocation/026_SendLocation_invalid_HMI_responses.lua +./test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_omitted_in_policy_table.lua +./test_scripts/API/Navigation/SendLocation/028_SendLocation_parameters_empty_in_policy_table.lua +./test_scripts/API/Navigation/SendLocation/029_SendLocation_requested_parameters_disallowed.lua +./test_scripts/API/Navigation/SendLocation/030_SendLocation_invalid_characters.lua +./test_scripts/API/Navigation/SendLocation/031_SendLocation_several_responses_to_request.lua + From 24558772d75c4ddc3b93fd7e72546d1b4adafdc8 Mon Sep 17 00:00:00 2001 From: GetmanetsIrina Date: Mon, 13 Nov 2017 12:23:40 +0200 Subject: [PATCH 23/29] Updated numbering and removed duplicated script --- ...25_SendLocation_disallowed_by_policies.lua | 55 ------------ ...025_SendLocation_without_HMI_response.lua} | 0 ...on_parameters_omitted_in_policy_table.lua} | 0 ...tion_parameters_empty_in_policy_table.lua} | 0 ...ation_requested_parameters_disallowed.lua} | 0 ...> 029_SendLocation_invalid_characters.lua} | 0 ...Location_several_responses_to_request.lua} | 0 ...nnn_SendLocation_invalid_HMI_responses.lua | 87 +++++++++++++++++++ test_sets/SendLocation.txt | 13 ++- 9 files changed, 93 insertions(+), 62 deletions(-) delete mode 100644 test_scripts/API/Navigation/SendLocation/025_SendLocation_disallowed_by_policies.lua rename test_scripts/API/Navigation/SendLocation/{026_SendLocation_without_HMI_response.lua => 025_SendLocation_without_HMI_response.lua} (100%) rename test_scripts/API/Navigation/SendLocation/{027_SendLocation_parameters_omitted_in_policy_table.lua => 026_SendLocation_parameters_omitted_in_policy_table.lua} (100%) rename test_scripts/API/Navigation/SendLocation/{028_SendLocation_parameters_empty_in_policy_table.lua => 027_SendLocation_parameters_empty_in_policy_table.lua} (100%) rename test_scripts/API/Navigation/SendLocation/{029_SendLocation_requested_parameters_disallowed.lua => 028_SendLocation_requested_parameters_disallowed.lua} (100%) rename test_scripts/API/Navigation/SendLocation/{030_SendLocation_invalid_characters.lua => 029_SendLocation_invalid_characters.lua} (100%) rename test_scripts/API/Navigation/SendLocation/{031_SendLocation_several_responses_to_request.lua => 030_SendLocation_several_responses_to_request.lua} (100%) create mode 100644 test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.lua diff --git a/test_scripts/API/Navigation/SendLocation/025_SendLocation_disallowed_by_policies.lua b/test_scripts/API/Navigation/SendLocation/025_SendLocation_disallowed_by_policies.lua deleted file mode 100644 index 8a44f337e0..0000000000 --- a/test_scripts/API/Navigation/SendLocation/025_SendLocation_disallowed_by_policies.lua +++ /dev/null @@ -1,55 +0,0 @@ ---------------------------------------------------------------------------------------------- --- 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(1000) -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/026_SendLocation_without_HMI_response.lua b/test_scripts/API/Navigation/SendLocation/025_SendLocation_without_HMI_response.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/026_SendLocation_without_HMI_response.lua rename to test_scripts/API/Navigation/SendLocation/025_SendLocation_without_HMI_response.lua diff --git a/test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_omitted_in_policy_table.lua b/test_scripts/API/Navigation/SendLocation/026_SendLocation_parameters_omitted_in_policy_table.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_omitted_in_policy_table.lua rename to test_scripts/API/Navigation/SendLocation/026_SendLocation_parameters_omitted_in_policy_table.lua diff --git a/test_scripts/API/Navigation/SendLocation/028_SendLocation_parameters_empty_in_policy_table.lua b/test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_empty_in_policy_table.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/028_SendLocation_parameters_empty_in_policy_table.lua rename to test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_empty_in_policy_table.lua diff --git a/test_scripts/API/Navigation/SendLocation/029_SendLocation_requested_parameters_disallowed.lua b/test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/029_SendLocation_requested_parameters_disallowed.lua rename to test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua diff --git a/test_scripts/API/Navigation/SendLocation/030_SendLocation_invalid_characters.lua b/test_scripts/API/Navigation/SendLocation/029_SendLocation_invalid_characters.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/030_SendLocation_invalid_characters.lua rename to test_scripts/API/Navigation/SendLocation/029_SendLocation_invalid_characters.lua diff --git a/test_scripts/API/Navigation/SendLocation/031_SendLocation_several_responses_to_request.lua b/test_scripts/API/Navigation/SendLocation/030_SendLocation_several_responses_to_request.lua similarity index 100% rename from test_scripts/API/Navigation/SendLocation/031_SendLocation_several_responses_to_request.lua rename to test_scripts/API/Navigation/SendLocation/030_SendLocation_several_responses_to_request.lua diff --git a/test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.lua b/test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.lua new file mode 100644 index 0000000000..99c01cd1e3 --- /dev/null +++ b/test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.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. 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 responds with invalid respone(mandatory missing, invalid json, invalid value of parametes) +-- +-- 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 json = require("json") + +--[[ Local Variables ]] +local HMIresponses = { + method_Missing = { jsonrpc = "2.0", result = { code = 0 }}, + method_WrongType = { jsonrpc = "2.0", result = { method = 3 ,code = 0 }}, + method_WrongValue = { jsonrpc = "2.0", result = { method = "ANY" ,code = 0 }}, + method_AnotherRPC = { jsonrpc = "2.0", result = { method = "Navigation.ShowConstantTBT", code = 0 }}, + code_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation" }}, + code_WrongType = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = "0" }}, + code_WrongValue = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 1111 }}, + result_Missing = { jsonrpc = "2.0" }, + result_WrongType = { jsonrpc = "2.0", result = 0 } +} + +local HMIresponsesIdCheck = { + id_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 0 }}, + id_WrongType = { jsonrpc = "2.0", id = "35", result = { method = "Navigation.SendLocation", code = 0 }}, + id_WrongValue = { jsonrpc = "2.0", id = 1111, result = { method = "Navigation.SendLocation", code = 0 }}, +} + +--[[ Local Functions ]] +local function sendLocation(paramsResponse, idValue, self) + local params = { + longitudeDegrees = 1.1, + latitudeDegrees = 1.1 + } + + local cid = self.mobileSession1:SendRPC("SendLocation", params) + + EXPECT_HMICALL("Navigation.SendLocation") + :Do(function(_,data) + if idValue == true then + paramsResponse.id = data.id + end + local text + if type(paramsResponse) ~= "string" then + text = json.encode(paramsResponse) + else text = paramsResponse + end + self.hmiConnection:Send(text) + end) + + self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) +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") +for key, value in pairs(HMIresponses) do + runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, true }) +end + +runner.Step("SendLocation_invalid_json", sendLocation, + { '"jsonrpc":"2.0","result":{"method""Navigation.SendLocation"}', false }) + +for key, value in pairs(HMIresponsesIdCheck) do + runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, false }) +end + +runner.Title("Postconditions") +runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_sets/SendLocation.txt b/test_sets/SendLocation.txt index 063bb97fe3..16cb03277b 100644 --- a/test_sets/SendLocation.txt +++ b/test_sets/SendLocation.txt @@ -22,11 +22,10 @@ ./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_disallowed_by_policies.lua -./test_scripts/API/Navigation/SendLocation/026_SendLocation_invalid_HMI_responses.lua -./test_scripts/API/Navigation/SendLocation/027_SendLocation_parameters_omitted_in_policy_table.lua -./test_scripts/API/Navigation/SendLocation/028_SendLocation_parameters_empty_in_policy_table.lua -./test_scripts/API/Navigation/SendLocation/029_SendLocation_requested_parameters_disallowed.lua -./test_scripts/API/Navigation/SendLocation/030_SendLocation_invalid_characters.lua -./test_scripts/API/Navigation/SendLocation/031_SendLocation_several_responses_to_request.lua +./test_scripts/API/Navigation/SendLocation/025_SendLocation_invalid_HMI_responses.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 From a61cb0570d135eb7b28467812a6f0e2e697b8469 Mon Sep 17 00:00:00 2001 From: GetmanetsIrina Date: Mon, 13 Nov 2017 14:16:27 +0200 Subject: [PATCH 24/29] Removed script under clarification Fixes --- ...ion_parameters_omitted_in_policy_table.lua | 2 +- ...cation_requested_parameters_disallowed.lua | 6 +- ...dLocation_several_responses_to_request.lua | 16 +++- ...nnn_SendLocation_invalid_HMI_responses.lua | 87 ------------------- test_sets/SendLocation.txt | 3 +- 5 files changed, 20 insertions(+), 94 deletions(-) delete mode 100644 test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.lua 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 index 4d89ffdeb5..309908f748 100644 --- 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 @@ -12,7 +12,7 @@ -- SDL receives allowed SendLocation request and parameters section is omitted in PT -- -- Expected: --- SDL responds DISALLOWED, success:false +-- SDL proceed with this request --------------------------------------------------------------------------------------------------- --[[ Required Shared libraries ]] local runner = require('user_modules/script_runner') 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 index 7eb9c4d544..4261136762 100644 --- a/test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua +++ b/test_scripts/API/Navigation/SendLocation/028_SendLocation_requested_parameters_disallowed.lua @@ -60,7 +60,11 @@ local function sendLocation(params, self) EXPECT_HMICALL("Navigation.SendLocation") :Times(0) commonSendLocation.delayedExp() - self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "DISALLOWED" }) + self.mobileSession1:ExpectResponse(cid, { + success = false, + resultCode = "DISALLOWED", + info = "Requested parameters are disallowed by Policies" + }) end --[[ Scenario ]] 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 index 37fc422704..e0f8db2b23 100644 --- 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 @@ -40,11 +40,21 @@ local function sendLocation(params, self) params.appID = commonSendLocation.getHMIAppId() EXPECT_HMICALL("Navigation.SendLocation", params) :Do(function(_,data) - self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {}) - self.hmiConnection:SendError(data.id, data.method, "ABORTED", "Error message") - self.hmiConnection:SendError(data.id, data.method, "REJECTED", "Error message") + 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 ]] diff --git a/test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.lua b/test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.lua deleted file mode 100644 index 99c01cd1e3..0000000000 --- a/test_scripts/API/Navigation/SendLocation/nnn_SendLocation_invalid_HMI_responses.lua +++ /dev/null @@ -1,87 +0,0 @@ ---------------------------------------------------------------------------------------------- --- 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 responds with invalid respone(mandatory missing, invalid json, invalid value of parametes) --- --- 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 json = require("json") - ---[[ Local Variables ]] -local HMIresponses = { - method_Missing = { jsonrpc = "2.0", result = { code = 0 }}, - method_WrongType = { jsonrpc = "2.0", result = { method = 3 ,code = 0 }}, - method_WrongValue = { jsonrpc = "2.0", result = { method = "ANY" ,code = 0 }}, - method_AnotherRPC = { jsonrpc = "2.0", result = { method = "Navigation.ShowConstantTBT", code = 0 }}, - code_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation" }}, - code_WrongType = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = "0" }}, - code_WrongValue = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 1111 }}, - result_Missing = { jsonrpc = "2.0" }, - result_WrongType = { jsonrpc = "2.0", result = 0 } -} - -local HMIresponsesIdCheck = { - id_Missing = { jsonrpc = "2.0", result = { method = "Navigation.SendLocation", code = 0 }}, - id_WrongType = { jsonrpc = "2.0", id = "35", result = { method = "Navigation.SendLocation", code = 0 }}, - id_WrongValue = { jsonrpc = "2.0", id = 1111, result = { method = "Navigation.SendLocation", code = 0 }}, -} - ---[[ Local Functions ]] -local function sendLocation(paramsResponse, idValue, self) - local params = { - longitudeDegrees = 1.1, - latitudeDegrees = 1.1 - } - - local cid = self.mobileSession1:SendRPC("SendLocation", params) - - EXPECT_HMICALL("Navigation.SendLocation") - :Do(function(_,data) - if idValue == true then - paramsResponse.id = data.id - end - local text - if type(paramsResponse) ~= "string" then - text = json.encode(paramsResponse) - else text = paramsResponse - end - self.hmiConnection:Send(text) - end) - - self.mobileSession1:ExpectResponse(cid, { success = false, resultCode = "GENERIC_ERROR" }) -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") -for key, value in pairs(HMIresponses) do - runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, true }) -end - -runner.Step("SendLocation_invalid_json", sendLocation, - { '"jsonrpc":"2.0","result":{"method""Navigation.SendLocation"}', false }) - -for key, value in pairs(HMIresponsesIdCheck) do - runner.Step("SendLocation_" .. tostring(key), sendLocation, { value, false }) -end - -runner.Title("Postconditions") -runner.Step("Stop SDL", commonSendLocation.postconditions) diff --git a/test_sets/SendLocation.txt b/test_sets/SendLocation.txt index 16cb03277b..b761a52643 100644 --- a/test_sets/SendLocation.txt +++ b/test_sets/SendLocation.txt @@ -22,10 +22,9 @@ ./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_invalid_HMI_responses.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 - From b7efaa27f655544ba9a8432123b798fd3bb9c016 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Thu, 30 Nov 2017 14:23:55 +0200 Subject: [PATCH 25/29] SL: Add additional scripts on transferring HMI codes --- .../031_SendLocation_transfer_result_code.lua | 116 ++++++++++++++++++ .../API/Navigation/commonSendLocation.lua | 25 ++-- test_sets/SendLocation.txt | 1 + 3 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 test_scripts/API/Navigation/SendLocation/031_SendLocation_transfer_result_code.lua 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 index 9817572133..3c29545768 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -37,9 +37,8 @@ local successCodes = { "SAVED" } -local nonDirectResultCodes = { - { mobile = "APPLICATION_NOT_REGISTERED", hmi = "NO_APPS_REGISTERED" }, - { mobile = "APPLICATION_NOT_REGISTERED", hmi = "NO_DEVICES_CONNECTED" } +local excludedCodes = { + "UNSUPPORTED_RESOURCE" -- excluded due to unresolved clarification } local function getAvailableParams() @@ -370,16 +369,12 @@ end local function getResultCodesMap() local out = {} for _, v in pairs(getHMIResultCodes()) do - if isContain(getMobileResultCodes(), v) then - table.insert(out, { mobile = v, hmi = v }) - elseif isContain(commonSendLocation.getKeysFromItemsTable(nonDirectResultCodes, "hmi"), v) then - for _, item in pairs(nonDirectResultCodes) do - if item.hmi == v then - table.insert(out, { mobile = item.mobile, hmi = item.hmi }) - end + 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 - else - table.insert(out, { mobile = nil, hmi = v }) end end return out @@ -408,8 +403,10 @@ 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 }) + table.insert(out, { mobile = item.mobile, hmi = item.hmi, success = success }) end end return out @@ -439,6 +436,8 @@ function commonSendLocation.printResultCodes(pResultCodes) printItem(pResultCodes.failure) print("Unexpected:") printItem(pResultCodes.unexpected) + print("Unmapped:") + printItem(pResultCodes.unmapped) end --[[ @filterTable: remove from 1st table items provided in 2nd table diff --git a/test_sets/SendLocation.txt b/test_sets/SendLocation.txt index b761a52643..d1932a609c 100644 --- a/test_sets/SendLocation.txt +++ b/test_sets/SendLocation.txt @@ -28,3 +28,4 @@ ./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 From e9e9b6d4dec295c6c3f05a503612de9cefeb88ee Mon Sep 17 00:00:00 2001 From: Dmytro Boltovskyi Date: Wed, 15 Nov 2017 16:05:51 +0200 Subject: [PATCH 26/29] Remove turnText item --- test_scripts/smoke_api.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 = { From 5fc166a18571e206391114ee7c4faeb52ba7c429 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 26 Jan 2018 12:51:44 +0200 Subject: [PATCH 27/29] Replace turnText by navigationText --- .../Smoke/API/027_UpdateTurnList_PositiveCase_SUCCESS.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 2d87de475209c0f22e377dee0d7c7c3518011b73 Mon Sep 17 00:00:00 2001 From: Dmitriy Boltovskiy Date: Fri, 26 Jan 2018 13:12:15 +0200 Subject: [PATCH 28/29] Fix obtaining of MAC address and device Id --- .../API/Navigation/commonSendLocation.lua | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index 3c29545768..ff7c8d9113 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -2,7 +2,7 @@ -- SendLocation common module --------------------------------------------------------------------------------------------------- --[[ General configuration parameters ]] -config.deviceMAC = "12ca17b49af2289436f303e0166030a21e525d266e209267433801a8fd4071a0" +config.mobileHost = "127.0.0.1" config.defaultProtocolVersion = 2 --[[ Required Shared libraries ]] @@ -50,8 +50,14 @@ local function getAvailableParams() end local function allowSDL(self) - self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality", - { allowed = true, source = "GUI", device = { id = config.deviceMAC, name = "127.0.0.1" } }) + self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality", { + allowed = true, + source = "GUI", + device = { + id = commonSendLocation.getDeviceMAC(), + name = commonSendLocation.getDeviceName() + } + }) end local function checkIfPTSIsSentAsBinary(bin_data) @@ -181,8 +187,16 @@ function commonSendLocation.delayedExp(timeout) commonTestCases:DelayedExp(timeout) end +function commonSendLocation.getDeviceName() + return config.mobileHost .. ":" .. config.mobilePort +end + function commonSendLocation.getDeviceMAC() - return config.deviceMAC + 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(...) From 662c3f5a70e74cd6638147776886b8ceb91d2d24 Mon Sep 17 00:00:00 2001 From: GetmanetsIrina Date: Thu, 21 Jun 2018 10:43:40 +0300 Subject: [PATCH 29/29] Added missing 'events' in common SendLocation file --- test_scripts/API/Navigation/commonSendLocation.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/test_scripts/API/Navigation/commonSendLocation.lua b/test_scripts/API/Navigation/commonSendLocation.lua index ff7c8d9113..8b83020f78 100644 --- a/test_scripts/API/Navigation/commonSendLocation.lua +++ b/test_scripts/API/Navigation/commonSendLocation.lua @@ -13,6 +13,7 @@ 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")