未验证 提交 504f9e49 编写于 作者: O openharmony_ci 提交者: Gitee

!7268 修改媒体库XTS获取权限的方式,增加媒体库XTS用例的权限获取操作的延时

Merge pull request !7268 from 梁家熙/new10
......@@ -235,20 +235,26 @@ const getPermission = async function (name, context) {
console.info("getPermission start", name);
let permissions = ["ohos.permission.MEDIA_LOCATION", "ohos.permission.READ_MEDIA", "ohos.permission.WRITE_MEDIA"];
context.requestPermissionsFromUser(permissions, (data) => {
console.info(`getPermission requestPermissionsFromUser ${JSON.stringify(data)}`);
});
await sleep(200);
let atManager = abilityAccessCtrl.createAtManager();
try {
atManager.requestPermissionsFromUser(context, permissions, (err, data) => {
console.info(`getPermission requestPermissionsFromUser ${JSON.stringify(data)}`);
});
} catch (err) {
console.log(`get permission catch err -> ${JSON.stringify(err)}`);
}
await sleep(1000);
let driver = uitest.Driver.create();
await sleep(200);
await sleep(2000);
let button = await driver.findComponent(uitest.ON.text("允许"));
await button.click();
await sleep(2000);
let appInfo = await bundle.getApplicationInfo(name, 0, 100);
let tokenID = appInfo.accessTokenId;
let atManager = abilityAccessCtrl.createAtManager();
let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION");
let isGranted2 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA");
let isGranted3 = await atManager.verifyAccessToken(tokenID, "ohos.permission.WRITE_MEDIA");
......
......@@ -25,21 +25,27 @@ export default function getExifNoLocation(abilityContext) {
describe("getExifNoLocation", function () {
beforeAll(async function () {
console.info("beforeAll case");
let atManager = abilityAccessCtrl.createAtManager();
let permissions = ["ohos.permission.READ_MEDIA"];
abilityContext.requestPermissionsFromUser(permissions, (data) => {
console.info(`getPermission requestPermissionsFromUser ${JSON.stringify(data)}`);
});
await sleep(200);
try {
atManager.requestPermissionsFromUser(abilityContext, permissions, (err, data) => {
console.info(`getPermission requestPermissionsFromUser ${JSON.stringify(data)}`);
});
} catch (err) {
console.log(`get permission catch err -> ${JSON.stringify(err)}`);
}
await sleep(1000);
let driver = uitest.Driver.create();
await sleep(200);
await sleep(2000);
let button = await driver.findComponent(uitest.ON.text("允许"));
await button.click();
await sleep(2000);
let appInfo = await bundle.getApplicationInfo("ohos.acts.multimedia.mediaLibrary", 0, 100);
let tokenID = appInfo.accessTokenId;
let atManager = abilityAccessCtrl.createAtManager();
let isGranted = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA");
if (isGranted != 0) {
console.info("getpermission failed");
......
......@@ -25,22 +25,28 @@ export default function getExifLocation(abilityContext) {
describe("getExifLocation", function () {
beforeAll(async function () {
console.info("beforeAll case");
let atManager = abilityAccessCtrl.createAtManager();
let permissions = ["ohos.permission.MEDIA_LOCATION", "ohos.permission.READ_MEDIA"];
abilityContext.requestPermissionsFromUser(permissions, (data) => {
console.info(`getPermission requestPermissionsFromUser ${JSON.stringify(data)}`);
});
await sleep(200);
try {
atManager.requestPermissionsFromUser(abilityContext, permissions, (err, data) => {
console.info(`getPermission requestPermissionsFromUser ${JSON.stringify(data)}`);
});
} catch (err) {
console.log(`get permission catch err -> ${JSON.stringify(err)}`);
}
await sleep(1000);
let driver = uitest.Driver.create();
await sleep(200);
await sleep(2000);
let button = await driver.findComponent(uitest.ON.text("允许"));
await button.click();
await sleep(2000);
let appInfo = await bundle.getApplicationInfo("ohos.acts.multimedia.mediaLibrary", 0, 100);
let tokenID = appInfo.accessTokenId;
let atManager = abilityAccessCtrl.createAtManager();
let isGranted1 = await atManager.verifyAccessToken(tokenID, "ohos.permission.MEDIA_LOCATION");
let isGranted2 = await atManager.verifyAccessToken(tokenID, "ohos.permission.READ_MEDIA");
if (!(isGranted1 == 0 && isGranted2 == 0)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册