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

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

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