diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js index 604725adbcc7e2fbb3738bc8d6a176e0c245a48c..a1d0c3cdc4eae6bf9b1461137ff96fa6ae5cbde4 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js @@ -16,10 +16,6 @@ import audio from '@ohos.multimedia.audio'; import fileio from '@ohos.fileio'; -import ability_featureAbility from '@ohos.ability.featureAbility'; -import app from '@system.app'; -import bundle from '@ohos.bundle'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import featureAbility from '@ohos.ability.featureAbility' import resourceManager from '@ohos.resourceManager'; @@ -36,12 +32,7 @@ describe('audioCall', function () { const audioManager = audio.getAudioManager(); console.info('AudioFrameworkRenderLog: Create AudioManger Object JS Framework'); - const audioManagerRec = audio.getAudioManager(); - console.info('AudioFrameworkRecLog: Create AudioManger Object JS Framework'); - - beforeAll(async function () { - await applyPermission(); console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level'); //mediaDir = '/data/storage/el2/base/haps/entry/cache'; }) @@ -106,36 +97,6 @@ describe('audioCall', function () { }); } - async function applyPermission() { - let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, 100); - let atManager = abilityAccessCtrl.createAtManager(); - if (atManager != null) { - let tokenID = appInfo.accessTokenId; - console.info('AudioFrameworkRenderLog:[permission] case accessTokenID is ' + tokenID); - let permissionName1 = 'ohos.permission.MEDIA_LOCATION'; - let permissionName2 = 'ohos.permission.READ_MEDIA'; - let permissionName3 = 'ohos.permission.WRITE_MEDIA'; - await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - } else { - console.info('AudioFrameworkRenderLog:[permission] case apply permission failed, createAtManager failed'); - } - } - - async function playbackPromise(AudioRendererOptions, pathName, AudioScene) { resultFlagRen = 'new'; console.info('AudioFrameworkRenderLog: Promise : Audio Playback Function'); diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.test.js index a15978591243fe196db270c5fff98d19d6b27833..a161d04d5b51e63fdd904c537d6651ba89a06e55 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.test.js @@ -14,12 +14,9 @@ */ import audio from '@ohos.multimedia.audio'; -import fileio from '@ohos.fileio'; - import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; describe('audioCapturerChange', function () { - var audioCapCallBack; var audioStreamManager; var audioStreamManagerCB; var dirPath; diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js index b468fc066f00569dd603dff24aff2702d790b9ed..3a6f5a7694a7cb3ef9fd535377225f19a54da72b 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js @@ -14,8 +14,6 @@ */ import audio from '@ohos.multimedia.audio'; -import fileio from '@ohos.fileio'; - import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; describe('audioEM', function () { @@ -23,16 +21,6 @@ describe('audioEM', function () { const audioManager = audio.getAudioManager(); var deviceRoleValue = null; var deviceTypeValue = null; - var volErrorMesg = 'Error, Operation not supported or Failed'; - var audioMedia = 3; - var audioRingtone = 2; - var minVol = 0; - var maxVol = 15; - var lowVol = 5; - var highVol = 14; - var outOfRangeVol = 28; - var longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843'; - function sleep (ms) { return new Promise(resolve => setTimeout(resolve, ms)); } diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js index b6b372889c78b091a0a6fd533be14f126b77373d..736a03a96791ca022d0996e229e3a7ec7908f592 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js @@ -15,8 +15,6 @@ import audio from '@ohos.multimedia.audio'; import fileio from '@ohos.fileio'; -import bundle from '@ohos.bundle'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import resourceManager from '@ohos.resourceManager'; import featureAbility from '@ohos.ability.featureAbility' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; @@ -31,7 +29,6 @@ describe('audioRenderer', function () { let filePath; beforeAll(async function () { - await applyPermission(); console.info('AudioFrameworkRenderLog: beforeAll: Prerequisites at the test suite level'); }) @@ -84,35 +81,6 @@ describe('audioRenderer', function () { }); } - async function applyPermission() { - let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, 100); - let atManager = abilityAccessCtrl.createAtManager(); - if (atManager != null) { - let tokenID = appInfo.accessTokenId; - console.info('AudioFrameworkRenderLog:[permission] case accessTokenID is ' + tokenID); - let permissionName1 = 'ohos.permission.MEDIA_LOCATION'; - let permissionName2 = 'ohos.permission.READ_MEDIA'; - let permissionName3 = 'ohos.permission.WRITE_MEDIA'; - await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - } else { - console.info('AudioFrameworkRenderLog:[permission] case apply permission failed, createAtManager failed'); - } - } - async function playbackPromise(AudioRendererOptions, pathName, AudioScene) { var resultFlag = 'new'; console.info('AudioFrameworkRenderLog: Promise : Audio Playback Function'); diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js index af1c6601aad908a920b8d9e563077bd589016a3e..8d015a7333bd81793e2b0df41259fdfc588945a1 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js @@ -14,12 +14,6 @@ */ import audio from '@ohos.multimedia.audio'; -import fileio from '@ohos.fileio'; -import app from '@system.app'; -import bundle from '@ohos.bundle'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; -import featureAbility from '@ohos.ability.featureAbility' -import ability_featureAbility from '@ohos.ability.featureAbility'; import resourceManager from '@ohos.resourceManager'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; @@ -28,13 +22,11 @@ describe('audioRendererChange', function () { var audioStreamManager; var audioStreamManagerCB; let fdRead; - let readpath; var Tag = "AFRenLog : "; const audioManager = audio.getAudioManager(); console.info(Tag+'Create AudioManger Object JS Framework'); beforeAll(async function () { - await applyPermission(); await audioManager.getStreamManager().then(async function (data) { audioStreamManager = data; console.info(Tag+'Get AudioStream Manager : Success '); @@ -106,34 +98,6 @@ describe('audioRendererChange', function () { } }) } - async function applyPermission() { - let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, 100); - let atManager = abilityAccessCtrl.createAtManager(); - if (atManager != null) { - let tokenID = appInfo.accessTokenId; - console.info(Tag+'[permission] case accessTokenID is '+tokenID); - let permissionName1 = 'ohos.permission.MEDIA_LOCATION'; - let permissionName2 = 'ohos.permission.READ_MEDIA'; - let permissionName3 = 'ohos.permission.WRITE_MEDIA'; - await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { - console.info(Tag+'[permission] case grantUserGrantedPermission success :'+result); - }).catch((err) => { - console.info(Tag+'[permission] case grantUserGrantedPermission failed :'+err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { - console.info(Tag+'[permission] case grantUserGrantedPermission success :'+result); - }).catch((err) => { - console.info(Tag+'[permission] case grantUserGrantedPermission failed :'+err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { - console.info(Tag+'[permission] case grantUserGrantedPermission success :'+result); - }).catch((err) => { - console.info(Tag+'[permission] case grantUserGrantedPermission failed :'+err); - }); - } else { - console.info(Tag+'[permission] case apply permission failed, createAtManager failed'); - } - } /* * * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_001 diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js index 757c64a73cb79415fb6f9654cab41a2d9116a2a0..5c6ec6d7d46bce68a9461fd916707a1d8fc588d8 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js @@ -16,10 +16,6 @@ import audio from '@ohos.multimedia.audio'; import fileio from '@ohos.fileio'; -import ability_featureAbility from '@ohos.ability.featureAbility'; -import app from '@system.app'; -import bundle from '@ohos.bundle'; -import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import featureAbility from '@ohos.ability.featureAbility' import resourceManager from '@ohos.resourceManager'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; @@ -33,11 +29,7 @@ describe('audioVoip', function () { const audioManager = audio.getAudioManager(); console.info('AudioFrameworkRenderLog: Create AudioManger Object JS Framework'); - const audioManagerRec = audio.getAudioManager(); - console.info('AudioFrameworkRecLog: Create AudioManger Object JS Framework'); - beforeAll(async function () { - await applyPermission(); console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level'); //mediaDir = '/data/storage/el2/base/haps/entry/cache'; }) @@ -100,35 +92,6 @@ describe('audioVoip', function () { }); } - async function applyPermission() { - let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, 100); - let atManager = abilityAccessCtrl.createAtManager(); - if (atManager != null) { - let tokenID = appInfo.accessTokenId; - console.info('AudioFrameworkRenderLog:[permission] case accessTokenID is ' + tokenID); - let permissionName1 = 'ohos.permission.MEDIA_LOCATION'; - let permissionName2 = 'ohos.permission.READ_MEDIA'; - let permissionName3 = 'ohos.permission.WRITE_MEDIA'; - await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission success :' + result); - }).catch((err) => { - console.info('AudioFrameworkRenderLog:[permission] case grantUserGrantedPermission failed :' + err); - }); - } else { - console.info('AudioFrameworkRenderLog:[permission] case apply permission failed, createAtManager failed'); - } - } - async function playbackPromise(AudioRendererOptions, pathName, AudioScene) { var resultFlag = 'new'; console.info('AudioFrameworkRenderLog: Promise : Audio Playback Function'); diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/getPermission.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/getPermission.test.js index e836f8f47f34f46292e356452913de5c5a7b2bdc..31d080975f8e50f3b12538958c45a8ea1b6c3413 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/getPermission.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/getPermission.test.js @@ -16,9 +16,17 @@ import { describe, beforeAll,afterAll, it, expect } from 'deccjsunit/index'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import bundle from '@ohos.bundle'; - +import account from '@ohos.account.osAccount'; describe("get_permission", function () { - + let userId ; + async function getUserId () { + await account.getAccountManager().getOsAccountLocalIdFromProcess().then(account => { + console.info("getOsAccountLocalIdFromProcess userid ==========" + account); + userId = account; + }).catch(err=>{ + console.info("getOsAccountLocalIdFromProcess err ==========" + JSON.stringify(err)); + }) + } /** * @tc.number SUB_DF_GRANT_USER_GRANTED_PERMISSION_0000 * @tc.name grant_user_granted_permission_async_000 @@ -29,7 +37,8 @@ describe("get_permission", function () { * @tc.require */ it("grant_user_granted_permission_async_000", 0, async function (done) { - let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, 100); + await getUserId(); + let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, userId); let tokenID = appInfo.accessTokenId; let atManager = abilityAccessCtrl.createAtManager(); let result1 = await atManager.grantUserGrantedPermission(tokenID, "ohos.permission.MEDIA_LOCATION",1);