Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
504f9e49
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
504f9e49
编写于
1月 28, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 28, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7268 修改媒体库XTS获取权限的方式,增加媒体库XTS用例的权限获取操作的延时
Merge pull request !7268 from 梁家熙/new10
上级
8b14daa5
a047e6d0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
20 deletion
+38
-20
multimedia/medialibrary/common.js
multimedia/medialibrary/common.js
+13
-7
multimedia/medialibrary/mediaLibrary_getExifNoLocation/entry/src/main/ets/test/getExifNoLocation.test.ets
...cation/entry/src/main/ets/test/getExifNoLocation.test.ets
+13
-7
multimedia/medialibrary/mediaLibrary_getExiflocation/entry/src/main/ets/test/getExifLocation.test.ets
...location/entry/src/main/ets/test/getExifLocation.test.ets
+12
-6
未找到文件。
multimedia/medialibrary/common.js
浏览文件 @
504f9e49
...
...
@@ -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
"
);
...
...
multimedia/medialibrary/mediaLibrary_getExifNoLocation/entry/src/main/ets/test/getExifNoLocation.test.ets
浏览文件 @
504f9e49
...
...
@@ -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(200
0
);
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");
...
...
multimedia/medialibrary/mediaLibrary_getExiflocation/entry/src/main/ets/test/getExifLocation.test.ets
浏览文件 @
504f9e49
...
...
@@ -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(200
0
);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录