Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
95a4e0f3
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看板
提交
95a4e0f3
编写于
7月 04, 2023
作者:
Y
yangbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixbug 3.0
Signed-off-by:
N
yangbo
<
yangbo258@huawei.com
>
上级
29b3d07a
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
234 addition
and
309 deletion
+234
-309
multimedia/photoAccess/common.ts
multimedia/photoAccess/common.ts
+1
-0
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/List.test.ets
...oAccess/photoAccess/entry/src/main/ets/test/List.test.ets
+8
-8
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/createAsset.ets
...entry/src/main/ets/test/PhotoAccessHelper/createAsset.ets
+78
-166
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/getAlbums.ets
...s/entry/src/main/ets/test/PhotoAccessHelper/getAlbums.ets
+0
-0
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/getAssets.ets
...s/entry/src/main/ets/test/PhotoAccessHelper/getAssets.ets
+4
-4
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
...ry/src/main/ets/test/PhotoAccessHelper/registerChange.ets
+15
-15
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/release.ets
...ess/entry/src/main/ets/test/PhotoAccessHelper/release.ets
+0
-0
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
.../src/main/ets/test/PhotoAccessHelper/unRegisterChange.ets
+21
-21
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/commitModify.ets
...ccess/entry/src/main/ets/test/PhotoAsset/commitModify.ets
+34
-42
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/getReadOnlyFd.ets
...cess/entry/src/main/ets/test/PhotoAsset/getReadOnlyFd.ets
+9
-3
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/close.ets
...s/entry/src/main/ets/test/PhotoAssetFetchResult/close.ets
+9
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getLastObject.ets
...src/main/ets/test/PhotoAssetFetchResult/getLastObject.ets
+5
-1
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getObjectByPosition.ets
...in/ets/test/PhotoAssetFetchResult/getObjectByPosition.ets
+4
-2
multimedia/photoAccess/photoAccessSystem/BUILD.gn
multimedia/photoAccess/photoAccessSystem/BUILD.gn
+6
-6
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
...em/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
+37
-37
multimedia/photoAccess/photoAccessSystem/entry/src/main/resources/base/element/string.json
...sSystem/entry/src/main/resources/base/element/string.json
+3
-3
未找到文件。
multimedia/photoAccess/common.ts
浏览文件 @
95a4e0f3
...
...
@@ -13,6 +13,7 @@
* limitations under the License.
*/
// @ts-nocheck
import
photoAccessHelper
from
'
@ohos.file.photoAccessHelper
'
;
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundleManager
from
'
@ohos.bundle.bundleManager
'
;
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/List.test.ets
浏览文件 @
95a4e0f3
...
...
@@ -35,12 +35,12 @@ import assetGetLastObjectTest from './PhotoAssetFetchResult/getLastObject'
import assetGetNextObjectTest from './PhotoAssetFetchResult/getNextObject'
import assetGetPositionObjectTest from './PhotoAssetFetchResult/getObjectByPosition'
import assetIsAfterLastTest from './PhotoAssetFetchResult/isAfterLast'
import createAssetTest from './
UserFileManag
er/createAsset'
import getAlbumsTest from './
UserFileManag
er/getAlbums'
import getAssetsTest from './
UserFileManag
er/getAssets'
import
offTest from './UserFileManager/off
'
import
onTest from './UserFileManager/on
'
import releaseTest from './
UserFileManag
er/release'
import createAssetTest from './
PhotoAccessHelp
er/createAsset'
import getAlbumsTest from './
PhotoAccessHelp
er/getAlbums'
import getAssetsTest from './
PhotoAccessHelp
er/getAssets'
import
unRegisterChangeTest from './PhotoAccessHelper/unRegisterChange
'
import
registerChangeTest from './PhotoAccessHelper/registerChange
'
import releaseTest from './
PhotoAccessHelp
er/release'
import checkAttrTest from './PhotoAsset/checkAttr'
import closeTest from './PhotoAsset/close'
import commitModifyTest from './PhotoAsset/commitModify'
...
...
@@ -74,8 +74,8 @@ export default function testsuite () {
createAssetTest()
getAlbumsTest()
getAssetsTest()
off
Test()
on
Test()
unRegisterChange
Test()
registerChange
Test()
releaseTest()
checkAttrTest()
closeTest()
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
UserFileManag
er/createAsset.ets
→
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
PhotoAccessHelp
er/createAsset.ets
浏览文件 @
95a4e0f3
...
...
@@ -243,28 +243,6 @@ export default function createAssetTest () {
await
createAssetAbnormalCallback1
(
done
,
testNum
,
type
,
extension
,
options
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_IMAGE_0700
* @tc.name : createImage_callback_007
* @tc.desc : createAsset with title 'aaaaaaa....' (253)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
// it('createImage_callback_007', 2, async function (done) {
// const testNum = 'createImage_callback_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.IMAGE;
// const extension = 'jpg';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalCallback1(done, testNum, type, extension, options);
// });
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_IMAGE_0000
* @tc.name : createImage_promise_000
...
...
@@ -386,28 +364,6 @@ export default function createAssetTest () {
await
createAssetAbnormalPromise1
(
done
,
testNum
,
type
,
extension
,
options
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_IMAGE_0700
* @tc.name : createImage_promise_007
* @tc.desc : createAsset with title 'aaaaaaa....' (253)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
// it('createImage_promise_007', 2, async function (done) {
// const testNum = 'createImage_promise_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.IMAGE;
// const extension = 'jpg';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalPromise1(done, testNum, type, extension, options);
// });
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_VIDEO_0000
* @tc.name : createVideo_callback_000
...
...
@@ -529,28 +485,6 @@ export default function createAssetTest () {
await
createAssetAbnormalCallback1
(
done
,
testNum
,
type
,
extension
,
options
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_CREATE_VIDEO_0700
* @tc.name : createVideo_callback_007
* @tc.desc : createAsset with title 'aaaaaaa....' (253)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
// it('createVideo_callback_007', 2, async function (done) {
// const testNum = 'createVideo_callback_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.VIDEO;
// const extension = 'mp4';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalCallback1(done, testNum, type, extension, options);
// });
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_VIDEO_0000
* @tc.name : createVideo_promise_000
...
...
@@ -671,27 +605,5 @@ export default function createAssetTest () {
const
options
:
photoAccessHelper
.
CreateOptions
=
undefined
;
await
createAssetAbnormalPromise1
(
done
,
testNum
,
type
,
extension
,
options
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_CREATE_VIDEO_0700
* @tc.name : createVideo_promise_007
* @tc.desc : createAsset with title 'aaaaaaa....' (253)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
// it('createVideo_promise_007', 2, async function (done) {
// const testNum = 'createVideo_promise_007';
// let value = '';
// for (let i = 0; i < 253; i++) {
// value += 'a';
// }
// const type = photoType.VIDEO;
// const extension = 'mp4';
// const options: photoAccessHelper.CreateOptions = {
// title: value
// }
// await createAssetAbnormalPromise1(done, testNum, type, extension, options);
// });
})
}
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
UserFileManag
er/getAlbums.ets
→
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
PhotoAccessHelp
er/getAlbums.ets
浏览文件 @
95a4e0f3
文件已移动
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
UserFileManag
er/getAssets.ets
→
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
PhotoAccessHelp
er/getAssets.ets
浏览文件 @
95a4e0f3
...
...
@@ -133,9 +133,9 @@ export default function getAssetsTest () {
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level
0
* @tc.level : Level
2
*/
it
(
'getAssets_callback_003'
,
0
,
async
function
(
done
)
{
it
(
'getAssets_callback_003'
,
2
,
async
function
(
done
)
{
const
testNum
=
'getAssets_callback_003'
;
await
getAssetsAbnormalCallbackTest
(
done
,
testNum
,
undefined
);
});
...
...
@@ -177,9 +177,9 @@ export default function getAssetsTest () {
* @tc.desc : getAssets image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level
0
* @tc.level : Level
2
*/
it
(
'getAssets_promise_003'
,
0
,
async
function
(
done
)
{
it
(
'getAssets_promise_003'
,
2
,
async
function
(
done
)
{
const
testNum
=
'getAssets_promise_003'
;
await
getAssetsAbnormalPromiseTest
(
done
,
testNum
,
undefined
);
});
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
UserFileManager/on
.ets
→
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
PhotoAccessHelper/registerChange
.ets
浏览文件 @
95a4e0f3
...
...
@@ -25,8 +25,8 @@ import {
photoType,
} from '../../../../../../../common'
export default function
on
Test () {
describe('
on
Test', function () {
export default function
registerChange
Test () {
describe('
registerChange
Test', function () {
const helper = photoAccessHelper.getPhotoAccessHelper(globalThis.abilityContext)
const { NOTIFY_ADD, NOTIFY_UPDATE, NOTIFY_REMOVE, NOTIFY_ALBUM_ADD_ASSET, NOTIFY_ALBUM_REMOVE_ASSET } =
photoAccessHelper.NotifyType;
...
...
@@ -48,10 +48,10 @@ export default function onTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.
on
(asset.uri, false, async (changeData) => {
helper.
registerChange
(asset.uri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.
off
(asset.uri);
helper.
unRegisterChange
(asset.uri);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
expect(changeData.uris[0]).assertEqual(asset.uri);
});
...
...
@@ -81,10 +81,10 @@ export default function onTest () {
try {
let changeDataUri = '';
let listenCount = 0;
helper.
on
(DEFAULT_ALBUM_URI, true, async (changeData) => {
helper.
registerChange
(DEFAULT_ALBUM_URI, true, async (changeData) => {
listenCount++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
helper.
off
(DEFAULT_ALBUM_URI);
helper.
unRegisterChange
(DEFAULT_ALBUM_URI);
changeDataUri = changeData.uris[0];
expect(changeData.type).assertEqual(NOTIFY_ADD);
});
...
...
@@ -92,7 +92,7 @@ export default function onTest () {
let album = await helper.createAlbum(albumName);
let creatAlbumUri = album.albumUri;
await sleep(2000);
helper.
off
(DEFAULT_ALBUM_URI);
helper.
unRegisterChange
(DEFAULT_ALBUM_URI);
expect(creatAlbumUri).assertEqual(changeDataUri);
expect(listenCount).assertEqual(1);
done();
...
...
@@ -120,7 +120,7 @@ export default function onTest () {
let album = await helper.createAlbum(albumName);
albumUri = album.albumUri;
await sleep(500);
helper.
on
(albumUri, false, async (changeData) => {
helper.
registerChange
(albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_UPDATE);
...
...
@@ -129,7 +129,7 @@ export default function onTest () {
album.albumName = Date.now() + album.albumName;
await album.commitModify();
await sleep(1000);
helper.
off
(albumUri);
helper.
unRegisterChange
(albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
...
...
@@ -156,16 +156,16 @@ export default function onTest () {
const asset = await getFileAsset(testNum, fetchOps);
let count = 0;
await sleep(500);
helper.
on
(album.albumUri, false, async (changeData) => {
helper.
registerChange
(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_ADD_ASSET);
expect(changeData.uris[0]).assertEqual(album.albumUri);
//
expect(changeData.extraUris[0]).assertEqual(asset.uri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await album.addAssets([asset]);
await sleep(1000);
helper.
off
(album.albumUri);
helper.
unRegisterChange
(album.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
...
...
@@ -193,16 +193,16 @@ export default function onTest () {
let count = 0;
await album.addAssets([asset]);
await sleep(500);
helper.
on
(album.albumUri, false, async (changeData) => {
helper.
registerChange
(album.albumUri, false, async (changeData) => {
count++;
console.info(`${testNum} changeData: ${JSON.stringify(changeData)}`);
expect(changeData.type).assertEqual(NOTIFY_ALBUM_REMOVE_ASSET);
expect(changeData.uris[0]).assertEqual(album.albumUri);
//
expect(changeData.extraUris[0]).assertEqual(asset.uri);
expect(changeData.extraUris[0]).assertEqual(asset.uri);
});
await album.removeAssets([asset]);
await sleep(1000);
helper.
off
(album.albumUri);
helper.
unRegisterChange
(album.albumUri);
expect(count).assertEqual(1);
done();
} catch (error) {
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
UserFileManag
er/release.ets
→
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
PhotoAccessHelp
er/release.ets
浏览文件 @
95a4e0f3
文件已移动
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
UserFileManager/off
.ets
→
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/
PhotoAccessHelper/unRegisterChange
.ets
浏览文件 @
95a4e0f3
...
...
@@ -27,8 +27,8 @@ import {
albumSubtype
}
from
'../../../../../../../common'
export
default
function
off
Test
()
{
describe
(
'
off
Test'
,
function
()
{
export
default
function
unRegisterChange
Test
()
{
describe
(
'
unRegisterChange
Test'
,
function
()
{
const
helper
=
photoAccessHelper
.
getPhotoAccessHelper
(
globalThis
.
abilityContext
)
const
DEFAULT_PHOTO_URI
=
photoAccessHelper
.
DefaultChangeUri
.
DEFAULT_PHOTO_URI
;
const
DEFAULT_ALBUM_URI
=
photoAccessHelper
.
DefaultChangeUri
.
DEFAULT_ALBUM_URI
;
...
...
@@ -48,12 +48,12 @@ export default function offTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
100
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
...
...
@@ -80,12 +80,12 @@ export default function offTest () {
const
testNum
=
'off_007'
;
try
{
let
count
=
0
;
helper
.
on
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
DEFAULT_ALBUM_URI
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
100
);
let
albumName
=
testNum
+
Date
.
now
();
await
helper
.
createAlbum
(
albumName
);
...
...
@@ -116,12 +116,12 @@ export default function offTest () {
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
await
sleep
(
500
);
helper
.
on
(
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
albumUri
);
helper
.
unRegisterChange
(
albumUri
);
await
sleep
(
100
);
album
.
albumName
=
Date
.
now
()
+
album
.
albumName
;
await
album
.
commitModify
();
...
...
@@ -155,12 +155,12 @@ export default function offTest () {
albumUri
=
album
.
albumUri
;
await
album
.
addAssets
([
asset
]);
await
sleep
(
500
);
helper
.
on
(
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
albumUri
);
helper
.
unRegisterChange
(
albumUri
);
await
sleep
(
100
);
album
.
albumName
=
testNum
+
album
.
albumName
;
await
album
.
commitModify
();
...
...
@@ -191,12 +191,12 @@ export default function offTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
album
.
albumUri
);
helper
.
unRegisterChange
(
album
.
albumUri
);
await
sleep
(
100
);
await
album
.
addAssets
([
asset
]);
await
sleep
(
1000
);
...
...
@@ -227,12 +227,12 @@ export default function offTest () {
let
count
=
0
;
await
album
.
addAssets
([
asset
]);
await
sleep
(
500
);
helper
.
on
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
album
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
album
.
albumUri
);
helper
.
unRegisterChange
(
album
.
albumUri
);
await
sleep
(
100
);
await
album
.
removeAssets
([
asset
]);
await
sleep
(
1000
);
...
...
@@ -260,16 +260,16 @@ export default function offTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
listenCount
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData1: ${JSON.stringify(changeData)}`
);
});
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData2: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
100
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
...
...
@@ -307,13 +307,13 @@ export default function offTest () {
const
callback2
=
async
(
changeData
)
=>
{
listenCount2
++
;
console
.
info
(
`${testNum} callback2: ${JSON.stringify(changeData)}`
);
helper
.
off
(
asset
.
uri
,
callback2
);
helper
.
unRegisterChange
(
asset
.
uri
,
callback2
);
};
helper
.
on
(
asset
.
uri
,
false
,
callback1
);
helper
.
on
(
asset
.
uri
,
false
,
callback2
);
helper
.
registerChange
(
asset
.
uri
,
false
,
callback1
);
helper
.
registerChange
(
asset
.
uri
,
false
,
callback2
);
await
sleep
(
100
);
helper
.
off
(
asset
.
uri
,
callback1
);
helper
.
unRegisterChange
(
asset
.
uri
,
callback1
);
await
sleep
(
100
);
const
newTitle
=
testNum
+
asset
.
get
(
photoKeys
.
TITLE
);
asset
.
set
(
photoKeys
.
TITLE
,
newTitle
);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/commitModify.ets
浏览文件 @
95a4e0f3
...
...
@@ -117,14 +117,14 @@ export default function commitModifyTest () {
it
(
'photoAsset_commitModify_callback_000'
,
0
,
async
function
(
done
)
{
const
testNum
=
'photoAsset_commitModify_callback_000'
;
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyCb01.jpg'
);
const
newTitle
=
new
Date
()
.
getTime
()
+
'.jpg'
;
const
newTitle
=
new
Date
()
.
getTime
()
+
testNum
;
await
commitModifyCallback
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0100
* @tc.name : photoAsset_commitModify_callback_001
* @tc.desc : modify image displayName '
中中...' (83
)
* @tc.desc : modify image displayName '
一...' (84
)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -133,10 +133,9 @@ export default function commitModifyTest () {
const
testNum
=
'photoAsset_commitModify_callback_001'
;
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyCb02.jpg'
);
let
newTitle
=
''
;
for
(
let
i
=
0
;
i
<
8
3
;
i
++
)
{
newTitle
+=
'
中
'
;
for
(
let
i
=
0
;
i
<
8
4
;
i
++
)
{
newTitle
+=
'
一
'
;
}
newTitle
+=
'.jpg'
;
await
commitModifyCallback
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
...
...
@@ -155,7 +154,6 @@ export default function commitModifyTest () {
for
(
let
i
=
0
;
i
<
251
;
i
++
)
{
newTitle
+=
'a'
;
}
newTitle
+=
'.jpg'
;
await
commitModifyCallback
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
...
...
@@ -194,7 +192,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0500
* @tc.name : photoAsset_commitModify_callback_005
* @tc.desc : modify image displayName '
中中
....jpg' (84)
* @tc.desc : modify image displayName '
二二
....jpg' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -205,7 +203,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
84
;
i
++
)
{
value
+=
'
中
'
;
value
+=
'
二
'
;
}
value
+=
'.jpg'
;
await
commitModifyAbnormalCallback
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
@@ -214,7 +212,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0600
* @tc.name : photoAsset_commitModify_callback_006
* @tc.desc : modify image displayName '
aaaaaaa
...' (252)
* @tc.desc : modify image displayName '
bbbbbbb
...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -225,7 +223,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
252
;
i
++
)
{
value
+=
'
a
'
;
value
+=
'
b
'
;
}
value
+=
'.jpg'
;
await
commitModifyAbnormalCallback
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
@@ -243,14 +241,14 @@ export default function commitModifyTest () {
it
(
'photoAsset_commitModify_callback_007'
,
0
,
async
function
(
done
)
{
const
testNum
=
'photoAsset_commitModify_callback_007'
;
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyCb01.mp4'
);
const
newTitle
=
new
Date
()
.
getTime
()
+
'.mp4'
;
const
newTitle
=
new
Date
()
.
getTime
()
+
testNum
;
await
commitModifyCallback
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0800
* @tc.name : photoAsset_commitModify_callback_008
* @tc.desc : modify video displayName '
中中...' (83
)
* @tc.desc : modify video displayName '
三三...' (84
)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -259,17 +257,16 @@ export default function commitModifyTest () {
const
testNum
=
'photoAsset_commitModify_callback_008'
;
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyCb02.mp4'
);
let
newTitle
=
''
;
for
(
let
i
=
0
;
i
<
8
3
;
i
++
)
{
newTitle
+=
'
中
'
;
for
(
let
i
=
0
;
i
<
8
4
;
i
++
)
{
newTitle
+=
'
三
'
;
}
newTitle
+=
'.mp4'
;
await
commitModifyCallback
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_0900
* @tc.name : photoAsset_commitModify_callback_009
* @tc.desc : modify image displayName '
aaaaaaa
...' (251)
* @tc.desc : modify image displayName '
ccccccc
...' (251)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -279,9 +276,8 @@ export default function commitModifyTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyCb03.mp4'
);
let
newTitle
=
''
;
for
(
let
i
=
0
;
i
<
251
;
i
++
)
{
newTitle
+=
'
a
'
;
newTitle
+=
'
c
'
;
}
newTitle
+=
'.mp4'
;
await
commitModifyCallback
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
...
...
@@ -320,7 +316,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_1200
* @tc.name : photoAsset_commitModify_callback_012
* @tc.desc : modify image displayName '
中中
...' (84)
* @tc.desc : modify image displayName '
四四
...' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -331,7 +327,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
84
;
i
++
)
{
value
+=
'
中
'
;
value
+=
'
四
'
;
}
value
+=
'.mp4'
;
await
commitModifyAbnormalCallback
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
@@ -340,7 +336,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_CALLBACK_FILE_ASSET_COMMITMODIFY_1300
* @tc.name : photoAsset_commitModify_callback_013
* @tc.desc : modify image displayName '
aaaaaaa
...' (252)
* @tc.desc : modify image displayName '
ddddddd
...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -351,7 +347,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
252
;
i
++
)
{
value
+=
'
a
'
;
value
+=
'
d
'
;
}
value
+=
'.mp4'
;
await
commitModifyAbnormalCallback
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
@@ -377,7 +373,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0100
* @tc.name : photoAsset_commitModify_promise_001
* @tc.desc : modify image displayName '
中中
...' (83)
* @tc.desc : modify image displayName '
五五
...' (83)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -387,16 +383,15 @@ export default function commitModifyTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyPro02.jpg'
);
let
newTitle
=
''
;
for
(
let
i
=
0
;
i
<
83
;
i
++
)
{
newTitle
+=
'
中
'
;
newTitle
+=
'
五
'
;
}
newTitle
+=
'.jpg'
;
await
commitModifyPromise
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0200
* @tc.name : photoAsset_commitModify_promise_002
* @tc.desc : modify image displayName '
aaaaaaa
...' (251)
* @tc.desc : modify image displayName '
eeeeeee
...' (251)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -406,9 +401,8 @@ export default function commitModifyTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyPro03.jpg'
);
let
newTitle
=
''
;
for
(
let
i
=
0
;
i
<
251
;
i
++
)
{
newTitle
+=
'
a
'
;
newTitle
+=
'
e
'
;
}
newTitle
+=
'.jpg'
;
await
commitModifyPromise
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
...
...
@@ -447,7 +441,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0500
* @tc.name : photoAsset_commitModify_promise_005
* @tc.desc : modify image displayName '
中中
....jpg' (84)
* @tc.desc : modify image displayName '
六六
....jpg' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -458,7 +452,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
84
;
i
++
)
{
value
+=
'
中
'
;
value
+=
'
六
'
;
}
value
+=
'.jpg'
;
await
commitModifyAbnormalPromise
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
@@ -467,7 +461,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0600
* @tc.name : photoAsset_commitModify_promise_006
* @tc.desc : modify image displayName '
aaaaaaa
...' (252)
* @tc.desc : modify image displayName '
fffffff
...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -478,7 +472,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
252
;
i
++
)
{
value
+=
'
a
'
;
value
+=
'
f
'
;
}
value
+=
'.jpg'
;
await
commitModifyAbnormalPromise
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
@@ -503,7 +497,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0800
* @tc.name : photoAsset_commitModify_promise_008
* @tc.desc : modify video displayName '
中中
...' (83)
* @tc.desc : modify video displayName '
七七
...' (83)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -513,16 +507,15 @@ export default function commitModifyTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyPro02.mp4'
);
let
newTitle
=
''
;
for
(
let
i
=
0
;
i
<
83
;
i
++
)
{
newTitle
+=
'
中
'
;
newTitle
+=
'
七
'
;
}
newTitle
+=
'.mp4'
;
await
commitModifyPromise
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_0900
* @tc.name : photoAsset_commitModify_promise_009
* @tc.desc : modify image displayName '
aaaaaaa
...' (251)
* @tc.desc : modify image displayName '
ggggggg
...' (251)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -532,9 +525,8 @@ export default function commitModifyTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'modifyPro03.mp4'
);
let
newTitle
=
''
;
for
(
let
i
=
0
;
i
<
251
;
i
++
)
{
newTitle
+=
'
a
'
;
newTitle
+=
'
g
'
;
}
newTitle
+=
'.mp4'
;
await
commitModifyPromise
(
done
,
testNum
,
fetchOps
,
newTitle
);
});
...
...
@@ -573,7 +565,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_1200
* @tc.name : photoAsset_commitModify_promise_012
* @tc.desc : modify image displayName '
中中
...' (84)
* @tc.desc : modify image displayName '
八八
...' (84)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -584,7 +576,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
84
;
i
++
)
{
value
+=
'
中
'
;
value
+=
'
八
'
;
}
value
+=
'.mp4'
;
await
commitModifyAbnormalPromise
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
@@ -593,7 +585,7 @@ export default function commitModifyTest () {
/**
* @tc.number : SUB_PHOTOACCESS_HELPER_PROMISE_FILE_ASSET_COMMITMODIFY_1300
* @tc.name : photoAsset_commitModify_promise_013
* @tc.desc : modify image displayName '
aaaaaaa
...' (252)
* @tc.desc : modify image displayName '
hhhhhhh
...' (252)
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -604,7 +596,7 @@ export default function commitModifyTest () {
const
type
=
'displayName'
;
let
value
=
''
;
for
(
let
i
=
0
;
i
<
252
;
i
++
)
{
value
+=
'
a
'
;
value
+=
'
h
'
;
}
value
+=
'.mp4'
;
await
commitModifyAbnormalPromise
(
done
,
testNum
,
fetchOps
,
type
,
value
);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAsset/getReadOnlyFd.ets
浏览文件 @
95a4e0f3
...
...
@@ -14,6 +14,7 @@
*/
// @ts-nocheck
import
fileio
from
"@ohos.fileio"
;
import
{
describe
,
it
,
expect
}
from
'deccjsunit/index'
import
{
photoKeys
,
...
...
@@ -34,7 +35,12 @@ export default function getReadOnlyFdTest () {
expect
(
false
)
.
assertTrue
();
}
else
{
console
.
info
(
`${testNum} fd: ${fd}`
);
expect
(
isNum
(
fd
))
.
assertTrue
();
try
{
await
fileio
.
write
(
fd
,
testNum
);
expect
(
false
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} error: ${error}`
);
}
}
done
();
})
...
...
@@ -50,11 +56,11 @@ export default function getReadOnlyFdTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
const
fd
=
await
asset
.
getReadOnlyFd
();
console
.
info
(
`${testNum} fd: ${fd}`
);
expect
(
isNum
(
fd
))
.
assertTrue
();
await
fileio
.
write
(
fd
,
testNum
);
expect
(
false
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed; error: ${error}`
);
expect
(
false
)
.
assertTrue
();
done
();
}
}
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/close.ets
浏览文件 @
95a4e0f3
...
...
@@ -31,50 +31,58 @@ export default function assetCloseTest () {
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
expect
(
fetchResult
.
getCount
()
>
0
)
.
assertTrue
();
fetchResult
.
close
();
let
testCount
=
0
;
let
count
=
0
;
try
{
testCount
++
;
fetchResult
.
getCount
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} getCount failed; error: ${error}`
);
count
++
;
}
try
{
testCount
++
;
await
fetchResult
.
getFirstObject
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} getFirstObject failed; error: ${error}`
);
count
++
;
}
try
{
testCount
++
;
await
fetchResult
.
getNextObject
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} getNextObject failed; error: ${error}`
);
count
++
;
}
try
{
testCount
++
;
await
fetchResult
.
getLastObject
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} getLastObject failed; error: ${error}`
);
count
++
;
}
try
{
testCount
++
;
await
fetchResult
.
getObjectByPosition
(
0
);
}
catch
(
error
)
{
console
.
info
(
`${testNum} getObjectByPosition failed; error: ${error}`
);
count
++
;
}
try
{
testCount
++
;
await
fetchResult
.
getAllObjects
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} getAllObjects failed; error: ${error}`
);
count
++
;
}
try
{
testCount
++
;
fetchResult
.
isAfterLast
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} isAfterLast failed; error: ${error}`
);
count
++
;
}
expect
(
count
)
.
assertEqual
(
7
);
expect
(
count
)
.
assertEqual
(
testCount
);
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed; error: ${error}`
);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getLastObject.ets
浏览文件 @
95a4e0f3
...
...
@@ -37,6 +37,8 @@ export default function assetGetLastObjectTest () {
expect
(
false
)
.
assertTrue
();
}
else
{
expect
(
asset
!==
undefined
)
.
assertTrue
();
const
ret
=
fetchResult
.
isAfterLast
();
expect
(
ret
)
.
assertTrue
();
}
}
catch
(
error
)
{
console
.
info
(
`${testNum} getLastObject failed; error: ${error}`
);
...
...
@@ -56,8 +58,10 @@ export default function assetGetLastObjectTest () {
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
expect
(
fetchResult
.
getCount
()
>
0
)
.
assertTrue
();
const
asset
=
await
fetchResult
.
getLastObject
();
fetchResult
.
close
();
expect
(
asset
!==
undefined
)
.
assertTrue
();
const
ret
=
fetchResult
.
isAfterLast
();
fetchResult
.
close
();
expect
(
ret
)
.
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed; error: ${error}`
);
...
...
multimedia/photoAccess/photoAccess/entry/src/main/ets/test/PhotoAssetFetchResult/getObjectByPosition.ets
浏览文件 @
95a4e0f3
...
...
@@ -30,13 +30,14 @@ export default function assetGetPositionObjectTest () {
try
{
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
expect
(
fetchResult
.
getCount
()
>
0
)
.
assertTrue
();
const
firAsset
=
await
fetchResult
.
getFirstObject
();
fetchResult
.
getObjectByPosition
(
0
,
(
err
,
asset
)
=>
{
try
{
if
(
err
!==
undefined
)
{
console
.
info
(
`${testNum} getObjectByPosition failed; err: ${err}`
);
expect
(
false
)
.
assertTrue
();
}
else
{
expect
(
asset
!==
undefined
)
.
assertTrue
(
);
expect
(
asset
.
displayName
)
.
assertEqual
(
firAsset
.
displayName
);
}
}
catch
(
error
)
{
console
.
info
(
`${testNum} getObjectByPosition failed; error: ${error}`
);
...
...
@@ -55,9 +56,10 @@ export default function assetGetPositionObjectTest () {
try
{
let
fetchResult
=
await
helper
.
getAssets
(
fetchOps
);
expect
(
fetchResult
.
getCount
()
>
0
)
.
assertTrue
();
const
firAsset
=
await
fetchResult
.
getFirstObject
();
const
asset
=
await
fetchResult
.
getObjectByPosition
(
0
);
fetchResult
.
close
();
expect
(
asset
!==
undefined
)
.
assertTrue
(
);
expect
(
asset
.
displayName
)
.
assertEqual
(
firAsset
.
displayName
);
done
();
}
catch
(
error
)
{
console
.
info
(
`${testNum} failed; error: ${error}`
);
...
...
multimedia/photoAccess/photoAccessSystem/BUILD.gn
浏览文件 @
95a4e0f3
...
...
@@ -17,8 +17,8 @@ ohos_js_hap_suite("photoAccess_system_js_hap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":photoAccess_js_assets",
":photoAccess_resources",
":photoAccess
System
_js_assets",
":photoAccess
System
_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
...
...
@@ -27,17 +27,17 @@ ohos_js_hap_suite("photoAccess_system_js_hap") {
subsystem_name = "multimedia"
}
ohos_app_scope("photoAccess_app_profile") {
ohos_app_scope("photoAccess
System
_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("photoAccess_js_assets") {
ohos_js_assets("photoAccess
System
_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("photoAccess_resources") {
ohos_resources("photoAccess
System
_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":photoAccess_app_profile" ]
deps = [ ":photoAccess
System
_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
multimedia/photoAccess/photoAccessSystem/entry/src/main/ets/test/publicApiTestWithSystemApi.ets
浏览文件 @
95a4e0f3
...
...
@@ -273,11 +273,11 @@ export default function publicApiTestWithSystemApiTest () {
await
createAsset
.
close
(
fd
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
helper
.
off
(
createAsset
.
uri
);
helper
.
unRegisterChange
(
createAsset
.
uri
);
await
sleep
(
100
);
fd
=
await
createAsset
.
getReadOnlyFd
();
await
createAsset
.
close
(
fd
);
...
...
@@ -306,12 +306,12 @@ export default function publicApiTestWithSystemApiTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
100
);
await
asset
.
setFavorite
(
true
);
await
sleep
(
1000
);
...
...
@@ -340,12 +340,12 @@ export default function publicApiTestWithSystemApiTest () {
await
asset
.
setFavorite
(
true
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
100
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
...
...
@@ -373,12 +373,12 @@ export default function publicApiTestWithSystemApiTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} asset changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
await
sleep
(
100
);
await
helper
.
deleteAssets
([
asset
.
uri
]);
await
sleep
(
2000
);
...
...
@@ -414,14 +414,14 @@ export default function publicApiTestWithSystemApiTest () {
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`off_005 changeData: ${JSON.stringify(changeData)}`
);
expect
(
false
)
.
assertTrue
();
done
();
});
await
sleep
(
100
);
helper
.
off
(
trashFileAsset
.
uri
);
helper
.
unRegisterChange
(
trashFileAsset
.
uri
);
await
sleep
(
100
);
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
sleep
(
2000
);
...
...
@@ -457,12 +457,12 @@ export default function publicApiTestWithSystemApiTest () {
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
trashAlbum
.
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
trashAlbum
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`off_006 changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
trashAlbum
.
albumUri
);
helper
.
unRegisterChange
(
trashAlbum
.
albumUri
);
await
sleep
(
100
);
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
sleep
(
1000
);
...
...
@@ -489,12 +489,12 @@ export default function publicApiTestWithSystemApiTest () {
let
albumName
=
'testAlbum'
+
Date
.
now
();
let
album
=
await
helper
.
createAlbum
(
albumName
);
await
sleep
(
500
);
helper
.
on
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`off_009 changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
DEFAULT_ALBUM_URI
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
100
);
await
helper
.
deleteAlbums
([
album
]);
await
sleep
(
1000
);
...
...
@@ -527,12 +527,12 @@ export default function publicApiTestWithSystemApiTest () {
await
helper
.
deleteAssets
([
fileAsset
.
uri
]);
await
sleep
(
500
);
let
listenCount
=
0
;
helper
.
on
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
DEFAULT_ALBUM_URI
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
await
sleep
(
100
);
// 1
let
albumName
=
'testAlbum'
+
Date
.
now
();
...
...
@@ -581,12 +581,12 @@ export default function publicApiTestWithSystemApiTest () {
let
listenCount
=
0
;
let
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'off14.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
helper
.
on
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
});
await
sleep
(
100
);
helper
.
off
(
DEFAULT_PHOTO_URI
);
helper
.
unRegisterChange
(
DEFAULT_PHOTO_URI
);
await
sleep
(
100
);
// 1
let
fd
=
await
asset
.
open
(
'rw'
);
...
...
@@ -639,7 +639,7 @@ export default function publicApiTestWithSystemApiTest () {
await
createAsset
.
close
(
fd
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
createAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
...
...
@@ -649,7 +649,7 @@ export default function publicApiTestWithSystemApiTest () {
fd
=
await
createAsset
.
getReadOnlyFd
();
await
createAsset
.
close
(
fd
);
await
sleep
(
1000
);
helper
.
off
(
createAsset
.
uri
);
helper
.
unRegisterChange
(
createAsset
.
uri
);
expect
(
count
)
.
assertEqual
(
0
);
done
();
}
catch
(
error
)
{
...
...
@@ -674,7 +674,7 @@ export default function publicApiTestWithSystemApiTest () {
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
...
...
@@ -682,7 +682,7 @@ export default function publicApiTestWithSystemApiTest () {
});
await
asset
.
setFavorite
(
true
);
await
sleep
(
1000
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
...
...
@@ -708,7 +708,7 @@ export default function publicApiTestWithSystemApiTest () {
await
asset
.
setFavorite
(
true
);
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
...
...
@@ -716,7 +716,7 @@ export default function publicApiTestWithSystemApiTest () {
});
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
...
...
@@ -749,7 +749,7 @@ export default function publicApiTestWithSystemApiTest () {
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
trashFileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`on_callback_005 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ADD
);
...
...
@@ -757,7 +757,7 @@ export default function publicApiTestWithSystemApiTest () {
});
await
trashAlbum
.
recoverAssets
([
trashFileAsset
]);
await
sleep
(
2000
);
helper
.
off
(
trashFileAsset
.
uri
);
helper
.
unRegisterChange
(
trashFileAsset
.
uri
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
...
...
@@ -790,15 +790,15 @@ export default function publicApiTestWithSystemApiTest () {
const
trashFileAsset
=
await
trashFetchResult
.
getFirstObject
();
let
count
=
0
;
await
sleep
(
500
);
helper
.
on
(
trashAlbum
.
albumUri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
trashAlbum
.
albumUri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`on_callback_006 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_ALBUM_REMOVE_ASSET
);
//
expect(changeData.extraUris[0]).assertEqual(trashFileAsset.uri);
expect
(
changeData
.
extraUris
[
0
])
.
assertEqual
(
trashFileAsset
.
uri
);
});
await
trashAlbum
.
deleteAssets
([
trashFileAsset
]);
await
sleep
(
1000
);
helper
.
off
(
trashAlbum
.
albumUri
);
helper
.
unRegisterChange
(
trashAlbum
.
albumUri
);
expect
(
count
)
.
assertEqual
(
1
);
done
();
}
catch
(
error
)
{
...
...
@@ -824,7 +824,7 @@ export default function publicApiTestWithSystemApiTest () {
let
album
=
await
helper
.
createAlbum
(
albumName
);
albumUri
=
album
.
albumUri
;
await
sleep
(
500
);
helper
.
on
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_ALBUM_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
if
(
listenCount
<
2
)
{
console
.
info
(
`on_callback_009 changeData: ${JSON.stringify(changeData)}`
);
...
...
@@ -836,7 +836,7 @@ export default function publicApiTestWithSystemApiTest () {
await
helper
.
deleteAlbums
([
album
]);
await
sleep
(
1000
);
expect
(
listenCount
)
.
assertEqual
(
1
);
helper
.
off
(
DEFAULT_ALBUM_URI
);
helper
.
unRegisterChange
(
DEFAULT_ALBUM_URI
);
done
();
}
catch
(
error
)
{
console
.
log
(
`on_callback_009: tryError: $${error}`
);
...
...
@@ -860,7 +860,7 @@ export default function publicApiTestWithSystemApiTest () {
const
fetchOps
=
photoFetchOption
(
testNum
,
photoKeys
.
DISPLAY_NAME
,
'on14.jpg'
);
const
asset
=
await
getFileAsset
(
testNum
,
fetchOps
);
let
photoAssetUri
=
asset
.
uri
;
helper
.
on
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
DEFAULT_PHOTO_URI
,
true
,
async
(
changeData
)
=>
{
listenCount
++
;
switch
(
listenCount
)
{
case
1
:
...
...
@@ -894,7 +894,7 @@ export default function publicApiTestWithSystemApiTest () {
await
sleep
(
500
);
await
asset
.
setFavorite
(
false
);
await
sleep
(
1000
);
helper
.
off
(
DEFAULT_PHOTO_URI
);
helper
.
unRegisterChange
(
DEFAULT_PHOTO_URI
);
expect
(
listenCount
)
.
assertEqual
(
3
);
done
();
}
catch
(
error
)
{
...
...
@@ -921,7 +921,7 @@ export default function publicApiTestWithSystemApiTest () {
await
asset
.
close
(
fd
);
let
listenCount
=
0
;
await
sleep
(
500
);
helper
.
on
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
asset
.
uri
,
false
,
async
(
changeData
)
=>
{
listenCount
++
;
console
.
info
(
`${testNum} changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
...
...
@@ -936,7 +936,7 @@ export default function publicApiTestWithSystemApiTest () {
await
sleep
(
500
);
}
await
sleep
(
2000
);
helper
.
off
(
asset
.
uri
);
helper
.
unRegisterChange
(
asset
.
uri
);
expect
(
listenCount
)
.
assertEqual
(
10
);
done
();
}
catch
(
error
)
{
...
...
@@ -965,7 +965,7 @@ export default function publicApiTestWithSystemApiTest () {
await
fileAsset
.
close
(
fd
);
let
count
=
0
;
await
sleep
(
1000
);
helper
.
on
(
fileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
helper
.
registerChange
(
fileAsset
.
uri
,
false
,
async
(
changeData
)
=>
{
count
++
;
console
.
info
(
`on_callback_017 changeData: ${JSON.stringify(changeData)}`
);
expect
(
changeData
.
type
)
.
assertEqual
(
NOTIFY_UPDATE
);
...
...
@@ -979,7 +979,7 @@ export default function publicApiTestWithSystemApiTest () {
await
fileAsset
.
close
(
fd
);
await
sleep
(
1000
);
expect
(
count
)
.
assertEqual
(
1
);
helper
.
off
(
fileAsset
.
uri
);
helper
.
unRegisterChange
(
fileAsset
.
uri
);
done
();
}
catch
(
error
)
{
console
.
log
(
`on_callback_017: tryError: $${error}`
);
...
...
multimedia/photoAccess/photoAccessSystem/entry/src/main/resources/base/element/string.json
浏览文件 @
95a4e0f3
...
...
@@ -14,15 +14,15 @@
},
{
"name"
:
"form_description"
,
"value"
:
"photoAccess"
"value"
:
"photoAccess
System
"
},
{
"name"
:
"serviceability_description"
,
"value"
:
"photoAccess"
"value"
:
"photoAccess
System
"
},
{
"name"
:
"description_application"
,
"value"
:
"photoAccess test"
"value"
:
"photoAccess
System
test"
},
{
"name"
:
"app_name"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录