Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update 090 to new common files #2479

Merged
merged 4 commits into from
Nov 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,165 +18,86 @@
---------------------------------------------------------------------------------------------------------------------
require('user_modules/script_runner').isTestApplicable({ { extendedPolicy = { "EXTERNAL_PROPRIETARY" } } })

--[[ General Settings for configuration ]]
Test = require('user_modules/connecttest_resumption')
require('cardinalities')
local mobile_session = require('mobile_session')
local mobile_adapter_controller = require("mobile_adapter/mobile_adapter_controller")
local file_connection = require('file_connection')
local mobile = require('mobile_connection')
local events = require('events')
local utils = require ('user_modules/utils')

--[[ General configuration parameters ]]
-- Create dummy connection
os.execute("ifconfig lo:1 1.0.0.1")

--[[ 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')
require('user_modules/AppTypes')

--[[ General Precondition before ATF start ]]
commonFunctions:SDLForceStop()
commonSteps:DeleteLogsFileAndPolicyTable()

--[[ Local variables ]]
local mobileHost = "1.0.0.1"
local deviceMAC2 = "9cc72994ab9ca68c1daaf02834f7a94552e82aad3250778f2e12d14afee0a5c6"
local deviceName2 = mobileHost .. ":" .. config.mobilePort
local runner = require('user_modules/script_runner')
local common = require('test_scripts/TheSameApp/commonTheSameApp')
local common2 = require('test_scripts/Capabilities/PersistingHMICapabilities/common')
iCollin marked this conversation as resolved.
Show resolved Hide resolved

--[[ Preconditions ]]
commonFunctions:newTestCasesGroup("Preconditions")

function Test:Precondition_Connect_device1()
commonTestCases:DelayedExp(2000)
self:connectMobile()
if utils.getDeviceTransportType() == "WIFI" then
EXPECT_HMICALL("BasicCommunication.UpdateDeviceList")
:Do(function(_,data)
self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
end)
end
end
--[[ Local Variables ]]
local devices = {
[1] = { host = "1.0.0.1", port = config.mobilePort, name = "1.0.0.1:" .. config.mobilePort },
[2] = { host = "192.168.100.199", port = config.mobilePort, name = "192.168.100.199:" .. config.mobilePort }
}

function Test:Precondition_Register_app_1()
commonTestCases:DelayedExp(3000)
self.mobileSession = mobile_session.MobileSession(self, self.mobileConnection)
self.mobileSession:StartService(7)
:Do(function()
local RequestIDRai1 = self.mobileSession:SendRPC("RegisterAppInterface", config.application1.registerAppInterfaceParams)
EXPECT_HMINOTIFICATION("BasicCommunication.OnAppRegistered")
:Do(function(_,data)
self.HMIAppID = data.params.application.appID
end)
self.mobileSession:ExpectResponse(RequestIDRai1, { success = true, resultCode = "SUCCESS" })
self.mobileSession:ExpectNotification("OnHMIStatus", {hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN"})
end)
end

function Test:Precondition_Activate_app_1()
local RequestId = self.hmiConnection:SendRequest("SDL.ActivateApp", { appID = self.HMIAppID})
EXPECT_HMIRESPONSE(RequestId, {result = { code = 0, device = { id = utils.getDeviceMAC(), name = utils.getDeviceName() }, isSDLAllowed = false, method ="SDL.ActivateApp" }})
:Do(function(_, _)
local RequestIdGetMes = self.hmiConnection:SendRequest("SDL.GetUserFriendlyMessage", {language = "EN-US", messageCodes = {"DataConsent"}})
EXPECT_HMIRESPONSE(RequestIdGetMes)
:Do(function()
self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality",
{allowed = true, source = "GUI", device = {id = utils.getDeviceMAC(), name = utils.getDeviceName()}})
EXPECT_HMICALL("BasicCommunication.ActivateApp")
:Do(function(_, data)
self.hmiConnection:SendResponse(data.id,"BasicCommunication.ActivateApp", "SUCCESS", {})
end)
:Times(AtLeast(1))
end)
end)
EXPECT_NOTIFICATION("OnHMIStatus", {hmiLevel = "FULL", systemContext = "MAIN", audioStreamingState = "AUDIBLE"})
end
local appParams = {
[1] = { appName = "App1", appID = "0001", fullAppID = "0000001" },
[2] = { appName = "App2", appID = "0002", fullAppID = "0000002" }
}

function Test:Precondition_Connect_device_2()
local mobileAdapter = self.getDefaultMobileAdapter(mobileHost, config.mobilePort)
local fileConnection = file_connection.FileConnection("mobile.out", mobileAdapter)
self.connection2 = mobile.MobileConnection(fileConnection)
self.mobileSession2 = mobile_session.MobileSession(self, self.connection2)
event_dispatcher:AddConnection(self.connection2)
self.mobileSession2:ExpectEvent(events.connectedEvent, "Connection started")
self.connection2:Connect()
EXPECT_HMICALL("BasicCommunication.UpdateDeviceList",
--[[ Local Functions ]]
local function connectDeviceTwo()
common.getHMIConnection():ExpectRequest("BasicCommunication.UpdateDeviceList",
{
deviceList = {
{
id = deviceMAC2,
name = deviceName2 ,
transportType = utils.getDeviceTransportType()
transportType = "WEBENGINE_WEBSOCKET",
},
{
id = utils.getDeviceMAC(),
name = utils.getDeviceName(),
transportType = utils.getDeviceTransportType()
name = devices[1].name,
transportType = "WIFI"
},
{
transportType = "WEBENGINE_WEBSOCKET",
isSDLAllowed = false,
name = devices[2].name,
transportType = "WIFI"
}
}
}
):Do(function(_,data)
self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
}})
:Do(function(_,data)
common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
:Times(AtLeast(1))
end

--[[ Test ]]
commonFunctions:newTestCasesGroup("Test")
function Test:Test_Register_app_2()
self.mobileSession2:StartService(7)
:Do(function()
local RaiIdSecond = self.mobileSession2:SendRPC("RegisterAppInterface", config.application2.registerAppInterfaceParams)
EXPECT_HMINOTIFICATION("BasicCommunication.OnAppRegistered")
:Do(function(_,data)
self.HMIAppID2 = data.params.application.appID
end)
self.mobileSession2:ExpectResponse(RaiIdSecond, { success = true, resultCode = "SUCCESS"})
self.mobileSession2:ExpectNotification("OnHMIStatus", {hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN"})
end)
common.connectMobDevice(2, devices[2], false)
end

function Test:Teat_Activate_app_2()
local RequestId = self.hmiConnection:SendRequest("SDL.ActivateApp", { appID = self.HMIAppID2})
EXPECT_HMIRESPONSE(RequestId, {result = { code = 0, device = { id = deviceMAC2, name = deviceName2 }, isSDLAllowed = false, method ="SDL.ActivateApp" }})
local function activateAppTwo()
local RequestId = common.getHMIConnection():SendRequest("SDL.ActivateApp", { appID = common.getHMIAppId(2) })
EXPECT_HMIRESPONSE(RequestId, {result = { code = 0, device = { name = devices[2].name }, isSDLAllowed = false, method = "SDL.ActivateApp" }})
iCollin marked this conversation as resolved.
Show resolved Hide resolved
:Do(function()
local RequestIdGetMes = self.hmiConnection:SendRequest("SDL.GetUserFriendlyMessage", {language = "EN-US", messageCodes = {"DataConsent"}})
EXPECT_HMIRESPONSE(RequestIdGetMes)
:Do(function()
self.hmiConnection:SendNotification("SDL.OnAllowSDLFunctionality",
{allowed = false, source = "GUI", device = {id = deviceMAC2, name = deviceName2}})
EXPECT_HMICALL("BasicCommunication.ActivateApp")
:Do(function(_, data)
self.hmiConnection:SendResponse(data.id,"BasicCommunication.ActivateApp", "SUCCESS", {})
end)
:Times(AtLeast(1))
end)
local RequestIdGetMes = common.getHMIConnection():SendRequest("SDL.GetUserFriendlyMessage", { language = "EN-US", messageCodes = { "DataConsent" } })
EXPECT_HMIRESPONSE(RequestIdGetMes)
iCollin marked this conversation as resolved.
Show resolved Hide resolved
:Do(function()
common.getHMIConnection():SendNotification("SDL.OnAllowSDLFunctionality",
{ allowed = false, source = "GUI", device = { name = devices[2].name } })
end)
end)
end

function Test:Test_Start_PTU()
EXPECT_HMICALL("BasicCommunication.PolicyUpdate")
:Do(function()
self.hmiConnection:SendNotification("BasicCommunication.OnSystemRequest",
{ requestType = "PROPRIETARY", fileName = "PolicyTableUpdate", appID = self.HMIAppID })
self.mobileSession2:ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
local function startPTU()
EXPECT_HMICALL("BasicCommunication.PolicyUpdate")
iCollin marked this conversation as resolved.
Show resolved Hide resolved
:Do(function()
common.getHMIConnection():SendNotification("BasicCommunication.OnSystemRequest",
{ requestType = "PROPRIETARY", fileName = "PolicyTableUpdate", appID = common.getHMIAppId(1) })
common.getMobileSession(2):ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
:Times(0)
self.mobileSession:ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
common.getMobileSession(1):ExpectNotification("OnSystemRequest", {requestType = "PROPRIETARY"})
:Do(function(_, data)
self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", {})
common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
end)
end

--[[ Postconditions ]]
commonFunctions:newTestCasesGroup("Postconditions")
runner.Title("Preconditions")
runner.Step("Clean environment", common.preconditions)
runner.Step("Start SDL, HMI", common2.start)
iCollin marked this conversation as resolved.
Show resolved Hide resolved
runner.Step("Connect device 1 to SDL", common.connectMobDevice, { 1, devices[1] })
runner.Step("Register App1 from device 1", common.registerAppEx, { 1, appParams[1], 1 })
runner.Step("Activate App1 from device 1", common.activateApp, { 1 })
runner.Step("Connect device 2 to SDL", connectDeviceTwo)

function Test.Postcondition_SDLForceStop()
StopSDL()
end
runner.Title("Test")
runner.Step("Register App2 from device 2", common.registerAppEx, { 2, appParams[2], 2 })
runner.Step("Activate App2 from device 2", activateAppTwo)
runner.Step("Start PTU", startPTU)

runner.Title("Postconditions")
runner.Step("Stop SDL", common.postconditions)