Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
4ff1b7fb
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看板
提交
4ff1b7fb
编写于
10月 11, 2022
作者:
Y
yangbo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix errcode case
Signed-off-by:
N
yangbo
<
yangbo258@h-partners.com
>
上级
5c49f339
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
304 addition
and
35 deletion
+304
-35
multimedia/BUILD.gn
multimedia/BUILD.gn
+4
-0
multimedia/userfilemgr/common.js
multimedia/userfilemgr/common.js
+13
-13
multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets
...try/src/main/ets/test/albumGetFileAssetsCallback.test.ets
+41
-1
multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets
...ntry/src/main/ets/test/albumGetFileAssetsPromise.test.ets
+34
-1
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsCallback.test.ets
...r_base/entry/src/main/ets/test/getAlbumsCallback.test.ets
+35
-0
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsPromise.test.ets
...gr_base/entry/src/main/ets/test/getAlbumsPromise.test.ets
+28
-0
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsCallback.test.ets
...se/entry/src/main/ets/test/getFileAssetsCallback.test.ets
+67
-2
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsPromise.test.ets
...ase/entry/src/main/ets/test/getFileAssetsPromise.test.ets
+54
-13
multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFileKey.test.ets
...leAsset/entry/src/main/ets/test/fileAssetFileKey.test.ets
+28
-2
multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenPromise.test.ets
...set/entry/src/main/ets/test/fileAssetOpenPromise.test.ets
+0
-3
未找到文件。
multimedia/BUILD.gn
浏览文件 @
4ff1b7fb
...
...
@@ -55,6 +55,10 @@ group("multimedia") {
"medialibrary/mediaLibrary_getThumbnail:mediaLibrary_getThumbnail_hap",
"medialibrary/mediaLibrary_mediafetchoptions:mediaLibrary_mediafetchoptions_hap",
"medialibrary/mediaLibrary_trash:mediaLibrary_trash_js_hap",
"userfilemgr/userfilemgr_album:userfilemgr_album_js_hap",
"userfilemgr/userfilemgr_base:userfilemgr_base_js_hap",
"userfilemgr/userfilemgr_fileAsset:userfilemgr_fileAsset_js_hap",
"userfilemgr/userfilemgr_noPermission:userfilemgr_noPermission_js_hap",
]
} else {
deps = [
...
...
multimedia/userfilemgr/common.js
浏览文件 @
4ff1b7fb
...
...
@@ -17,7 +17,6 @@ import userFileManager from '@ohos.filemanagement.userFileManager';
import
abilityAccessCtrl
from
'
@ohos.abilityAccessCtrl
'
;
import
bundle
from
'
@ohos.bundle
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
;
const
presetsCount
=
{
ActsUserFileMgrAlbumJsTest
:
{
albumsCount
:
3
,
assetsCount
:
3
},
...
...
@@ -32,7 +31,7 @@ const AUDIO_TYPE = userFileManager.FileType.AUDIO;
const
AUDIOKEY
=
userFileManager
.
AudioKey
;
const
IMAGEVIDEOKEY
=
userFileManager
.
ImageVideoKey
;
const
ALBUMKEY
=
userFileManager
.
AlbumKey
;
const
FILEKEY
=
mediaLibrary
.
FileKey
;
const
THROW_ERROR_CODE
=
13900020
;
const
sleep
=
async
function
sleep
(
times
)
{
if
(
times
==
undefined
)
{
times
=
10
...
...
@@ -50,58 +49,58 @@ const allFetchOp = function () {
const
audioFetchOps
=
function
(
testNum
,
path
)
{
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
FILEKEY
.
RELATIVE_PATH
,
path
);
predicates
.
equalTo
(
"
relative_path
"
,
path
);
let
ops
=
{
fetchColumns
:
[],
predicates
:
predicates
};
console
.
info
(
`
${
testNum
}
queryOps:
${
FILEKEY
.
RELATIVE_PATH
}
=
${
path
}
`
);
console
.
info
(
`
${
testNum
}
queryOps:
relative_path
=
${
path
}
`
);
return
ops
}
const
imageVideoFetchOps
=
function
(
testNum
,
path
)
{
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
FILEKEY
.
RELATIVE_PATH
,
path
);
predicates
.
equalTo
(
"
relative_path
"
,
path
);
let
ops
=
{
fetchColumns
:
[],
predicates
:
predicates
};
console
.
info
(
`
${
testNum
}
queryOps:
${
FILEKEY
.
RELATIVE_PATH
}
=
${
path
}
`
);
console
.
info
(
`
${
testNum
}
queryOps:
relative_path
=
${
path
}
`
);
return
ops
}
const
audioNameFetchOps
=
function
(
testNum
,
path
,
displayName
)
{
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
FILEKEY
.
RELATIVE_PATH
,
path
)
predicates
.
equalTo
(
"
relative_path
"
,
path
)
.
equalTo
(
AUDIOKEY
.
DISPLAY_NAME
,
displayName
);
let
ops
=
{
fetchColumns
:
[],
predicates
:
predicates
};
console
.
info
(
`
${
testNum
}
queryOps:
${
FILEKEY
.
RELATIVE_PATH
}
=
${
path
}
AND display_name =
${
displayName
}
`
);
console
.
info
(
`
${
testNum
}
queryOps:
relative_path
=
${
path
}
AND display_name =
${
displayName
}
`
);
return
ops
}
const
imageVideoNameFetchOps
=
function
(
testNum
,
path
,
displayName
)
{
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
FILEKEY
.
RELATIVE_PATH
,
path
)
predicates
.
equalTo
(
"
relative_path
"
,
path
)
.
equalTo
(
IMAGEVIDEOKEY
.
DISPLAY_NAME
,
displayName
);
let
ops
=
{
fetchColumns
:
[],
predicates
:
predicates
};
console
.
info
(
`
${
testNum
}
queryOps:
${
FILEKEY
.
RELATIVE_PATH
}
=
${
path
}
AND display_name =
${
displayName
}
`
);
console
.
info
(
`
${
testNum
}
queryOps:
relative_path
=
${
path
}
AND display_name =
${
displayName
}
`
);
return
ops
}
const
albumFetchOps
=
function
(
testNum
,
path
,
albumName
)
{
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
predicates
.
equalTo
(
FILEKEY
.
RELATIVE_PATH
,
path
)
.
equalTo
(
"
bucket_display_name
"
,
albumName
);
predicates
.
equalTo
(
"
relative_path
"
,
path
)
.
equalTo
(
ALBUMKEY
.
ALBUM_NAME
,
albumName
);
let
ops
=
{
predicates
:
predicates
};
console
.
info
(
`
${
testNum
}
queryOps:
${
FILEKEY
.
RELATIVE_PATH
}
=
${
path
}
AND bucket_display_name =
${
albumName
}
`
);
console
.
info
(
`
${
testNum
}
queryOps:
relative_path
=
${
path
}
AND bucket_display_name =
${
albumName
}
`
);
return
ops
}
...
...
@@ -170,6 +169,7 @@ export {
IMAGE_TYPE
,
VIDEO_TYPE
,
AUDIO_TYPE
,
THROW_ERROR_CODE
,
sleep
,
allFetchOp
,
audioFetchOps
,
...
...
multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsCallback.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -14,10 +14,10 @@
*/
import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import {
sleep,
THROW_ERROR_CODE,
allFetchOp,
albumFetchOps,
checkPresetsAssets,
...
...
@@ -69,6 +69,32 @@ export default function albumGetFileAssetsCallback(abilityContext) {
}
}
const getPhotoAssetsErrCodeTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) {
try {
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp);
const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
fetchAlbumResult.close();
let invalidOps : userFileManager.FetchOptions;
album.getPhotoAssets(invalidOps, (error, fetchAssetResult) => {
if (error != undefined) {
console.info(`${testNum} getPhotoAssetsErrCodeTest error: ${error}`);
expect(false).assertTrue();
done();
return;
}
expect(false).assertTrue();
fetchAssetResult.close();
done();
});
} catch (error) {
console.info(`${testNum}, errCode :${JSON.stringify(error)}`);
expect(error.code).assertEqual(THROW_ERROR_CODE.toString());
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_CALLBACK_01
* @tc.name : getPhotoAssets
...
...
@@ -82,5 +108,19 @@ export default function albumGetFileAssetsCallback(abilityContext) {
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
});
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_CALLBACK_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp);
});
});
}
\ No newline at end of file
multimedia/userfilemgr/userfilemgr_album/entry/src/main/ets/test/albumGetFileAssetsPromise.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -16,10 +16,10 @@
import userFileManager from '@ohos.filemanagement.userFileManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
import {
sleep,
THROW_ERROR_CODE,
allFetchOp,
albumFetchOps,
checkPresetsAssets,
...
...
@@ -70,6 +70,25 @@ export default function albumGetFileAssetsPromise(abilityContext) {
}
}
const getPhotoAssetsErrCodeTest = async function (done, testNum, fetchOp, expectAlbumCount = 1, expectAssetsCount = 1) {
try {
const fetchAlbumResult = await userfilemgr.getPhotoAlbums(fetchOp);
const albumCountPass = await checkAssetsCount(done, testNum, fetchAlbumResult, expectAlbumCount);
if (!albumCountPass) return;
const album = await fetchAlbumResult.getFirstObject();
fetchAlbumResult.close();
let invalidOps : userFileManager.FetchOptions;
let fetchAssetResult = await album.getPhotoAssets(invalidOps);
expect(false).assertTrue();
fetchAssetResult.close();
done();
} catch (error) {
console.info(`${testNum}, errCode :${JSON.stringify(error)}`);
expect(error.code).assertEqual(THROW_ERROR_CODE.toString());
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_PROMISE_01
* @tc.name : getPhotoAssets
...
...
@@ -83,5 +102,19 @@ export default function albumGetFileAssetsPromise(abilityContext) {
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsTest(done, testNum, currentFetchOp);
});
/**
* @tc.number : SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid AlbumFetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01', 0, async function (done) {
const testNum = 'SUB_USERFILE_MGR_ALBUM_GETPHOTOASSETS_ERRCODE_PROMISE_01';
let currentFetchOp = albumFetchOps(testNum, 'Pictures/', 'Static');
await getPhotoAssetsErrCodeTest(done, testNum, currentFetchOp);
});
});
}
\ No newline at end of file
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsCallback.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -18,6 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import {
sleep,
THROW_ERROR_CODE,
albumFetchOps,
checkPresetsAssets,
checkAssetsCount,
...
...
@@ -107,6 +108,27 @@ export default function getAlbumsCallbackTest(abilityContext) {
}
}
const getPhotoAlbumsErrCodeTest = async function (done, testNum) {
try {
let invalidOps : userFileManager.FetchOptions;
userfilemgr.getPhotoAlbums(invalidOps, async (err, fetchAlbumResult) => {
if(err) {
console.info(`${testNum} getPhotoAlbums err: ${err}`)
expect(false).assertTrue();
done();
return;
}
expect(false).assertTrue();
fetchAlbumResult.close();
done();
});
} catch (error) {
console.info(`${testNum}, errCode :${JSON.stringify(error)}`);
expect(error.code).assertEqual(THROW_ERROR_CODE.toString());
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_CALLBACK_01
* @tc.name : getPhotoAlbums
...
...
@@ -121,6 +143,19 @@ export default function getAlbumsCallbackTest(abilityContext) {
let relativePaths = 'Pictures/';
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums by invalid
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_CALLBACK_01';
await getPhotoAlbumsErrCodeTest(done, testNum);
});
});
}
...
...
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getAlbumsPromise.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -18,6 +18,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import {
sleep,
THROW_ERROR_CODE,
albumFetchOps,
checkPresetsAssets,
checkAssetsCount,
...
...
@@ -94,6 +95,20 @@ export default function getAlbumsPromiseTest(abilityContext) {
}
}
const getPhotoAlbumsErrCodeTest = async function (done, testNum) {
try {
let invalidOps : userFileManager.FetchOptions;
let fetchAlbumResult = await userfilemgr.getPhotoAlbums(invalidOps);
expect(false).assertTrue();
fetchAlbumResult.close();
done();
} catch (error) {
console.info(`${testNum}, errCode :${JSON.stringify(error)}`);
expect(error.code).assertEqual(THROW_ERROR_CODE.toString());
done();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_PROMISE_01
* @tc.name : getPhotoAlbums
...
...
@@ -108,6 +123,19 @@ export default function getAlbumsPromiseTest(abilityContext) {
let relativePaths = 'Pictures/';
await checkAlbumInfo(done, testNum, currentFetchOp, relativePaths);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01
* @tc.name : getPhotoAlbums
* @tc.desc : getPhotoAlbums by invalid
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMS_ERRCODE_PROMISE_01';
await getPhotoAlbumsErrCodeTest(done, testNum);
});
});
}
...
...
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsCallback.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -20,6 +20,7 @@ import {
IMAGE_TYPE
,
VIDEO_TYPE
,
AUDIO_TYPE
,
THROW_ERROR_CODE
,
audioFetchOps
,
imageVideoFetchOps
,
checkPresetsAssets
,
...
...
@@ -190,7 +191,7 @@ export default function getFileAssetsCallbackTest(abilityContext) {
let
expectCount
=
4
;
let
checkAssetCountPass
=
await
checkAssetsCount
(
done
,
testNum
,
fetchAssetResult
,
expectCount
);
if
(
!
checkAssetCountPass
)
return
;
fetchAssetResult
.
getFirstObject
(
async
(
err
,
asset
)
=>
{
fetchAssetResult
.
getFirstObject
((
err
,
asset
)
=>
{
if
(
err
)
{
console
.
info
(
`${testNum} err : ${err}`
)
expect
.
assertFail
();
...
...
@@ -199,6 +200,7 @@ export default function getFileAssetsCallbackTest(abilityContext) {
return
;
}
expect
(
asset
.
displayName
)
.
assertEqual
(
props
[
type
]
.
displayName
);
expect
(
asset
.
fileType
.
toString
())
.
assertEqual
(
props
[
type
]
.
fileType
);
expect
(
asset
.
uri
!=
undefined
)
.
assertTrue
();
fetchAssetResult
.
close
();
done
();
...
...
@@ -210,6 +212,39 @@ export default function getFileAssetsCallbackTest(abilityContext) {
}
}
async
function
getFileAssetsErrCodeTest
(
done
,
testNum
,
isAudio
)
{
try
{
let
invalidOps
:
userFileManager
.
FetchOptions
;
if
(
isAudio
)
{
await
userfilemgr
.
getAudioAssets
(
invalidOps
,
(
err
,
fetchAssetResult
)
=>
{
if
(
err
!=
undefined
)
{
console
.
info
(
`${testNum}:: getAudioAssets error :${err}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
}
expect
(
false
)
.
assertTrue
();
done
();
})
}
else
{
await
userfilemgr
.
getPhotoAssets
(
invalidOps
,
(
err
,
fetchAssetResult
)
=>
{
if
(
err
!=
undefined
)
{
console
.
info
(
`${testNum}:: getAudioAssets error :${err}`
);
expect
(
false
)
.
assertTrue
();
done
();
return
;
}
expect
(
false
)
.
assertTrue
();
done
();
})
}
}
catch
(
error
)
{
console
.
info
(
`${testNum}:: errCode :${JSON.stringify(error)}`
);
expect
(
error
.
code
)
.
assertEqual
(
THROW_ERROR_CODE
.
toString
());
done
();
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_01_001
* @tc.name : getFirstObject
...
...
@@ -352,7 +387,7 @@ export default function getFileAssetsCallbackTest(abilityContext) {
await
getPositionObjectTest
(
done
,
testNum
,
currentFetchOps
,
pos
,
isAudio
);
});
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-----
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_CALLBACK_04_001
...
...
@@ -448,6 +483,36 @@ export default function getFileAssetsCallbackTest(abilityContext) {
let
isAudio
=
false
;
await
checkFileAssetAttr
(
done
,
testNum
,
currentFetchOps
,
type
,
isAudio
);
});
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01'
,
0
,
async
function
(
done
)
{
let
testNum
=
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_01'
;
let
isAudio
=
false
;
await
getFileAssetsErrCodeTest
(
done
,
testNum
,
isAudio
);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_02
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_02'
,
0
,
async
function
(
done
)
{
let
testNum
=
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_CALLBACK_02'
;
let
isAudio
=
true
;
await
getFileAssetsErrCodeTest
(
done
,
testNum
,
isAudio
);
});
});
}
multimedia/userfilemgr/userfilemgr_base/entry/src/main/ets/test/getFileAssetsPromise.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -20,9 +20,9 @@ import {
IMAGE_TYPE
,
VIDEO_TYPE
,
AUDIO_TYPE
,
THROW_ERROR_CODE
,
checkPresetsAssets
,
checkAssetsCount
,
allFetchOp
,
audioFetchOps
,
imageVideoFetchOps
,
}
from
'../../../../../../common'
;
...
...
@@ -166,18 +166,12 @@ export default function getFileAssetsPromiseTest(abilityContext) {
let
expectCount
=
4
;
let
checkAssetCountPass
=
await
checkAssetsCount
(
done
,
testNum
,
fetchAssetResult
,
expectCount
);
if
(
!
checkAssetCountPass
)
return
;
fetchAssetResult
.
getFirstObject
(
async
(
err
,
asset
)
=>
{
if
(
err
)
{
console
.
info
(
`${testNum} err : ${err}`
)
expect
.
assertFail
();
fetchAssetResult
.
close
();
done
();
return
;
}
let
asset
=
await
fetchAssetResult
.
getFirstObject
();
expect
(
asset
.
displayName
)
.
assertEqual
(
props
[
type
]
.
displayName
);
expect
(
asset
.
fileType
.
toString
())
.
assertEqual
(
props
[
type
]
.
fileType
);
expect
(
asset
.
uri
!=
undefined
)
.
assertTrue
();
fetchAssetResult
.
close
();
done
();
});
}
catch
(
error
)
{
console
.
info
(
`${testNum}:: error :${error}`
);
expect
(
false
)
.
assertTrue
();
...
...
@@ -185,6 +179,23 @@ export default function getFileAssetsPromiseTest(abilityContext) {
}
}
async
function
getFileAssetsErrCodeTest
(
done
,
testNum
,
isAudio
)
{
try
{
let
fetchAssetResult
;
let
invalidOps
:
userFileManager
.
FetchOptions
;
if
(
isAudio
)
{
fetchAssetResult
=
await
userfilemgr
.
getAudioAssets
(
invalidOps
);
}
else
{
fetchAssetResult
=
await
userfilemgr
.
getPhotoAssets
(
invalidOps
);
}
expect
(
false
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`${testNum}:: errCode :${JSON.stringify(error)}`
);
expect
(
error
.
code
)
.
assertEqual
(
THROW_ERROR_CODE
.
toString
());
done
();
}
}
//
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_PROMISE_01_001
* @tc.name : getFirstObject
...
...
@@ -423,6 +434,36 @@ export default function getFileAssetsPromiseTest(abilityContext) {
let
isAudio
=
false
;
await
checkFileAssetAttr
(
done
,
testNum
,
currentFetchOps
,
type
,
isAudio
);
});
//------------------------------------------------------------------------------
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01'
,
0
,
async
function
(
done
)
{
let
testNum
=
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_01'
;
let
isAudio
=
false
;
await
getFileAssetsErrCodeTest
(
done
,
testNum
,
isAudio
);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02
* @tc.name : getPhotoAssets
* @tc.desc : invalid FetchOptions
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02'
,
0
,
async
function
(
done
)
{
let
testNum
=
'SUB_USERFILE_MGR_GETPHOTOASSETS_ERRCODE_PROMISE_02'
;
let
isAudio
=
true
;
await
getFileAssetsErrCodeTest
(
done
,
testNum
,
isAudio
);
});
});
}
multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetFileKey.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -74,7 +74,6 @@ export default function fileAssetFileKeyTest(abilityContext) {
}
const fetchCount = newAlbumResult.getCount();
const currentAlbum = await newAlbumResult.getFirstObject();
//expect(currentAlbum.get(type)).assertEqual(album.get(type));
expect(currentAlbum[type]).assertEqual(album[type]);
expect(fetchCount > 0).assertTrue();
console.info(`${testNum} newAlbum : ${currentAlbum[type]} count: ${fetchCount}`)
...
...
@@ -141,7 +140,6 @@ export default function fileAssetFileKeyTest(abilityContext) {
fetchColumns: [],
predicates: predicates
};
userfilemgr.getAudioAssets(ops, async (err, newAssetResult) => {
if (err) {
console.info(`${testNum}, err: ${err}`)
...
...
@@ -162,6 +160,20 @@ export default function fileAssetFileKeyTest(abilityContext) {
}
}
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02
* @tc.name : AlbumKey
* @tc.desc : AlbumKey.ALBUM_NAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_02';
let type = 'albumName';
let fileKey = AlbumKey.ALBUM_NAME;
await getAlbumsByKey(done, testNum, type, fileKey);
})
/**
* @tc.number : SUB_USERFILE_MGR_GETPHOTOALBUMSBYKEY_03
* @tc.name : AlbumKey
...
...
@@ -420,6 +432,20 @@ export default function fileAssetFileKeyTest(abilityContext) {
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07
* @tc.name : AUDIOKEY
* @tc.desc : AUDIOKEY.AUDIOALBUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07', 0, async function (done) {
let testNum = 'SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_07';
let fileKey = AUDIOKEY.AUDIOALBUM;
await getAudioAssetsByKey(done, testNum, fileKey);
});
/**
* @tc.number : SUB_USERFILE_MGR_GETAUDIOASSETSBYKEY_08
* @tc.name : AUDIOKEY
...
...
multimedia/userfilemgr/userfilemgr_fileAsset/entry/src/main/ets/test/fileAssetOpenPromise.test.ets
浏览文件 @
4ff1b7fb
...
...
@@ -18,9 +18,6 @@ import fileio from '@ohos.fileio';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
import {
sleep,
IMAGE_TYPE,
VIDEO_TYPE,
AUDIO_TYPE,
audioFetchOps,
imageVideoFetchOps,
audioNameFetchOps,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录