Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
db552f95
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看板
未验证
提交
db552f95
编写于
3月 04, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 04, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2165 add more xts
Merge pull request !2165 from 潘强标/master
上级
2a81936f
f88666e9
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
3539 addition
and
1511 deletion
+3539
-1511
multimedia/medialibrary/mediaLibrary_js_standard/Test.json
multimedia/medialibrary/mediaLibrary_js_standard/Test.json
+2
-2
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js
...ry/mediaLibrary_js_standard/src/main/js/test/List.test.js
+7
-1
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumGetFileAssetsPromise.test.js
...andard/src/main/js/test/albumGetFileAssetsPromise.test.js
+399
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js
...ary_js_standard/src/main/js/test/albumTestPromise.test.js
+781
-548
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAsset2.test.js
...iaLibrary_js_standard/src/main/js/test/fileAsset2.test.js
+398
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js
...js_standard/src/main/js/test/fileAssetTestPromise.test.js
+893
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js
...rary_js_standard/src/main/js/test/fileTestPromise.test.js
+225
-960
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js
...standard/src/main/js/test/mediaLibraryTestPromise.test.js
+834
-0
未找到文件。
multimedia/medialibrary/mediaLibrary_js_standard/Test.json
浏览文件 @
db552f95
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
"description"
:
"Configuration for mediaLibrary Tests"
,
"description"
:
"Configuration for mediaLibrary Tests"
,
"driver"
:
{
"driver"
:
{
"type"
:
"JSUnitTest"
,
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"
12
0000"
,
"test-timeout"
:
"
60
0000"
,
"package"
:
"ohos.acts.multimedia.mediaLibrary"
,
"package"
:
"ohos.acts.multimedia.mediaLibrary"
,
"shell-timeout"
:
"
12
0000"
"shell-timeout"
:
"
60
0000"
},
},
"kits"
:
[
"kits"
:
[
{
{
...
...
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js
浏览文件 @
db552f95
...
@@ -13,5 +13,11 @@
...
@@ -13,5 +13,11 @@
* limitations under the License.
* limitations under the License.
*/
*/
require
(
'
./favoriteTestCallBack.test.js
'
)
require
(
'
./favoriteTestCallBack.test.js
'
)
require
(
'
./favoriteTestPromise.test.js
'
)
require
(
'
./fileTestPromise.test.js
'
)
require
(
'
./fileTestPromise.test.js
'
)
require
(
'
./favoriteTestPromise.test.js
'
)
require
(
'
./fileAsset2.test.js
'
)
require
(
'
./fileAssetTestPromise.test.js
'
)
require
(
'
./mediaLibraryTestPromise.test.js
'
)
require
(
'
./albumGetFileAssetsPromise.test.js
'
)
require
(
'
./albumTestPromise.test.js
'
)
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumGetFileAssetsPromise.test.js
0 → 100644
浏览文件 @
db552f95
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
mediaLibrary
from
'
@ohos.multimedia.medialibrary
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
describe
(
'
fileAssetTestPromise.test.js
'
,
async
function
()
{
var
context
=
featureAbility
.
getContext
();
console
.
info
(
'
MediaLibraryTest : getMediaLibrary IN
'
);
var
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
console
.
info
(
'
MediaLibraryTest : getMediaLibrary OUT
'
);
beforeAll
(
function
()
{});
beforeEach
(
function
()
{});
afterEach
(
function
()
{});
afterAll
(
function
()
{});
const
fileKeyObj
=
mediaLibrary
.
FileKey
;
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
videoType
=
mediaLibrary
.
MediaType
.
VIDEO
;
let
audioType
=
mediaLibrary
.
MediaType
.
AUDIO
;
const
count
=
3
;
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01
* @tc.name : getFileAssets
* @tc.desc : more file type all
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_01
'
,
0
,
async
function
(
done
)
{
try
{
let
allTypefetchOp
=
{
selections
:
''
,
selectionArgs
:
[],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
allTypefetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
allTypefetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02
* @tc.name : getFileAssets
* @tc.desc : more file type image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_02
'
,
0
,
async
function
(
done
)
{
try
{
let
imageAlbumfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
imageType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
imageAlbumfetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
imageAlbumfetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03
* @tc.name : getFileAssets
* @tc.desc : more file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_03
'
,
0
,
async
function
(
done
)
{
try
{
let
audioAlbumfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
audioType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
audioAlbumfetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
audioAlbumfetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04
* @tc.name : getFileAssets
* @tc.desc : more file type video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_04
'
,
0
,
async
function
(
done
)
{
try
{
let
videoAlbumfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
videoType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
videoAlbumfetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
videoAlbumfetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05
* @tc.name : getFileAssets
* @tc.desc : more file type image and video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_05
'
,
0
,
async
function
(
done
)
{
try
{
let
imageAndVideoAlbumfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ? or
'
+
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
imageType
.
toString
(),
videoType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
imageAndVideoAlbumfetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
imageAndVideoAlbumfetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06
* @tc.name : getFileAssets
* @tc.desc : more file type image and audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_06
'
,
0
,
async
function
(
done
)
{
try
{
let
imageAndAudioAlbumfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ? or
'
+
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
imageType
.
toString
(),
audioType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
imageAndAudioAlbumfetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
imageAndAudioAlbumfetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/** order: 'date_added DESC LIMIT 0,500'
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07
* @tc.name : getFileAssets
* @tc.desc : more file type video and audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_07
'
,
0
,
async
function
(
done
)
{
try
{
let
videoAndAudioAlbumfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ? or
'
+
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
videoType
.
toString
(),
audioType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
videoAndAudioAlbumfetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
videoAndAudioAlbumfetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_08
* @tc.name : getFileAssets
* @tc.desc : more file type image video and audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_08
'
,
0
,
async
function
(
done
)
{
try
{
let
imgAndVideoAndAudioAlbumfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ? or
'
+
fileKeyObj
.
MEDIA_TYPE
+
'
= ? or
'
+
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
imageType
.
toString
(),
videoType
.
toString
(),
audioType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,3
'
,
};
const
albumList
=
await
media
.
getAlbums
(
imgAndVideoAndAudioAlbumfetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
imgAndVideoAndAudioAlbumfetchOp
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_09
* @tc.name : getFileAssets
* @tc.desc : one file tpe image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_09
'
,
0
,
async
function
(
done
)
{
try
{
let
albumfetchOpOne
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
imageType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,1
'
,
};
const
albumList
=
await
media
.
getAlbums
(
albumfetchOpOne
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
albumfetchOpOne
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_10
* @tc.name : getFileAssets
* @tc.desc : one file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_10
'
,
0
,
async
function
(
done
)
{
try
{
let
albumfetchOpOne
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
audioType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,1
'
,
};
const
albumList
=
await
media
.
getAlbums
(
albumfetchOpOne
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
albumfetchOpOne
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_11
* @tc.name : getFileAssets
* @tc.desc : one file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_11
'
,
0
,
async
function
(
done
)
{
try
{
let
albumfetchOpOne
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
videoType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,1
'
,
};
const
albumList
=
await
media
.
getAlbums
(
albumfetchOpOne
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
albumfetchOpOne
);
expect
(
fetchFileResult
.
getCount
()
<=
count
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12
* @tc.name : getFileAssets
* @tc.desc : no file type image
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_12
'
,
0
,
async
function
(
done
)
{
try
{
let
albumfetchOpNone
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ? AND date_added < 0
'
,
selectionArgs
:
[
imageType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,1
'
,
};
const
albumList
=
await
media
.
getAlbums
(
albumfetchOpNone
);
expect
(
albumList
.
length
==
0
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13
* @tc.name : getFileAssets
* @tc.desc : no file type audio
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_13
'
,
0
,
async
function
(
done
)
{
try
{
let
albumfetchOpNone
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ? AND date_added < 0
'
,
selectionArgs
:
[
audioType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,1
'
,
};
const
albumList
=
await
media
.
getAlbums
(
albumfetchOpNone
);
expect
(
albumList
.
length
==
0
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14
* @tc.name : getFileAssets
* @tc.desc : no file type video
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ALBUM_GET_ASSETS_PROMISE_001_14
'
,
0
,
async
function
(
done
)
{
try
{
let
albumfetchOpNone
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ? AND date_added < 0
'
,
selectionArgs
:
[
videoType
.
toString
()],
order
:
'
date_added DESC LIMIT 0,1
'
,
};
const
albumList
=
await
media
.
getAlbums
(
albumfetchOpNone
);
expect
(
albumList
.
length
==
0
).
assertTrue
();
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js
浏览文件 @
db552f95
此差异已折叠。
点击以展开。
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAsset2.test.js
0 → 100644
浏览文件 @
db552f95
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
mediaLibrary
from
'
@ohos.multimedia.medialibrary
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
function
printAttr
(
asset
)
{
for
(
const
key
in
asset
)
{
console
.
info
(
`
${
key
}
: asset[key]`
);
}
}
function
checkAttrs
(
done
,
asset
,
tNum
)
{
let
passed
=
true
;
for
(
const
key
in
asset
)
{
if
(
asset
[
key
]
==
undefined
)
{
passed
=
false
;
break
;
}
}
if
(
passed
)
{
console
.
info
(
`FileAsset checkAttrs
${
tNum
}
passed`
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
info
(
`FileAsset checkAttrs
${
tNum
}
failed`
);
expect
(
false
).
assertTrue
();
done
();
}
}
describe
(
'
fileAsset2.test.js
'
,
async
function
()
{
let
fileKeyObj
=
mediaLibrary
.
FileKey
;
let
imageType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
videoType
=
mediaLibrary
.
MediaType
.
VIDEO
;
let
audioType
=
mediaLibrary
.
MediaType
.
AUDIO
;
let
imagesfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
imageType
.
toString
()],
};
let
videosfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
videoType
.
toString
()],
};
let
audiosfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
'
= ?
'
,
selectionArgs
:
[
audioType
.
toString
()],
};
let
allTypefetchOp
=
{
selections
:
''
,
selectionArgs
:
[],
};
const
context
=
featureAbility
.
getContext
();
const
media
=
mediaLibrary
.
getMediaLibrary
(
context
);
beforeAll
(
function
()
{});
beforeEach
(
function
()
{});
afterEach
(
function
()
{});
afterAll
(
function
()
{});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_001
* @tc.name : commitModify
* @tc.desc : Modify displayName
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_commitModify_promise_001
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
const
newName
=
'
newName
'
;
asset
.
displayName
=
newName
;
const
id
=
asset
.
id
;
await
asset
.
commitModify
();
const
fetchFileResult2
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
dataList
=
await
fetchFileResult2
.
getAllObject
();
let
passed
=
false
;
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
const
asset
=
dataList
[
i
];
if
(
asset
.
id
==
id
&&
asset
.
displayName
==
newName
)
{
passed
=
true
;
break
;
}
}
expect
(
passed
).
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'
FileAsset commitModify 001 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_002
* @tc.name : commitModify
* @tc.desc : Modify title
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_commitModify_promise_002
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
const
newTitle
=
'
newTitle
'
;
asset
.
title
=
newTitle
;
const
id
=
asset
.
id
;
await
asset
.
commitModify
();
const
fetchFileResult2
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
dataList
=
await
fetchFileResult2
.
getAllObject
();
let
passed
=
false
;
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
const
asset
=
dataList
[
i
];
if
(
asset
.
id
==
id
&&
asset
.
title
==
newTitle
)
{
passed
=
true
;
break
;
}
}
expect
(
passed
).
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'
FileAsset commitModify 002 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_003
* @tc.name : commitModify
* @tc.desc : Modify relativePath
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_commitModify_promise_003
'
,
0
,
async
function
(
done
)
{
try
{
const
path1
=
await
media
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
);
const
path2
=
await
media
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_VIDEO
);
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
let
relativePath
=
asset
.
relativePath
;
let
newrelativePath
=
path1
;
if
(
relativePath
==
path1
)
{
newrelativePath
=
path2
;
}
asset
.
relativePath
=
newrelativePath
;
const
id
=
asset
.
id
;
await
asset
.
commitModify
();
const
fetchFileResult2
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
dataList
=
await
fetchFileResult2
.
getAllObject
();
let
passed
=
false
;
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
const
asset
=
dataList
[
i
];
if
(
asset
.
id
==
id
&&
asset
.
relativePath
==
newrelativePath
)
{
passed
=
true
;
break
;
}
}
expect
(
passed
).
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'
FileAsset commitModify 003 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_004
* @tc.name : commitModify
* @tc.desc : Modify orientation
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_commitModify_promise_004
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
let
neworientation
=
1
;
if
(
asset
.
orientation
==
1
)
{
neworientation
=
0
;
}
asset
.
orientation
=
neworientation
;
const
id
=
asset
.
id
;
await
asset
.
commitModify
();
const
fetchFileResult2
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
dataList
=
await
fetchFileResult2
.
getAllObject
();
let
passed
=
false
;
for
(
let
i
=
0
;
i
<
dataList
.
length
;
i
++
)
{
const
asset
=
dataList
[
i
];
if
(
asset
.
id
==
id
&&
asset
.
orientation
==
neworientation
)
{
passed
=
true
;
break
;
}
}
expect
(
passed
).
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'
FileAsset commitModify 004 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_005
* @tc.name : commitModify
* @tc.desc : Modify uri
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_commitModify_promise_005
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
const
id
=
asset
.
id
;
const
newUri
=
'
newUri
'
;
asset
.
uri
=
newUri
;
await
asset
.
commitModify
();
console
.
info
(
'
FileAsset commitModify 005 failed
'
);
expect
(
false
).
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'
FileAsset commitModify 005 passed
'
);
expect
(
true
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_commitModify_promise_006
* @tc.name : commitModify
* @tc.desc : Modify mediaType
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_commitModify_promise_006
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
const
id
=
asset
.
id
;
const
newMediaType
=
'
newMediaType
'
;
asset
.
mediaType
=
newMediaType
;
await
asset
.
commitModify
();
console
.
info
(
'
FileAsset commitModify 006 failed
'
);
expect
(
false
).
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'
FileAsset commitModify 006 passed
'
);
expect
(
true
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_isDirectory_promise_001
* @tc.name : isDirectory
* @tc.desc : isDirectory asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_isDirectory_promise_001
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
const
isDir
=
await
asset
.
isDirectory
();
expect
(
!
isDir
).
assertTrue
();
done
();
}
catch
(
error
)
{
console
.
info
(
'
FileAsset isDirectory 001 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_001
* @tc.name : attrs
* @tc.desc : imagesfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_checkAttr_promise_001
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
imagesfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
printAttr
(
asset
);
checkAttrs
(
done
,
asset
,
'
001
'
);
}
catch
(
error
)
{
console
.
info
(
'
FileAsset checkAttr 001 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_002
* @tc.name : attrs
* @tc.desc : videosfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_checkAttr_promise_002
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
videosfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
printAttr
(
asset
);
checkAttrs
(
done
,
asset
,
'
002
'
);
}
catch
(
error
)
{
console
.
info
(
'
FileAsset checkAttr 002 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_003
* @tc.name : attrs
* @tc.desc : audiosfetchOp attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_checkAttr_promise_003
'
,
0
,
async
function
(
done
)
{
try
{
const
fetchFileResult
=
await
media
.
getFileAssets
(
audiosfetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
printAttr
(
asset
);
checkAttrs
(
done
,
asset
,
'
003
'
);
}
catch
(
error
)
{
console
.
info
(
'
FileAsset checkAttr 003 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
/**
* @tc.number : SUB_MEDIA_FILEASSET_checkAttr_promise_004
* @tc.name : attrs
* @tc.desc : album attrs print and check
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_FILEASSET_checkAttr_promise_004
'
,
0
,
async
function
(
done
)
{
try
{
const
albumList
=
await
media
.
getAlbums
(
allTypefetchOp
);
const
album
=
albumList
[
0
];
const
fetchFileResult
=
await
album
.
getFileAssets
(
allTypefetchOp
);
const
asset
=
await
fetchFileResult
.
getFirstObject
();
printAttr
(
asset
);
checkAttrs
(
done
,
asset
,
'
004
'
);
}
catch
(
error
)
{
console
.
info
(
'
FileAsset checkAttr 003 failed, message =
'
+
error
);
expect
(
false
).
assertTrue
();
done
();
}
});
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js
0 → 100644
浏览文件 @
db552f95
此差异已折叠。
点击以展开。
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js
浏览文件 @
db552f95
此差异已折叠。
点击以展开。
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js
0 → 100644
浏览文件 @
db552f95
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录