Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.86 KB | None | 0 0
  1. require('atf.util')
  2. local module = require('testbase')
  3. local mobile = require("mobile_connection")
  4. local tcp = require("tcp_connection")
  5. local file_connection = require("file_connection")
  6. local mobile_session = require("mobile_session")
  7. local websocket = require('websocket_connection')
  8. local hmi_connection = require('hmi_connection')
  9. local events = require("events")
  10. local expectations = require('expectations')
  11. local functionId = require('function_id')
  12. local SDL = require('SDL')
  13. local exit_codes = require('exit_codes')
  14. local load_schema = require('load_schema')
  15.  
  16. local mob_schema = load_schema.mob_schema
  17. local hmi_schema = load_schema.hmi_schema
  18.  
  19. local Event = events.Event
  20.  
  21. local Expectation = expectations.Expectation
  22. local SUCCESS = expectations.SUCCESS
  23. local FAILED = expectations.FAILED
  24.  
  25. module.hmiConnection = hmi_connection.Connection(websocket.WebSocketConnection(config.hmiUrl, config.hmiPort))
  26. local tcpConnection = tcp.Connection(config.mobileHost, config.mobilePort)
  27. local fileConnection = file_connection.FileConnection("mobile.out", tcpConnection)
  28. module.mobileConnection = mobile.MobileConnection(fileConnection)
  29. event_dispatcher:AddConnection(module.hmiConnection)
  30. event_dispatcher:AddConnection(module.mobileConnection)
  31. module.notification_counter = 1
  32.  
  33. function module.hmiConnection:EXPECT_HMIRESPONSE(id, args)
  34. local event = events.Event()
  35. event.matches = function(self, data)
  36. return data["method"] == nil and data.id == id
  37. end
  38. local ret = Expectation("HMI response " .. id, self)
  39. ret:ValidIf(function(self, data)
  40. local arguments
  41. if self.occurences > #args then
  42. arguments = args[#args]
  43. else
  44. arguments = args[self.occurences]
  45. end
  46. xmlReporter.AddMessage("EXPECT_HMIRESPONSE", {["Id"] = tostring(id),["Type"] = "EXPECTED_RESULT"},arguments)
  47. xmlReporter.AddMessage("EXPECT_HMIRESPONSE", {["Id"] = tostring(id),["Type"] = "AVALIABLE_RESULT"},data)
  48. local func_name = data.method
  49. local results_args = arguments
  50. local results_args2 = arguments
  51. if(table2str(arguments):match('result')) then
  52. results_args = arguments.result
  53. results_args2 = arguments.result
  54. elseif(table2str(arguments):match('error')) then
  55. results_args = arguments.error
  56. results_args2 = arguments.error
  57. end
  58.  
  59. if results_args2 and results_args2.code then
  60. results_args2 = table.removeKey(results_args2, 'code')
  61. end
  62. if results_args2 and results_args2.method then
  63. results_args2 = table.removeKey(results_args2, 'method')
  64. elseif results_args2 and results_args2.data.method then
  65. results_args2 = table.removeKey(results_args2.data, 'method')
  66. end
  67.  
  68. if func_name == nil and type(data.result) == 'table' then
  69. func_name = data.result.method
  70. elseif func_name == nil and type(data.error) == 'table' then
  71. print_table(data)
  72. -- print (debug.traceback())
  73. func_name = data.error.data.method
  74. end
  75.  
  76. local _res, _err
  77. _res = true
  78. if not (table2str(arguments):match('error')) then
  79. _res, _err = hmi_schema:Validate(func_name, load_schema.response, data.params)
  80. end
  81. if (not _res) then
  82. return _res,_err
  83. end
  84.  
  85. if func_name and results_args and data.result then
  86. return compareValues(results_args, data.result, "result")
  87. elseif func_name and results_args and data.error then
  88. return compareValues(results_args, data.error, "error")
  89. else
  90. return compareValues(results_args, data.params, "params")
  91. end
  92. end)
  93. ret.event = event
  94. event_dispatcher:AddEvent(module.hmiConnection, event, ret)
  95. module:AddExpectation(ret)
  96. return ret
  97. end
  98.  
  99. function EXPECT_HMIRESPONSE(id,...)
  100. local args = table.pack(...)
  101. return module.hmiConnection:EXPECT_HMIRESPONSE(id, args)
  102. end
  103.  
  104. function EXPECT_HMINOTIFICATION(name,...)
  105. local args = table.pack(...)
  106. local event = events.Event()
  107. event.matches = function(self, data) return data.method == name end
  108. local ret = Expectation("HMI notification " .. name, module.hmiConnection)
  109. if #args > 0 then
  110. ret:ValidIf(function(self, data)
  111. local arguments
  112. if self.occurences > #args then
  113. arguments = args[#args]
  114. else
  115. arguments = args[self.occurences]
  116. end
  117. local correlation_id = module.notification_counter
  118. module.notification_counter = module.notification_counter + 1
  119. xmlReporter.AddMessage("EXPECT_HMINOTIFICATION", {["Id"] = correlation_id, ["name"] = tostring(name),["Type"] = "EXPECTED_RESULT"},arguments)
  120. xmlReporter.AddMessage("EXPECT_HMINOTIFICATION", {["Id"] = correlation_id, ["name"] = tostring(name),["Type"] = "AVALIABLE_RESULT"},data)
  121. local _res, _err = hmi_schema:Validate(name, load_schema.notification, data.params)
  122. if (not _res) then return _res,_err end
  123. return compareValues(arguments, data.params, "params")
  124. end)
  125. end
  126. ret.event = event
  127. event_dispatcher:AddEvent(module.hmiConnection, event, ret)
  128. module:AddExpectation(ret)
  129. return ret
  130. end
  131.  
  132. function EXPECT_HMICALL(methodName, ...)
  133. local args = table.pack(...)
  134. -- TODO: Avoid copy-paste
  135. local event = events.Event()
  136. event.matches =
  137. function(self, data) return data.method == methodName end
  138. local ret = Expectation("HMI call " .. methodName, module.hmiConnection)
  139. if #args > 0 then
  140. ret:ValidIf(function(self, data)
  141. local arguments
  142. if self.occurences > #args then
  143. arguments = args[#args]
  144. else
  145. arguments = args[self.occurences]
  146. end
  147. xmlReporter.AddMessage("EXPECT_HMICALL", {["Id"] = data.id, ["name"] = tostring(methodName),["Type"] = "EXPECTED_RESULT"},arguments)
  148. xmlReporter.AddMessage("EXPECT_HMICALL", {["Id"] = data.id, ["name"] = tostring(methodName),["Type"] = "AVALIABLE_RESULT"},data.params)
  149. _res, _err = hmi_schema:Validate(methodName, load_schema.request, data.params)
  150. if (not _res) then return _res,_err end
  151. return compareValues(arguments, data.params, "params")
  152. end)
  153. end
  154. ret.event = event
  155. event_dispatcher:AddEvent(module.hmiConnection, event, ret)
  156. module:AddExpectation(ret)
  157. return ret
  158. end
  159.  
  160. function EXPECT_NOTIFICATION(func,...)
  161. -- xmlReporter.AddMessage(debug.getinfo(1, "n").name, "EXPECTED_RESULT", ... )
  162. local args = table.pack(...)
  163. local args_count = 1
  164. if #args > 0 then
  165. local arguments = {}
  166. if #args > 1 then
  167. for args_count = 1, #args do
  168. if(type( args[args_count])) == 'table' then
  169. table.insert(arguments, args[args_count])
  170. end
  171. end
  172. else
  173. arguments = args
  174. end
  175. return module.mobileSession:ExpectNotification(func,arguments)
  176. end
  177. return module.mobileSession:ExpectNotification(func,args)
  178.  
  179. end
  180.  
  181. function EXPECT_ANY_SESSION_NOTIFICATION(funcName, ...)
  182. local args = table.pack(...)
  183. local event = events.Event()
  184. event.matches = function(_, data)
  185. return data.rpcFunctionId == functionId[funcName]
  186. end
  187. local ret = Expectation(funcName .. " notification", module.mobileConnection)
  188. if #args > 0 then
  189. ret:ValidIf(function(self, data)
  190. local arguments
  191. if self.occurences > #args then
  192. arguments = args[#args]
  193. else
  194. arguments = args[self.occurences]
  195. end
  196. local _res, _err = mob_schema:Validate(funcName, load_schema.notification, data.payload)
  197. xmlReporter.AddMessage("EXPECT_ANY_SESSION_NOTIFICATION", {["name"] = tostring(funcName),["Type"]= "EXPECTED_RESULT"}, arguments)
  198. xmlReporter.AddMessage("EXPECT_ANY_SESSION_NOTIFICATION", {["name"] = tostring(funcName),["Type"]= "AVALIABLE_RESULT"}, data.payload)
  199. if (not _res) then return _res,_err end
  200. return compareValues(arguments, data.payload, "payload")
  201. end)
  202. end
  203. ret.event = event
  204. event_dispatcher:AddEvent(module.mobileConnection, event, ret)
  205. module.expectations_list:Add(ret)
  206. return ret
  207. end
  208.  
  209. module.timers = { }
  210.  
  211. function RUN_AFTER(func, timeout, funcName)
  212. func_name_str = "noname"
  213. if funcName then
  214. func_name_str = funcName
  215. end
  216. xmlReporter.AddMessage(debug.getinfo(1, "n").name, func_name_str,
  217. {["functionLine"] = debug.getinfo(func, "S").linedefined, ["Timeout"] = tostring(timeout)})
  218. local d = qt.dynamic()
  219. d.timeout = function(self)
  220. func()
  221. module.timers[self] = nil
  222. end
  223. local timer = timers.Timer()
  224. module.timers[timer] = true
  225. qt.connect(timer, "timeout()", d, "timeout()")
  226. timer:setSingleShot(true)
  227. timer:start(timeout)
  228. end
  229.  
  230. function EXPECT_RESPONSE(correlationId, ...)
  231. xmlReporter.AddMessage(debug.getinfo(1, "n").name, "EXPECTED_RESULT", ... )
  232. return module.mobileSession:ExpectResponse(correlationId, ...)
  233. end
  234.  
  235. function EXPECT_ANY_SESSION_RESPONSE(correlationId, ...)
  236. xmlReporter.AddMessage(debug.getinfo(1, "n").name, {["CorrelationId"] = tostring(correlationId)})
  237. local args = table.pack(...)
  238. local event = events.Event()
  239. event.matches = function(_, data)
  240. return data.rpcCorrelationId == correlationId
  241. end
  242. local ret = Expectation("response to " .. correlationId, module.mobileConnection)
  243. if #args > 0 then
  244. ret:ValidIf(function(self, data)
  245. local arguments
  246. if self.occurences > #args then
  247. arguments = args[#args]
  248. else
  249. arguments = args[self.occurences]
  250. end
  251. xmlReporter.AddMessage("EXPECT_ANY_SESSION_RESPONSE", "EXPECTED_RESULT", arguments)
  252. xmlReporter.AddMessage("EXPECT_ANY_SESSION_RESPONSE", "AVALIABLE_RESULT", data.payload)
  253. return compareValues(arguments, data.payload, "payload")
  254. end)
  255. end
  256. ret.event = event
  257. event_dispatcher:AddEvent(module.mobileConnection, event, ret)
  258. module.expectations_list:Add(ret)
  259. return ret
  260. end
  261.  
  262. function EXPECT_ANY()
  263. xmlReporter.AddMessage(debug.getinfo(1, "n").name, '')
  264. return module.mobileSession:ExpectAny()
  265. end
  266.  
  267. function EXPECT_EVENT(event, name)
  268. local ret = Expectation(name, module.mobileConnection)
  269. ret.event = event
  270. event_dispatcher:AddEvent(module.mobileConnection, event, ret)
  271. module:AddExpectation(ret)
  272. return ret
  273. end
  274.  
  275. function RAISE_EVENT(event, data, eventName)
  276. event_str = "noname"
  277. if eventName then
  278. event_str = eventName
  279. end
  280. xmlReporter.AddMessage(debug.getinfo(1, "n").name, event_str)
  281. event_dispatcher:RaiseEvent(module.mobileConnection, data)
  282. end
  283.  
  284. function EXPECT_HMIEVENT(event, name)
  285. local ret = Expectation(name, module.hmiConnection)
  286. ret.event = event
  287. event_dispatcher:AddEvent(module.hmiConnection, event, ret)
  288. module:AddExpectation(ret)
  289. return ret
  290. end
  291.  
  292. function StartSDL(SDLPathName, ExitOnCrash)
  293. return SDL:StartSDL(SDLPathName, config.SDL, ExitOnCrash)
  294. end
  295.  
  296. function StopSDL()
  297. event_dispatcher:ClearEvents()
  298. module.expectations_list:Clear()
  299. return SDL:StopSDL()
  300. end
  301.  
  302. function module:runSDL()
  303. if config.autorunSDL ~= true then
  304. SDL.autoStarted = false
  305. return
  306. end
  307. local result, errmsg = SDL:StartSDL(config.pathToSDL, config.SDL, config.ExitOnCrash)
  308. if not result then
  309. SDL:DeleteFile()
  310. quit(exit_codes.aborted)
  311. end
  312. SDL.autoStarted = true
  313. end
  314.  
  315. function module:createMultipleExpectationsWaiter(name)
  316. assert(name)
  317. exp_waiter = {}
  318. exp_waiter.expectation_list = {}
  319. function exp_waiter:CheckStatus()
  320. if #exp_waiter.expectation_list == 0 and not exp_waiter.expectation.status then
  321. exp_waiter.expectation.status = SUCCESS
  322. event_dispatcher:RaiseEvent(module.mobileConnection, exp_waiter.event)
  323. return true
  324. end
  325. return false
  326. end
  327.  
  328. function exp_waiter:AddExpectation(exp)
  329. table.insert(exp_waiter.expectation_list, exp)
  330. --print ("add ", exp)
  331. exp:Do(function()
  332. --print ("remove ",exp)
  333. exp_waiter:RemoveExpectation(exp)
  334. exp_waiter:CheckStatus()
  335. end)
  336. end
  337.  
  338. function exp_waiter:RemoveExpectation(exp)
  339. local function AnIndexOf(t,val)
  340. for k,v in ipairs(t) do
  341. if v == val then return k end
  342. end
  343. return nil
  344. end
  345.  
  346.  
  347. table.remove(exp_waiter.expectation_list,
  348. AnIndexOf(exp_waiter.expectation_list, exp))
  349. end
  350.  
  351. exp_waiter.event = events.Event()
  352.  
  353. exp_waiter.event.matches = function(self, e)
  354. return self == e
  355. end
  356.  
  357. exp_waiter.expectation = Expectation(name, module.mobileConnection)
  358. exp_waiter.expectation.event = exp_waiter.event
  359. exp_waiter.event.level = 3
  360. event_dispatcher:AddEvent(module.mobileConnection, exp_waiter.event , exp_waiter.expectation)
  361. module:AddExpectation(exp_waiter.expectation)
  362. return exp_waiter
  363. end
  364.  
  365. function module:initHMI()
  366.  
  367. local exp_waiter = module:createMultipleExpectationsWaiter("Hmi initialization")
  368. --local hmi_initialised = events.Event()
  369. local function registerComponent(name, subscriptions)
  370. local rid = module.hmiConnection:SendRequest("MB.registerComponent", { componentName = name })
  371. local exp = EXPECT_HMIRESPONSE(rid)
  372. exp_waiter:AddExpectation(exp)
  373. if subscriptions then
  374. for _, s in ipairs(subscriptions) do
  375. exp:Do(function(_, data)
  376. local rid = module.hmiConnection:SendRequest("MB.subscribeTo", { propertyName = s })
  377. local exp = EXPECT_HMIRESPONSE(rid)
  378. exp_waiter:AddExpectation(exp)
  379. end)
  380. end
  381. end
  382. end
  383.  
  384. local web_socket_connected_event = EXPECT_HMIEVENT(events.connectedEvent, "Connected websocket")
  385. :Do(function()
  386. registerComponent("Buttons", {"Buttons.OnButtonSubscription"})
  387. registerComponent("TTS")
  388. registerComponent("VR")
  389. registerComponent("BasicCommunication",
  390. {
  391. "BasicCommunication.OnPutFile",
  392. "SDL.OnStatusUpdate",
  393. "SDL.OnAppPermissionChanged",
  394. "BasicCommunication.OnSDLPersistenceComplete",
  395. "BasicCommunication.OnFileRemoved",
  396. "BasicCommunication.OnAppRegistered",
  397. "BasicCommunication.OnAppUnregistered",
  398. "BasicCommunication.PlayTone",
  399. "BasicCommunication.OnSDLClose",
  400. "SDL.OnSDLConsentNeeded",
  401. "BasicCommunication.OnResumeAudioSource"
  402. })
  403. registerComponent("UI",
  404. {
  405. "UI.OnRecordStart"
  406. })
  407. registerComponent("VehicleInfo")
  408. registerComponent("Navigation",
  409. {
  410. "Navigation.OnAudioDataStreaming",
  411. "Navigation.OnVideoDataStreaming"
  412. })
  413. end)
  414. exp_waiter:AddExpectation(web_socket_connected_event)
  415.  
  416. self.hmiConnection:Connect()
  417. return exp_waiter.expectation
  418. end
  419.  
  420. function module:initHMI_onReady()
  421. local exp_waiter = module:createMultipleExpectationsWaiter("Hmi on ready")
  422. local function ExpectRequest(name, mandatory, params)
  423. local event = events.Event()
  424. event.level = 2
  425. event.matches = function(self, data)
  426. return data.method == name
  427. end
  428. local exp = EXPECT_HMIEVENT(event, name)
  429. :Times(mandatory and 1 or AnyNumber())
  430. :Do(function(_, data)
  431. xmlReporter.AddMessage("hmi_connection","SendResponse",
  432. {
  433. ["methodName"] = tostring(name),
  434. ["mandatory"] = mandatory ,
  435. ["params"]= params
  436. })
  437. --print ("request:", name)
  438. self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", params)
  439. end)
  440. if (mandatory) then
  441. exp_waiter:AddExpectation(exp)
  442. end
  443. return exp
  444. end
  445.  
  446. local function ExpectNotification(name, mandatory)
  447. xmlReporter.AddMessage(debug.getinfo(1, "n").name, tostring(name))
  448. local event = events.Event()
  449. event.level = 2
  450. event.matches = function(self, data) return data.method == name end
  451. local exp = EXPECT_HMIEVENT(event, name)
  452. :Times(mandatory and 1 or AnyNumber())
  453. exp_waiter:AddExpectation(exp)
  454. return exp
  455. end
  456.  
  457. ExpectRequest("BasicCommunication.MixingAudioSupported",
  458. true,
  459. { attenuatedSupported = true })
  460. ExpectRequest("BasicCommunication.GetSystemInfo", false,
  461. {
  462. ccpu_version = "ccpu_version",
  463. language = "EN-US",
  464. wersCountryCode = "wersCountryCode"
  465. })
  466. ExpectRequest("UI.GetLanguage", true, { language = "EN-US" })
  467. ExpectRequest("VR.GetLanguage", true, { language = "EN-US" })
  468. ExpectRequest("TTS.GetLanguage", true, { language = "EN-US" })
  469. ExpectRequest("UI.ChangeRegistration", false, { }):Pin()
  470. ExpectRequest("TTS.SetGlobalProperties", false, { }):Pin()
  471. ExpectRequest("BasicCommunication.UpdateDeviceList", false, { }):Pin()
  472. ExpectRequest("VR.ChangeRegistration", false, { }):Pin()
  473. ExpectRequest("TTS.ChangeRegistration", false, { }):Pin()
  474. ExpectRequest("VR.GetSupportedLanguages", true, {
  475. languages = {
  476. "EN-US","ES-MX","FR-CA","DE-DE","ES-ES","EN-GB","RU-RU",
  477. "TR-TR","PL-PL","FR-FR","IT-IT","SV-SE","PT-PT","NL-NL",
  478. "ZH-TW","JA-JP","AR-SA","KO-KR","PT-BR","CS-CZ","DA-DK",
  479. "NO-NO","NL-BE","EL-GR","HU-HU","FI-FI","SK-SK" }
  480. })
  481. ExpectRequest("TTS.GetSupportedLanguages", true, {
  482. languages = {
  483. "EN-US","ES-MX","FR-CA","DE-DE","ES-ES","EN-GB","RU-RU",
  484. "TR-TR","PL-PL","FR-FR","IT-IT","SV-SE","PT-PT","NL-NL",
  485. "ZH-TW","JA-JP","AR-SA","KO-KR","PT-BR","CS-CZ","DA-DK",
  486. "NO-NO","NL-BE","EL-GR","HU-HU","FI-FI","SK-SK" }
  487. })
  488. ExpectRequest("UI.GetSupportedLanguages", true, {
  489. languages = {
  490. "EN-US","ES-MX","FR-CA","DE-DE","ES-ES","EN-GB","RU-RU",
  491. "TR-TR","PL-PL","FR-FR","IT-IT","SV-SE","PT-PT","NL-NL",
  492. "ZH-TW","JA-JP","AR-SA","KO-KR","PT-BR","CS-CZ","DA-DK",
  493. "NO-NO","NL-BE","EL-GR","HU-HU","FI-FI","SK-SK" }
  494. })
  495. ExpectRequest("VehicleInfo.GetVehicleType", true, {
  496. vehicleType =
  497. {
  498. make = "Ford",
  499. model = "Fiesta",
  500. modelYear = "2013",
  501. trim = "SE"
  502. }
  503. })
  504. ExpectRequest("VehicleInfo.GetVehicleData", true, { vin = "52-452-52-752" })
  505.  
  506. local function button_capability(name, shortPressAvailable, longPressAvailable, upDownAvailable)
  507. return
  508. {
  509. name = name,
  510. shortPressAvailable = shortPressAvailable == nil and true or shortPressAvailable,
  511. longPressAvailable = longPressAvailable == nil and true or longPressAvailable,
  512. upDownAvailable = upDownAvailable == nil and true or upDownAvailable
  513. }
  514. end
  515.  
  516. local buttons_capabilities =
  517. {
  518. capabilities =
  519. {
  520. button_capability("PRESET_0"),
  521. button_capability("PRESET_1"),
  522. button_capability("PRESET_2"),
  523. button_capability("PRESET_3"),
  524. button_capability("PRESET_4"),
  525. button_capability("PRESET_5"),
  526. button_capability("PRESET_6"),
  527. button_capability("PRESET_7"),
  528. button_capability("PRESET_8"),
  529. button_capability("PRESET_9"),
  530. button_capability("OK", true, false, true),
  531. button_capability("SEEKLEFT"),
  532. button_capability("SEEKRIGHT"),
  533. button_capability("TUNEUP"),
  534. button_capability("TUNEDOWN")
  535. },
  536. presetBankCapabilities = { onScreenPresetsAvailable = true }
  537. }
  538. ExpectRequest("Buttons.GetCapabilities", true, buttons_capabilities)
  539. ExpectRequest("VR.GetCapabilities", true, { vrCapabilities = { "TEXT" } })
  540. ExpectRequest("TTS.GetCapabilities", true, {
  541. speechCapabilities = { "TEXT", "PRE_RECORDED" },
  542. prerecordedSpeechCapabilities =
  543. {
  544. "HELP_JINGLE",
  545. "INITIAL_JINGLE",
  546. "LISTEN_JINGLE",
  547. "POSITIVE_JINGLE",
  548. "NEGATIVE_JINGLE"
  549. }
  550. })
  551.  
  552. local function text_field(name, characterSet, width, rows)
  553. return
  554. {
  555. name = name,
  556. characterSet = characterSet or "TYPE2SET",
  557. width = width or 500,
  558. rows = rows or 1
  559. }
  560. end
  561. local function image_field(name, width, height)
  562. return
  563. {
  564. name = name,
  565. imageTypeSupported =
  566. {
  567. "GRAPHIC_BMP",
  568. "GRAPHIC_JPEG",
  569. "GRAPHIC_PNG"
  570. },
  571. imageResolution =
  572. {
  573. resolutionWidth = width or 64,
  574. resolutionHeight = height or 64
  575. }
  576. }
  577.  
  578. end
  579.  
  580. ExpectRequest("UI.GetCapabilities", true, {
  581. displayCapabilities =
  582. {
  583. displayType = "GEN2_8_DMA",
  584. textFields =
  585. {
  586. text_field("mainField1"),
  587. text_field("mainField2"),
  588. text_field("mainField3"),
  589. text_field("mainField4"),
  590. text_field("statusBar"),
  591. text_field("mediaClock"),
  592. text_field("mediaTrack"),
  593. text_field("alertText1"),
  594. text_field("alertText2"),
  595. text_field("alertText3"),
  596. text_field("scrollableMessageBody"),
  597. text_field("initialInteractionText"),
  598. text_field("navigationText1"),
  599. text_field("navigationText2"),
  600. text_field("ETA"),
  601. text_field("totalDistance"),
  602. text_field("navigationText"),
  603. text_field("audioPassThruDisplayText1"),
  604. text_field("audioPassThruDisplayText2"),
  605. text_field("sliderHeader"),
  606. text_field("sliderFooter"),
  607. text_field("notificationText"),
  608. text_field("menuName"),
  609. text_field("secondaryText"),
  610. text_field("tertiaryText"),
  611. text_field("timeToDestination"),
  612. text_field("turnText"),
  613. text_field("menuTitle"),
  614. text_field("locationName"),
  615. text_field("locationDescription"),
  616. text_field("addressLines"),
  617. text_field("phoneNumber")
  618. },
  619. imageFields =
  620. {
  621. image_field("softButtonImage"),
  622. image_field("choiceImage"),
  623. image_field("choiceSecondaryImage"),
  624. image_field("vrHelpItem"),
  625. image_field("turnIcon"),
  626. image_field("menuIcon"),
  627. image_field("cmdIcon"),
  628. image_field("showConstantTBTIcon"),
  629. image_field("locationImage")
  630. },
  631. mediaClockFormats =
  632. {
  633. "CLOCK1",
  634. "CLOCK2",
  635. "CLOCK3",
  636. "CLOCKTEXT1",
  637. "CLOCKTEXT2",
  638. "CLOCKTEXT3",
  639. "CLOCKTEXT4"
  640. },
  641. graphicSupported = true,
  642. imageCapabilities = { "DYNAMIC", "STATIC" },
  643. templatesAvailable = { "TEMPLATE" },
  644. screenParams =
  645. {
  646. resolution = { resolutionWidth = 800, resolutionHeight = 480 },
  647. touchEventAvailable =
  648. {
  649. pressAvailable = true,
  650. multiTouchAvailable = true,
  651. doublePressAvailable = false
  652. }
  653. },
  654. numCustomPresetsAvailable = 10
  655. },
  656. audioPassThruCapabilities =
  657. {
  658. samplingRate = "44KHZ",
  659. bitsPerSample = "8_BIT",
  660. audioType = "PCM"
  661. },
  662. hmiZoneCapabilities = "FRONT",
  663. softButtonCapabilities =
  664. {
  665. {
  666. shortPressAvailable = true,
  667. longPressAvailable = true,
  668. upDownAvailable = true,
  669. imageSupported = true
  670. }
  671. }
  672. })
  673.  
  674. ExpectRequest("VR.IsReady", true, { available = true })
  675. ExpectRequest("TTS.IsReady", true, { available = true })
  676. ExpectRequest("UI.IsReady", true, { available = true })
  677. ExpectRequest("Navigation.IsReady", true, { available = true })
  678. ExpectRequest("VehicleInfo.IsReady", true, { available = true })
  679.  
  680. self.applications = { }
  681. ExpectRequest("BasicCommunication.UpdateAppList", false, { })
  682. :Pin()
  683. :Do(function(_, data)
  684. self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", { })
  685. self.applications = { }
  686. for _, app in pairs(data.params.applications) do
  687. self.applications[app.appName] = app.appID
  688. end
  689. end)
  690. self.hmiConnection:SendNotification("BasicCommunication.OnReady")
  691. return exp_waiter.expectation
  692. end
  693.  
  694. function module:connectMobile()
  695. -- Disconnected expectation
  696. EXPECT_EVENT(events.disconnectedEvent, "Disconnected")
  697. :Pin()
  698. :Times(AnyNumber())
  699. :Do(function()
  700. print("Disconnected!!!")
  701. quit(exit_codes.aborted)
  702. end)
  703. self.mobileConnection:Connect()
  704. return EXPECT_EVENT(events.connectedEvent, "Connected")
  705. end
  706.  
  707. function module:startSession()
  708. self.mobileSession = mobile_session.MobileSession(
  709. self,
  710. self.mobileConnection,
  711. config.application1.registerAppInterfaceParams)
  712. self.mobileSession:Start()
  713. local mobile_connected = EXPECT_HMICALL("BasicCommunication.UpdateAppList")
  714. mobile_connected:Do(function(_, data)
  715. self.hmiConnection:SendResponse(data.id, data.method, "SUCCESS", { })
  716. self.applications = { }
  717. for _, app in pairs(data.params.applications) do
  718. self.applications[app.appName] = app.appID
  719. end
  720. end)
  721. return mobile_connected
  722. end
  723.  
  724. function enableFullATFLogs()
  725. function enableFullLoggintTestCase()
  726. if (config.storeFullATFLogs) then
  727. module:FailTestCase("full ATF logs already enabled")
  728. else
  729. config.storeFullATFLogs = true
  730. end
  731. end
  732. module["EnableFullATFLogs"] = nil
  733. module["EnableFullATFLogs"] = enableFullLoggintTestCase
  734. end
  735.  
  736. function disableFullATFLogs()
  737. function disableFullLoggintTestCase()
  738. if (not config.storeFullATFLogs) then
  739. module:FailTestCase("full ATF logs already disabled")
  740. else
  741. config.storeFullATFLogs = false
  742. end
  743. end
  744. module["DisableFullATFLogs"] = nil
  745. module["DisableFullATFLogs"] = disableFullLoggintTestCase
  746. end
  747.  
  748.  
  749. -- function module:RunSDL()
  750. -- self:runSDL()
  751. -- end
  752.  
  753. -- function module:InitHMI()
  754. -- critical(true)
  755. -- self:initHMI()
  756. -- end
  757.  
  758. -- function module:InitHMI_onReady()
  759. -- critical(true)
  760. -- self:initHMI_onReady()
  761. -- end
  762.  
  763. -- function module:ConnectMobile()
  764. -- critical(true)
  765. -- self:connectMobile()
  766. -- end
  767.  
  768. -- function module:StartSession()
  769. -- critical(true)
  770. -- self:startSession()
  771. -- end
  772.  
  773. return module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement