提交 8af4e5c7 编写于 作者: L lwx1121892

<audio修改>

Signed-off-by: Nlwx1121892 <liuxueqi3@huawei.com>
上级 b3bcad2e
......@@ -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');
......
......@@ -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;
......
......@@ -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));
}
......
......@@ -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');
......
......@@ -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
......
......@@ -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');
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册