-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathcommonIconResumed.lua
195 lines (179 loc) · 6.25 KB
/
commonIconResumed.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
---------------------------------------------------------------------------------------------------
-- Common module
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--[[ General configuration parameters ]]
config.defaultProtocolVersion = 2
--[[ Required Shared libraries ]]
local actions = require("user_modules/sequences/actions")
local utils = require("user_modules/utils")
local test = require("user_modules/dummy_connecttest")
local commonPreconditions = require('user_modules/shared_testcases/commonPreconditions')
local mobile_session = require('mobile_session')
--[[ Module ]]
local m = actions
--[[ Variables ]]
--[[ @getPathToFileInStorage: Get path of app icon from storage
--! @parameters:
--! pFileName - Name of file
--! pAppId - application number (1, 2, etc.)
--! @return: app icon path
--]]
function m.getPathToFileInStorage(pFileName, pAppId)
if not pAppId then pAppId = 1 end
return commonPreconditions:GetPathToSDL() .. "storage/"
.. m.getConfigAppParams(pAppId).fullAppID .. "_"
.. utils.getDeviceMAC() .. "/" .. pFileName
end
--[[ @getIconValueForResumption: Get path of app icon from storage
--! @parameters:
--! pAppId - application number (1, 2, etc.)
--! @return: app icon path
--]]
function m.getIconValueForResumption(pAppId)
if not pAppId then pAppId = 1 end
return commonPreconditions:GetPathToSDL() .. "storage/" .. m.getConfigAppParams(pAppId).fullAppID
end
--[[ @registerAppWOPTU: register mobile application
--! @parameters:
--! pAppId - application number (1, 2, etc.)
--! pIconResumed - apps icon was resumed at system or is not resumed
--! pReconnection - re-register mobile application
--! @return: none
--]]
function m.registerAppWOPTU(pAppId, pIconResumed, pReconnection)
if not pAppId then pAppId = 1 end
local pIconValue
if pIconResumed == true then pIconValue = m.getIconValueForResumption(pAppId) end
local mobSession = m.getMobileSession(pAppId)
local function RegisterApp()
local corId = mobSession:SendRPC("RegisterAppInterface",
config["application" .. pAppId].registerAppInterfaceParams)
test.hmiConnection:ExpectNotification("BasicCommunication.OnAppRegistered", {
application = {
appName = config["application" .. pAppId].registerAppInterfaceParams.appName,
icon = pIconValue
}
})
:ValidIf(function(_,data)
if false == pIconResumed and
data.params.application.icon then
return false, "BC.OnAppRegistered notification contains unexpected parameter: icon "
end
return true
end)
mobSession:ExpectResponse(corId, { success = true, resultCode = "SUCCESS", iconResumed = pIconResumed })
:Do(function()
mobSession:ExpectNotification("OnHMIStatus", {
hmiLevel = "NONE", audioStreamingState = "NOT_AUDIBLE", systemContext = "MAIN"
})
mobSession:ExpectNotification("OnPermissionsChange")
end)
end
if pReconnection == true then
RegisterApp()
else
mobSession:StartService(7)
:Do(function()
RegisterApp()
end)
end
end
--[[ @unregisterAppInterface: Mobile application unregistration
--! @parameters:
--! pAppId - Application number (1, 2, etc.)
--! @return: none
--]]
function m.unregisterAppInterface(pAppId)
if not pAppId then pAppId = 1 end
local mobSession = m.getMobileSession(pAppId)
local corId = mobSession:SendRPC("UnregisterAppInterface", { })
EXPECT_HMINOTIFICATION("BasicCommunication.OnAppUnregistered", {
appID = m.getHMIAppId(pAppId), unexpectedDisconnect = false
})
mobSession:ExpectResponse(corId, { success = true, resultCode = "SUCCESS" })
end
--[[ @getPutFileAllParams: get all parameter for PutFile
--! @parameters: none
--! @return: parameters for PutFile
--]]
local function getPutFileAllParams()
return {
syncFileName = "icon.png",
fileType = "GRAPHIC_PNG",
persistentFile = false,
systemFile = false,
offset = 0,
length = 11600
}
end
--[[ @putFile: Successful processing PutFile RPC
--! @parameters:
--! pParamsSend - parameters for PutFile RPC
--! pFile - file will be used to send to SDL
--! pAppId - Application number (1, 2, etc.)
--! @return: none
--]]
function m.putFile(pParamsSend, pFile, pAppId)
if pParamsSend then
pParamsSend = pParamsSend
else
pParamsSend = getPutFileAllParams()
end
if not pAppId then pAppId = 1 end
local mobSession = m.getMobileSession(pAppId)
local cid
if pFile ~= nil then
cid = mobSession:SendRPC("PutFile", pParamsSend, pFile)
else
cid = mobSession:SendRPC("PutFile", pParamsSend, "files/icon_png.png")
end
mobSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
end
--[[ @setAppIcon: Successful Processing of SetAppIcon RPC
--! @parameters:
--! pParams - Parameters for SetAppIcon RPC
--! pAppId - Application number (1, 2, etc.)
--! @return: none
--]]
function m.setAppIcon(pParams, pAppId)
if not pAppId then pAppId = 1 end
local mobSession = m.getMobileSession(pAppId)
local cid = mobSession:SendRPC("SetAppIcon", pParams.requestParams)
pParams.requestUiParams.appID = m.getHMIAppId()
EXPECT_HMICALL("UI.SetAppIcon", pParams.requestUiParams)
:Do(function(_, data)
m.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {})
end)
mobSession:ExpectResponse(cid, { success = true, resultCode = "SUCCESS" })
end
--[[ @closeConnection: Close mobile connection successfully
--! @parameters: none
--! @return: none
--]]
function m.closeConnection()
EXPECT_HMINOTIFICATION("BasicCommunication.OnAppUnregistered", { unexpectedDisconnect = true })
actions.mobile.disconnect()
actions.run.wait(1000)
end
--[[ @openConnection: Open mobile connection successfully
--! @parameters: none
--! return: none
--]]
function m.openConnection()
actions.mobile.connect()
:Do(function()
m.mobile.createSession():StartRPC()
end)
end
local preconditionsOrig = m.preconditions
--[[ @preconditions: Expand initial precondition with removing storage folder
--! @parameters: none
--! return: none
--]]
function m.preconditions()
preconditionsOrig()
local storage = commonPreconditions:GetPathToSDL() .. "storage"
os.execute("rm -rf " .. storage)
end
return m