Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7f8faa89
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看板
未验证
提交
7f8faa89
编写于
3月 22, 2022
作者:
潘
潘强标
提交者:
Gitee
3月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix medialibrary on/off
Signed-off-by:
N
panqiangbiao
<
panqiangbiao@huawei.com
>
上级
12d7c8e1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
111 addition
and
117 deletion
+111
-117
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromiseOnOff.test.js
...ard/src/main/js/test/mediaLibraryTestPromiseOnOff.test.js
+111
-117
未找到文件。
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromiseOnOff.test.js
浏览文件 @
7f8faa89
...
...
@@ -20,7 +20,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
describe
(
'
mediaLibraryTestPromiseOnOff.test.js
'
,
async
function
()
{
const
context
=
featureAbility
.
getContext
();
const
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
beforeAll
(
function
()
{});
beforeEach
(
function
()
{});
afterEach
(
function
()
{});
afterAll
(
function
()
{});
let
fileKeyObj
=
mediaLibrary
.
FileKey
;
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
videoType
=
mediaLibrary
.
MediaType
.
VIDEO
;
...
...
@@ -43,7 +46,7 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
fileType
.
toString
()],
};
/**
* @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_001
* @tc.name : ON
...
...
@@ -56,20 +59,19 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
try
{
let
conut
=
0
;
media
.
on
(
'
imageChange
'
,
()
=>
{
console
.
info
(
'
MediaLibraryTest : on 001 callback
'
);
conut
++
;
});
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
expect
(
conut
>
0
).
assertTrue
(
);
media
.
off
(
'
imageChange
'
);
done
(
);
setTimeout
(()
=>
{
expect
(
conut
>
0
).
assertTrue
();
media
.
off
(
'
imageChange
'
);
done
(
);
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : on 001 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -90,17 +92,18 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
try
{
let
conut
=
0
;
media
.
on
(
'
videoChange
'
,
()
=>
{
console
.
info
(
'
MediaLibraryTest : on 002 callback
'
);
conut
++
;
});
const
fetchFileResult
=
await
media
.
getFileAssets
(
videosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
expect
(
conut
==
1
).
assertTrue
();
media
.
off
(
'
videoChange
'
);
done
();
setTimeout
(()
=>
{
expect
(
conut
>
0
).
assertTrue
();
media
.
off
(
'
videoChange
'
);
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : on 002 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -121,17 +124,18 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
try
{
let
conut
=
0
;
media
.
on
(
'
audioChange
'
,
()
=>
{
console
.
info
(
'
MediaLibraryTest : on 003 callback
'
);
conut
++
;
});
const
fetchFileResult
=
await
media
.
getFileAssets
(
audiosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
expect
(
conut
==
1
).
assertTrue
();
media
.
off
(
'
audioChange
'
);
done
();
setTimeout
(()
=>
{
expect
(
conut
>
0
).
assertTrue
();
media
.
off
(
'
audioChange
'
);
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : on 003 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -152,17 +156,18 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
try
{
let
conut
=
0
;
media
.
on
(
'
fileChange
'
,
()
=>
{
console
.
info
(
'
MediaLibraryTest : on 004 callback
'
);
conut
++
;
});
const
fetchFileResult
=
await
media
.
getFileAssets
(
filesfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
expect
(
conut
==
1
).
assertTrue
();
media
.
off
(
'
fileChange
'
);
done
();
setTimeout
(()
=>
{
expect
(
conut
>
0
).
assertTrue
();
media
.
off
(
'
fileChange
'
);
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : on 004 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -183,17 +188,18 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
try
{
let
conut
=
0
;
media
.
on
(
'
albumChange
'
,
()
=>
{
console
.
info
(
'
MediaLibraryTest : on 005 callback
'
);
conut
++
;
});
const
fetchFileResult
=
await
media
.
getFileAssets
(
filesfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
expect
(
conut
==
0
).
assertTrue
();
media
.
off
(
'
albumChange
'
);
done
();
setTimeout
(()
=>
{
expect
(
conut
==
0
).
assertTrue
();
media
.
off
(
'
albumChange
'
);
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : on 005 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -216,17 +222,18 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
expect
(
true
).
assertTrue
();
done
();
media
.
on
(
'
deviceChange
'
,
()
=>
{
console
.
info
(
'
MediaLibraryTest : on 006 callback
'
);
conut
++
;
});
const
fetchFileResult
=
await
media
.
getFileAssets
(
filesfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
expect
(
conut
==
0
).
assertTrue
();
media
.
off
(
'
deviceChange
'
);
done
();
setTimeout
(()
=>
{
expect
(
conut
==
0
).
assertTrue
();
media
.
off
(
'
deviceChange
'
);
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : on 006 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -249,17 +256,18 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
expect
(
true
).
assertTrue
();
done
();
media
.
on
(
'
remoteFileChange
'
,
()
=>
{
console
.
info
(
'
MediaLibraryTest : on 007 callback
'
);
conut
++
;
});
const
fetchFileResult
=
await
media
.
getFileAssets
(
filesfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
expect
(
conut
==
0
).
assertTrue
();
media
.
off
(
'
remoteFileChange
'
);
done
();
setTimeout
(()
=>
{
expect
(
conut
==
0
).
assertTrue
();
media
.
off
(
'
remoteFileChange
'
);
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : on 006 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -287,16 +295,14 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media
.
off
(
'
imageChange
'
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
console
.
info
(
'
MediaLibraryTest : off 001 passed
'
);
expect
(
true
).
assertTrue
();
done
();
setTimeout
(()
=>
{
console
.
info
(
'
MediaLibraryTest : off 001 passed
'
);
expect
(
true
).
assertTrue
();
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : off 001 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -324,16 +330,14 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media
.
off
(
'
videoChange
'
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
videosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
console
.
info
(
'
MediaLibraryTest : off 002 passed
'
);
expect
(
true
).
assertTrue
();
done
();
setTimeout
(()
=>
{
console
.
info
(
'
MediaLibraryTest : off 002 passed
'
);
expect
(
true
).
assertTrue
();
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : off 002 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -361,16 +365,14 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media
.
off
(
'
audioChange
'
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
audiosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
console
.
info
(
'
MediaLibraryTest : off 003 passed
'
);
expect
(
true
).
assertTrue
();
done
();
setTimeout
(()
=>
{
console
.
info
(
'
MediaLibraryTest : off 003 passed
'
);
expect
(
true
).
assertTrue
();
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : off 003 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -398,16 +400,14 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media
.
off
(
'
fileChange
'
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
videosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
changename
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
changename
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
console
.
info
(
'
MediaLibraryTest : off 004 passed
'
);
expect
(
true
).
assertTrue
();
done
();
setTimeout
(()
=>
{
console
.
info
(
'
MediaLibraryTest : off 004 passed
'
);
expect
(
true
).
assertTrue
();
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : off 004 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -435,16 +435,14 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media
.
off
(
'
albumChange
'
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
videosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
albumChange
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
albumChange
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
console
.
info
(
'
MediaLibraryTest : off 005 passed
'
);
expect
(
true
).
assertTrue
();
done
();
setTimeout
(()
=>
{
console
.
info
(
'
MediaLibraryTest : off 005 passed
'
);
expect
(
true
).
assertTrue
();
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : off 005 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -472,16 +470,14 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media
.
off
(
'
deviceChange
'
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
videosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
deviceChange
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
deviceChange
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
console
.
info
(
'
MediaLibraryTest : off 006 passed
'
);
expect
(
true
).
assertTrue
();
done
();
setTimeout
(()
=>
{
console
.
info
(
'
MediaLibraryTest : off 006 passed
'
);
expect
(
true
).
assertTrue
();
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : off 006 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -509,16 +505,14 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
media
.
off
(
'
remoteFileChange
'
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
videosfetchOp
);
const
dataList
=
await
fetchFileResult
.
getAllObject
();
const
asset
=
dataList
[
0
];
asset
.
title
=
'
remoteFileChange
'
;
const
asset
=
await
fetchFileResult
.
getFirstObject
();
asset
.
title
=
asset
.
title
+
'
remoteFileChange
'
;
await
asset
.
commitModify
();
await
new
Promise
((
res
)
=>
setTimeout
(()
=>
res
(),
3000
));
console
.
info
(
'
MediaLibraryTest : off 007 passed
'
);
expect
(
true
).
assertTrue
();
done
();
setTimeout
(()
=>
{
console
.
info
(
'
MediaLibraryTest : off 007 passed
'
);
expect
(
true
).
assertTrue
();
done
();
},
1000
);
}
catch
(
error
)
{
console
.
info
(
`MediaLibraryTest : off 006 failed, error:
${
error
}
`
);
expect
(
false
).
assertTrue
();
...
...
@@ -547,4 +541,4 @@ describe('mediaLibraryTestPromiseOnOff.test.js', async function () {
done
();
}
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录