From 884c27138676053bed4071f4312b9495ae13cbb0 Mon Sep 17 00:00:00 2001 From: collin Date: Tue, 1 Sep 2020 19:16:41 -0400 Subject: [PATCH 1/2] add tests for re-subscribing to app service data with resumption and unsubscribing on disconnect of last app subscribed --- .../3470_HMI_provider_resume_subscription.lua | 137 ++++++++++++++++++ ...70_mobile_provider_resume_subscription.lua | 116 +++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 test_scripts/Defects/7_0/3470_HMI_provider_resume_subscription.lua create mode 100644 test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua diff --git a/test_scripts/Defects/7_0/3470_HMI_provider_resume_subscription.lua b/test_scripts/Defects/7_0/3470_HMI_provider_resume_subscription.lua new file mode 100644 index 0000000000..c41cf84e41 --- /dev/null +++ b/test_scripts/Defects/7_0/3470_HMI_provider_resume_subscription.lua @@ -0,0 +1,137 @@ +--------------------------------------------------------------------------------------------------- +-- TBA +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local common = require('user_modules/sequences/actions') +local utils = require("user_modules/utils") + +--[[ Test Configuration ]] +runner.testSettings.isSelfIncluded = false + +-- [[ Local Variables ]] +local manifest = { + serviceName = "HMI_MEDIA_SERVICE", + serviceType = "MEDIA", + allowAppConsumers = true, + rpcSpecVersion = common.getConfigAppParams(1).syncMsgVersion, + mediaServiceManifest = {} +} +local serviceId +local hashId + +-- [[ Local Functions ]] +local function publishEmbeddedAppService() + local cid = common.getHMIConnection():SendRequest("AppService.PublishAppService", { + appServiceManifest = manifest }) + common.getHMIConnection():ExpectResponse(cid, { + result = { + appServiceRecord = { + serviceManifest = manifest, + servicePublished = true + }, + code = 0, + method = "AppService.PublishAppService" + } + }) + :Do(function(_, data) + serviceId = data.result.appServiceRecord.serviceID + end) + common.getHMIConnection():ExpectNotification("BasicCommunication.OnSystemCapabilityUpdated") + :Times(2) +end + +local function subscribeAppServiceData(pIsSubscribed) + local params = { + serviceType = manifest.serviceType, + subscribe = pIsSubscribed + } + local cid = common.getMobileSession():SendRPC("GetAppServiceData", params) + common.getHMIConnection():ExpectRequest("AppService.GetAppServiceData") + :Do(function(_, data) + common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) + end) + common.getMobileSession():ExpectResponse(cid, { success = true, resultCode = "SUCCESS" }) + common.getMobileSession():ExpectNotification("OnHashChange") + :Do(function(_, data) + hashId = data.payload.hashID + end) +end + +local function sendOnAppServiceData(pIsExp) + local occurences = pIsExp == true and 1 or 0 + local params = { + serviceData = { + serviceType = manifest.serviceType, + serviceID = serviceId, + mediaServiceData = { + mediaType = "MUSIC", + mediaTitle = "Song name", + mediaArtist = "Band name", + mediaAlbum = "Album name", + playlistName = "Good music", + isExplicit = false, + trackPlaybackProgress = 200, + trackPlaybackDuration = 300, + queuePlaybackProgress = 2200, + queuePlaybackDuration = 4000, + queueCurrentTrackNumber = 12, + queueTotalTrackCount = 20 + } + } + } + common.getHMIConnection():SendNotification("AppService.OnAppServiceData", params) + common.getMobileSession():ExpectNotification("OnAppServiceData", params):Times(occurences) +end + +local function unexpectedDisconnect() + local params = { + serviceType = manifest.serviceType, + subscribe = false + } + common.getHMIConnection():ExpectRequest("AppService.GetAppServiceData", params) + :Do(function(_, data) + common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) + end) + common.getHMIConnection():ExpectNotification("BasicCommunication.OnAppUnregistered", { unexpectedDisconnect = true }) + :Times(common.mobile.getAppsCount()) + common.mobile.disconnect() + utils.wait(1000) +end + +local function ptUpdate(pt) + pt.policy_table.app_policies[common.app.getPolicyAppId()].groups = { "Base-4", "AppServiceConsumer" } +end + +local function reRegisterApp() + common.app.getParams().hashID = hashId + common.app.registerNoPTU() + local params = { + serviceType = manifest.serviceType, + subscribe = true + } + common.getHMIConnection():ExpectRequest("AppService.GetAppServiceData", params) + :Do(function(_, data) + common.getHMIConnection():SendResponse(data.id, data.method, "SUCCESS", {}) + 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("Register app", common.registerApp) +runner.Step("Activate app", common.activateApp) +runner.Step("PTU", common.policyTableUpdate, { ptUpdate }) +runner.Step("Publish Embedded App Service", publishEmbeddedAppService, { manifest }) + +runner.Title("Test") +runner.Step("Subscribe to App Service Data", subscribeAppServiceData, { true }) +runner.Step("Check subscription", sendOnAppServiceData, { true }) +runner.Step("Unexpected disconnect", unexpectedDisconnect) +runner.Step("Connect mobile", common.mobile.connect) +runner.Step("Reregister App resumption data", reRegisterApp) +runner.Step("Check subscription", sendOnAppServiceData, { true }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", common.postconditions) diff --git a/test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua b/test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua new file mode 100644 index 0000000000..2d8a0d89ca --- /dev/null +++ b/test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua @@ -0,0 +1,116 @@ +--------------------------------------------------------------------------------------------------- +-- TBA +--------------------------------------------------------------------------------------------------- +--[[ Required Shared libraries ]] +local runner = require('user_modules/script_runner') +local common = require('test_scripts/AppServices/commonAppServices') +local utils = require("user_modules/utils") + +--[[ Test Configuration ]] +runner.testSettings.isSelfIncluded = false + +-- [[ Local Variables ]] +local manifest = { + serviceName = config.application2.registerAppInterfaceParams.appName, + serviceType = "MEDIA", + allowAppConsumers = true, + rpcSpecVersion = config.application2.registerAppInterfaceParams.syncMsgVersion, + mediaServiceManifest = {} +} + +local hashId + +-- [[ Local Functions ]] +local function sendOnAppServiceData(pIsExp) + local occurences = pIsExp == true and 1 or 0 + local params = { + serviceData = { + serviceType = manifest.serviceType, + serviceID = common.getAppServiceID(2), + mediaServiceData = { + mediaType = "MUSIC", + mediaTitle = "Song name", + mediaArtist = "Band name", + mediaAlbum = "Album name", + playlistName = "Good music", + isExplicit = false, + trackPlaybackProgress = 200, + trackPlaybackDuration = 300, + queuePlaybackProgress = 2200, + queuePlaybackDuration = 4000, + queueCurrentTrackNumber = 12, + queueTotalTrackCount = 20 + } + } + } + common.getMobileSession(2):SendNotification("OnAppServiceData", params) + common.getMobileSession():ExpectNotification("OnAppServiceData", params):Times(occurences) +end + +local function unexpectedDisconnect() + local params = { + serviceType = manifest.serviceType, + subscribe = false + } + common.getMobileSession(2):ExpectRequest("GetAppServiceData", params) + :Do(function(_, data) + common.getMobileSession(2):SendResponse(data.id, "GetAppServiceData", "SUCCESS") + end) + common.getHMIConnection():ExpectNotification("BasicCommunication.OnAppUnregistered", { unexpectedDisconnect = true }) + :Times(common.mobile.getAppsCount()) + common.mobile.disconnect() + utils.wait(1000) +end + +local function ptUpdate(pt) + pt.policy_table.app_policies[common.getConfigAppParams(1).fullAppID] = common.getAppServiceConsumerConfig(1); + pt.policy_table.app_policies[common.getConfigAppParams(2).fullAppID] = common.getAppServiceProducerConfig(2, manifest.serviceType); +end + +local function reRegisterApp() + common.app.getParams().hashID = hashId + common.app.registerNoPTU() + local params = { + serviceType = manifest.serviceType, + subscribe = true + } + + common.getMobileSession(2):ExpectRequest("GetAppServiceData", params) + :Do(function(_, data) + common.getMobileSession(2):SendResponse(data.id, "GetAppServiceData", "SUCCESS") + end) +end + +local function subscribeAppService() + common.getMobileSession():ExpectNotification("OnHashChange") + :Do(function(_, data) + hashId = data.payload.hashID + end) + + common.mobileSubscribeAppServiceData(2, manifest.serviceType, 1) +end + +--[[ Scenario ]] +runner.Title("Preconditions") +runner.Step("Clean environment", common.preconditions) +runner.Step("Start SDL, HMI, connect Mobile, start Session", common.start) +runner.Step("Register app", common.registerApp) +runner.Step("Activate app", common.activateApp) +runner.Step("PTU", common.policyTableUpdate, { ptUpdate }) +runner.Step("Register app 2", common.registerAppWOPTU, { 2 }) +runner.Step("Activate app 2", common.activateApp, { 2 }) +runner.Step("Publish App Service", common.publishMobileAppService, { manifest, 2 }) + +runner.Title("Test") +runner.Step("Subscribe to App Service Data", subscribeAppService) +runner.Step("Check subscription", sendOnAppServiceData, { true }) +runner.Step("Unexpected disconnect", unexpectedDisconnect) +runner.Step("Connect mobile", common.mobile.connect) +runner.Step("Register app 2", common.registerAppWOPTU, { 2 }) +runner.Step("Activate app 2", common.activateApp, { 2 }) +runner.Step("Publish App Service", common.publishMobileAppService, { manifest, 2 }) +runner.Step("Reregister App resumption data", reRegisterApp) +runner.Step("Check subscription", sendOnAppServiceData, { true }) + +runner.Title("Postconditions") +runner.Step("Stop SDL", common.postconditions) From 85b7c4fc003be8eba91120f6e789fe3a8d41286d Mon Sep 17 00:00:00 2001 From: collin Date: Tue, 1 Sep 2020 19:46:18 -0400 Subject: [PATCH 2/2] fix GetAppServiceData responses --- .../7_0/3470_mobile_provider_resume_subscription.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua b/test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua index 2d8a0d89ca..1aa8c7ff17 100644 --- a/test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua +++ b/test_scripts/Defects/7_0/3470_mobile_provider_resume_subscription.lua @@ -54,8 +54,8 @@ local function unexpectedDisconnect() } common.getMobileSession(2):ExpectRequest("GetAppServiceData", params) :Do(function(_, data) - common.getMobileSession(2):SendResponse(data.id, "GetAppServiceData", "SUCCESS") - end) + common.getMobileSession(2):SendResponse("GetAppServiceData", data.rpcCorrelationId, "SUCCESS") + end) common.getHMIConnection():ExpectNotification("BasicCommunication.OnAppUnregistered", { unexpectedDisconnect = true }) :Times(common.mobile.getAppsCount()) common.mobile.disconnect() @@ -77,7 +77,7 @@ local function reRegisterApp() common.getMobileSession(2):ExpectRequest("GetAppServiceData", params) :Do(function(_, data) - common.getMobileSession(2):SendResponse(data.id, "GetAppServiceData", "SUCCESS") + common.getMobileSession(2):SendResponse("GetAppServiceData", data.rpcCorrelationId, "SUCCESS") end) end