Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
a9a2966e
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看板
提交
a9a2966e
编写于
1月 27, 2022
作者:
G
gudehe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add MediaLibrary XTS unit test cases
Signed-off-by:
N
gudehe
<
gudehe@huawei.com
>
上级
612f46d0
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
2628 addition
and
19 deletion
+2628
-19
multimedia/BUILD.gn
multimedia/BUILD.gn
+1
-0
multimedia/medialibrary/mediaLibrary_js_standard/BUILD.gn
multimedia/medialibrary/mediaLibrary_js_standard/BUILD.gn
+38
-0
multimedia/medialibrary/mediaLibrary_js_standard/Test.json
multimedia/medialibrary/mediaLibrary_js_standard/Test.json
+35
-0
multimedia/medialibrary/mediaLibrary_js_standard/signature/openharmony_sx.p7b
...ary/mediaLibrary_js_standard/signature/openharmony_sx.p7b
+0
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/config.json
...edialibrary/mediaLibrary_js_standard/src/main/config.json
+74
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/app.js
...brary/mediaLibrary_js_standard/src/main/js/default/app.js
+7
-19
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/i18n/en-US.json
...iaLibrary_js_standard/src/main/js/default/i18n/en-US.json
+6
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/i18n/zh-CN.json
...iaLibrary_js_standard/src/main/js/default/i18n/zh-CN.json
+6
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/pages/index/index.css
...ary_js_standard/src/main/js/default/pages/index/index.css
+46
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/pages/index/index.hml
...ary_js_standard/src/main/js/default/pages/index/index.hml
+5
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/pages/index/index.js
...rary_js_standard/src/main/js/default/pages/index/index.js
+41
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js
...ry/mediaLibrary_js_standard/src/main/js/test/List.test.js
+21
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestCallBack.test.js
...ry_js_standard/src/main/js/test/albumTestCallBack.test.js
+153
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js
...ary_js_standard/src/main/js/test/albumTestPromise.test.js
+155
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssets.test.js
...ary_js_standard/src/main/js/test/createFileAssets.test.js
+269
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssetsPerformance.test.js
...dard/src/main/js/test/createFileAssetsPerformance.test.js
+95
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/deleteFileAssetsPerformance.test.js
...dard/src/main/js/test/deleteFileAssetsPerformance.test.js
+138
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestCallBack.test.js
...rary_js_standard/src/main/js/test/favTestCallBack.test.js
+126
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestPromise.test.js
...brary_js_standard/src/main/js/test/favTestPromise.test.js
+115
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestCallBack.test.js
...ary_js_standard/src/main/js/test/fileTestCallBack.test.js
+313
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js
...rary_js_standard/src/main/js/test/fileTestPromise.test.js
+235
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAlbumsPerformance.test.js
...js_standard/src/main/js/test/getAlbumsPerformance.test.js
+73
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance.test.js
...tandard/src/main/js/test/getFileAssetsPerformance.test.js
+76
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance_object.test.js
.../src/main/js/test/getFileAssetsPerformance_object.test.js
+250
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getMediaFileAssetStatus.test.js
...standard/src/main/js/test/getMediaFileAssetStatus.test.js
+200
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getPrivateAlbumsPerformance.test.js
...dard/src/main/js/test/getPrivateAlbumsPerformance.test.js
+68
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/smartAlbumOperatePerformance_object.test.js
.../main/js/test/smartAlbumOperatePerformance_object.test.js
+70
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/resources/base/element/string.json
...y_js_standard/src/main/resources/base/element/string.json
+12
-0
multimedia/medialibrary/mediaLibrary_js_standard/src/main/resources/base/media/icon.png
...ibrary_js_standard/src/main/resources/base/media/icon.png
+0
-0
未找到文件。
multimedia/BUILD.gn
浏览文件 @
a9a2966e
...
...
@@ -20,6 +20,7 @@ group("multimedia") {
"audio/audio_js_standard/audioManager:audio_manager_js_hap",
"media/media_js_standard/audioPlayer:audio_player_js_hap",
"media/media_js_standard/audioRecorder:audio_recorder_js_hap",
"medialibrary/mediaLibrary_js_standard:mediaLibrary_js_hap",
#"media/media_js_standard/audioDecoder:audio_decoder_js_hap",
#"media/media_js_standard/audioEncoder:audio_encoder_js_hap",
...
...
multimedia/medialibrary/mediaLibrary_js_standard/BUILD.gn
0 → 100644
浏览文件 @
a9a2966e
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("mediaLibrary_js_hap") {
hap_profile = "./src/main/config.json"
deps = [
":mediaLibrary_js_assets",
":mediaLibrary_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "mediaLibraryJsTest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("mediaLibrary_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("mediaLibrary_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
multimedia/medialibrary/mediaLibrary_js_standard/Test.json
0 → 100644
浏览文件 @
a9a2966e
{
"description"
:
"Configuration for mediaLibrary Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"120000"
,
"package"
:
"ohos.acts.multimedia.mediaLibrary"
,
"shell-timeout"
:
"120000"
},
"kits"
:
[
{
"type"
:
"PushKit"
,
"pre-push"
:
[
],
"push"
:
[
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"chmod -R 666 /data/media/*"
,
"setenforce 0"
],
"teardown-command"
:[
"setenforce 1"
]
},
{
"test-file-name"
:
[
"mediaLibraryJsTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}
]
}
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/signature/openharmony_sx.p7b
0 → 100755
浏览文件 @
a9a2966e
文件已添加
multimedia/medialibrary/mediaLibrary_js_standard/src/main/config.json
0 → 100644
浏览文件 @
a9a2966e
{
"app"
:
{
"apiVersion"
:
{
"compatible"
:
6
,
"releaseType"
:
"Beta1"
,
"target"
:
7
},
"vendor"
:
"acts"
,
"bundleName"
:
"ohos.acts.multimedia.mediaLibrary"
,
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
}
},
"deviceConfig"
:
{
"default"
:
{
"debug"
:
true
}
},
"module"
:
{
"abilities"
:
[
{
"iconId"
:
16777218
,
"skills"
:
[
{
"entities"
:
[
"entity.system.home"
],
"actions"
:
[
"action.system.home"
]
}
],
"descriptionId"
:
16777217
,
"visible"
:
true
,
"labelId"
:
16777216
,
"icon"
:
"$media:icon"
,
"name"
:
"ohos.acts.multimedia.mediaLibrary.MainAbility"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:entry_MainAbility"
,
"type"
:
"page"
,
"homeAbility"
:
true
,
"launchType"
:
"standard"
}
],
"deviceType"
:
[
"phone"
,
"tablet"
,
"tv"
,
"wearable"
],
"mainAbility"
:
"ohos.acts.multimedia.mediaLibrary.MainAbility"
,
"distro"
:
{
"moduleType"
:
"entry"
,
"installationFree"
:
false
,
"deliveryWithInstall"
:
true
,
"moduleName"
:
"entry"
},
"package"
:
"ohos.acts.multimedia.mediaLibrary"
,
"name"
:
".MyApplication"
,
"js"
:
[
{
"pages"
:
[
"pages/index/index"
],
"name"
:
"default"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
true
}
}
]
}
}
\ No newline at end of file
multimedia/
audio/audio_js_standard/audioManager/src/main/java/ohos/acts/multimedia/audio/audioplayer/MainAbility.java
→
multimedia/
medialibrary/mediaLibrary_js_standard/src/main/js/default/app.js
浏览文件 @
a9a2966e
...
...
@@ -12,24 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
ohos.acts.multimedia.audio.audioplayer
;
import
ohos.ace.ability.AceAbility
;
import
ohos.aafwk.content.Intent
;
/*
* java MainAbility
*/
public
class
MainAbility
extends
AceAbility
{
@Override
public
void
onStart
(
Intent
intent
)
{
super
.
onStart
(
intent
);
}
@Override
public
void
onStop
()
{
super
.
onStop
();
export
default
{
onCreate
()
{
console
.
info
(
'
AceApplication onCreate
'
);
},
onDestroy
()
{
console
.
info
(
'
AceApplication onDestroy
'
);
}
}
};
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/i18n/en-US.json
0 → 100644
浏览文件 @
a9a2966e
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
}
}
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/i18n/zh-CN.json
0 → 100644
浏览文件 @
a9a2966e
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
}
}
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/pages/index/index.css
0 → 100644
浏览文件 @
a9a2966e
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
width
:
100%
;
height
:
100%
;
}
.title
{
font-size
:
40px
;
color
:
#000000
;
opacity
:
0.9
;
}
@media
screen
and
(
device-type
:
tablet
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
100px
;
}
}
@media
screen
and
(
device-type
:
wearable
)
{
.title
{
font-size
:
28px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
tv
)
{
.container
{
background-image
:
url("/common/images/Wallpaper.png")
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
}
.title
{
font-size
:
100px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
phone
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
60px
;
}
}
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/pages/index/index.hml
0 → 100644
浏览文件 @
a9a2966e
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/default/pages/index/index.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
console
.
info
(
'
onShow finish
'
)
const
core
=
Core
.
getInstance
()
const
expectExtend
=
new
ExpectExtend
({
'
id
'
:
'
extend
'
})
core
.
addService
(
'
expect
'
,
expectExtend
)
core
.
init
()
const
configService
=
core
.
getDefaultService
(
'
config
'
)
configService
.
setConfig
(
this
)
this
.
timeout
=
60000
require
(
'
../../../test/List.test
'
)
core
.
execute
()
},
onReady
()
{
},
}
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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.
*/
require
(
'
./fileTestPromise.test.js
'
)
require
(
'
./favTestPromise.test.js
'
)
require
(
'
./albumTestPromise.test.js
'
)
require
(
'
./fileTestCallBack.test.js
'
)
require
(
'
./favTestCallBack.test.js
'
)
require
(
'
./albumTestCallBack.test.js
'
)
require
(
'
./getMediaFileAssetStatus.test.js
'
)
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestCallBack.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
AlbumNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
let
AlbumHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
PATH
+
"
LIKE ?
"
,
selectionArgs
:
[
"
/data/media%
"
],
}
let
type1
=
mediaLibrary
.
MediaType
.
IMAGE
let
fileHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type1
.
toString
()],
}
let
fileNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
describe
(
'
album.callback.test.js
'
,
function
()
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
path
=
"
Pictures/
"
var
asset
;
var
media
=
mediaLibrary
.
getMediaLibrary
();
var
album
;
beforeAll
(
function
()
{
console
.
info
(
'
Album Callback MediaLibraryTest: beforeAll.
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
Album Callback MediaLibraryTest: beforeEach.
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
Album Callback MediaLibraryTest: afterEach.
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
Album Callback MediaLibraryTest: afterAll.
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001
* @tc.name : Get Album by AlbumNoArgsfetchOp
* @tc.desc : Get Album by AlbumNoArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001
'
,
0
,
async
function
(
done
)
{
asset
=
await
media
.
createAsset
(
mediaType
,
"
image0003Callback.jpg
"
,
path
);
media
.
getAlbums
(
AlbumNoArgsfetchOp
,
getAlbumsCallBack
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002
* @tc.name : Get Album by AlbumHasArgsfetchOp
* @tc.desc : Get Album by AlbumHasArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002
'
,
0
,
async
function
(
done
)
{
media
.
getAlbums
(
AlbumHasArgsfetchOp
,
getAlbumsCallBack
);
done
();
});
function
getAllObjectInfo
(
data
)
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK id is
'
+
data
.
id
);
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK uri is
'
+
data
.
uri
);
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK displayName is
'
+
data
.
displayName
);
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK mediaType is
'
+
data
.
title
);
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK relativePath is
'
+
data
.
relativePath
);
}
else
{
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK getAllObjectInfo no album
'
);
}
}
function
getAlbumsCallBack
(
err
,
albumList
)
{
if
(
albumList
!=
undefined
)
{
album
=
albumList
[
0
];
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK getAlbumsCallBack album.albumName =
'
+
album
.
albumName
);
album
.
albumName
=
"
helloCallBack
"
;
album
.
commitModify
(
commitModifyCallBack
);
album
.
getFileAssets
(
fileNoArgsfetchOp
,
getFileAssetsCallBack
);
album
.
getFileAssets
(
fileHasArgsfetchOp
,
getFileAssetsCallBack
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK getAlbumsCallBack Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK getAlbumsCallBack : FAIL
'
);
done
();
}
}
function
commitModifyCallBack
(
err
,
data
)
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK Modify album.albumName =
'
+
album
.
albumName
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK Modify Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK Modify : FAIL
'
);
done
();
}
}
function
getFileAssetsCallBack
(
err
,
albumFetchFileResult
)
{
if
(
albumFetchFileResult
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ALBUM_CALLBACK getFileAssetsCallBack success
'
);
albumFetchFileResult
.
getAllObject
((
err1
,
data1
)
=>
{
if
(
data1
!=
undefined
)
{
data1
.
forEach
(
getAllObjectInfo
);
console
.
info
(
'
MediaLibraryTest : getFileAssetsCallBack getAllObject :PASS
'
);
done
();
}
console
.
info
(
'
MediaLibraryTest : getFileAssetsCallBack getFileAssets :No data
'
);
done
();
});
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK getFileAssetsCallBack Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK getFileAssetsCallBack : FAIL
'
);
done
();
}
}
})
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
AlbumNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
let
AlbumHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
PATH
+
"
LIKE ?
"
,
selectionArgs
:
[
"
/data/media%
"
],
}
let
type1
=
mediaLibrary
.
MediaType
.
IMAGE
let
fileHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type1
.
toString
()],
}
let
fileNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
describe
(
'
album.promise.test.js
'
,
function
()
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
path
=
"
Pictures/
"
var
asset
;
var
media
=
mediaLibrary
.
getMediaLibrary
();
var
album
;
beforeAll
(
function
()
{
onsole
.
info
(
'
Album Promise MediaLibraryTest: beforeAll.
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
Album Promise MediaLibraryTest: beforeEach.
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
Album Promise MediaLibraryTest: afterEach.
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
Album Promise MediaLibraryTest: afterAll.
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001
* @tc.name : Get Album by AlbumNoArgsfetchOp
* @tc.desc : Get Album by AlbumNoArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_001
'
,
0
,
async
function
(
done
)
{
asset
=
await
media
.
createAsset
(
mediaType
,
"
image0003.jpg
"
,
path
);
let
albumList
=
await
media
.
getAlbums
(
AlbumNoArgsfetchOp
);
album
=
albumList
[
0
];
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE album.albumName =
'
+
album
.
albumName
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_002
* @tc.name : Get Album by AlbumHasArgsfetchOp
* @tc.desc : Get Album by AlbumHasArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_002
'
,
0
,
async
function
(
done
)
{
let
albumHasList
=
await
media
.
getAlbums
(
AlbumHasArgsfetchOp
);
let
albumHas
=
albumHasList
[
0
];
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE albumHas.albumName =
'
+
albumHas
.
albumName
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003
* @tc.name : Modify Album
* @tc.desc : Modify Album
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_PROMISE_003
'
,
0
,
async
function
(
done
)
{
album
.
albumName
=
"
hello
"
;
await
album
.
commitModify
();
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE Modify album.albumName =
'
+
album
.
albumName
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_004
* @tc.name : Get Album Assets by fileNoArgsfetchOp
* @tc.desc : Get Album Assets by fileNoArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_004
'
,
0
,
async
function
(
done
)
{
let
albumFetchFileResult
=
await
album
.
getFileAssets
(
fileNoArgsfetchOp
);
let
albumAssetList
=
await
albumFetchFileResult
.
getAllObject
();
albumAssetList
.
forEach
(
getAllObjectInfo
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_005
* @tc.name : Get Album Assets by fileHasArgsfetchOp
* @tc.desc : Get Album Assets by fileHasArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETALBUM_PROMISE_005
'
,
0
,
async
function
(
done
)
{
let
albumFetchFileResult
=
await
album
.
getFileAssets
(
fileHasArgsfetchOp
);
let
albumAssetList
=
await
albumFetchFileResult
.
getAllObject
();
albumAssetList
.
forEach
(
getAllObjectInfo
);
await
media
.
deleteAsset
(
asset
.
uri
);
done
();
});
function
getAllObjectInfo
(
data
)
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE id is
'
+
data
.
id
);
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE uri is
'
+
data
.
uri
);
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE displayName is
'
+
data
.
displayName
);
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE mediaType is
'
+
data
.
title
);
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE relativePath is
'
+
data
.
relativePath
);
}
else
{
console
.
info
(
'
MediaLibraryTest : ALBUM_PROMISE getAllObjectInfo no album
'
);
}
}
})
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssets.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
Create_File_Assets.test.js
'
,
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
console
.
info
(
'
MediaLibraryTest : createAsset : release begin
'
);
if
(
media
!=
undefined
)
{
media
.
release
();
}
console
.
info
(
'
MediaLibraryTest : createAsset : release end
'
);
})
/*
* @tc.number : 01
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01
* @tc.desc : Create an image file asset in predefined relative path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01
'
,
0
,
async
function
(
done
)
{
if
(
media
==
null
||
media
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : media == null
'
);
}
else
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
displayName
=
"
02image.jpg
"
;
let
rp
=
"
Pictures/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileObj
)
=>
{
if
(
fileObj
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull file uri =
'
+
fileObj
.
uri
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS
'
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
console
.
info
(
'
MediaLibraryTest : createAsset end
'
);
}
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 end
'
);
/*
* @tc.number : 02
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02
* @tc.desc : Create an image file asset in not predefined relative path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02
'
,
0
,
async
function
(
done
)
{
if
(
media
==
null
||
media
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : media == null
'
);
}
else
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
displayName
=
"
02image.jpg
"
;
let
rp
=
"
Pictures/test/001/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileObj
)
=>
{
if
(
fileObj
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull file uri =
'
+
fileObj
.
uri
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 : PASS
'
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
console
.
info
(
'
MediaLibraryTest : createAsset end
'
);
}
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 end
'
);
/*
* @tc.number : 03
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03
* @tc.desc : Repeat to create same image file asset expect return error
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03
'
,
0
,
async
function
(
done
)
{
if
(
media
==
null
||
media
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : media == null
'
);
}
else
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
displayName
=
"
02image.jpg
"
;
let
rp
=
"
Pictures/test/001/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileObj
)
=>
{
if
(
fileObj
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 : PASS
'
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
info
(
'
MediaLibraryTest : createAsset : FAIL
'
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
});
console
.
info
(
'
MediaLibraryTest : createAsset end
'
);
}
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 end
'
);
/*
* @tc.number : 04
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04
* @tc.desc : Create image file asset in invalid relative path expect return error
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04
'
,
0
,
async
function
(
done
)
{
if
(
media
==
null
||
media
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : media == null
'
);
}
else
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
displayName
=
"
04image.jpg
"
;
let
rp
=
"
test/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileObj
)
=>
{
if
(
createAssetErr
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 : PASS
'
);
expect
(
true
).
assertTrue
();
done
();
}
console
.
info
(
'
MediaLibraryTest : createAsset : FAIL
'
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
});
console
.
info
(
'
MediaLibraryTest : createAsset end
'
);
}
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 end
'
);
/*
* @tc.number : 07
* @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07
* @tc.desc : After create an image file asset, open and close it
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07
'
,
0
,
async
function
(
done
)
{
if
(
media
==
null
||
media
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : media == null
'
);
}
else
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
displayName
=
"
03image.jpg
"
;
media
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
,
(
err
,
rp
)
=>
{
if
(
rp
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getPublicDirectory Successfull
'
+
rp
);
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
data
)
=>
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull
'
);
getObjectInfo
(
data
);
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
console
.
info
(
'
MediaLibraryTest : createAsset end
'
);
}
else
{
console
.
info
(
'
MediaLibraryTest : getPublicDirectory : FAIL
'
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 end
'
);
});
function
getObjectInfo
(
fileAsset
){
console
.
info
(
'
MediaLibraryTest : getObjectInfo uri is
'
+
fileAsset
.
uri
);
console
.
info
(
"
==========================fileAsset.open begin=======================>
"
);
fileAsset
.
open
(
'
Rw
'
).
then
((
openError
,
fd
)
=>
{
if
(
openError
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : open : FAIL
'
+
openError
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
console
.
info
(
"
==========================fileAsset.open success=======================>
"
);
console
.
debug
(
"
open success fd =
"
+
JSON
.
stringify
(
fd
));
console
.
info
(
"
==========================fileAsset.close begin=======================>
"
);
fileAsset
.
close
(
fd
).
then
((
closeErr
)
=>
{
if
(
closeErr
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : close : FAIL
'
+
closeErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
console
.
info
(
"
==========================fileAsset.close success=======================>
"
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : PASS
'
);
expect
(
true
).
assertTrue
();
done
();
});
console
.
info
(
"
==========================fileAsset.close end=======================>
"
);
});
console
.
info
(
"
==========================fileAsset.open end=======================>
"
);
}
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssetsPerformance.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
createFileAssetsPerformance.test.js
'
,
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
let
times
=
100
;
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03
* @tc.name : Create an image file asset in predefined path
* @tc.desc : Create an image file asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 begin1
'
);
if
(
media
==
null
||
media
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : media == null
'
);
}
else
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
displayNamePrefix
=
"
image
"
;
let
extendStr
=
"
.jpg
"
let
rp
=
"
Pictures/
"
;
let
displayName
;
let
conteEnd
=
0
;
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
displayName
=
displayNamePrefix
+
i
+
extendStr
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
).
then
((
fileObj
)
=>
{
if
(
fileObj
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull file uri =
'
+
fileObj
.
uri
);
conteEnd
++
;
if
(
conteEnd
==
times
){
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 : PASS
'
);
expect
(
true
).
assertTrue
();
done
();
}
else
if
(
i
==
times
)
{
console
.
info
(
'
MediaLibraryTest : createAsset has error
'
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01:Partial
'
);
expect
(
false
).
assertTrue
();
done
();
}
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
console
.
info
(
'
MediaLibraryTest : createAsset end
'
);
}
}
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 end
'
);
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/deleteFileAssetsPerformance.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
deleteFileAssetsPerformance.test.js
'
,
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
let
fileList_
;
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
type
=
mediaLibrary
.
MediaType
.
IMAGE
let
fetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type
.
toString
()],
order
:
fileKeyObj
.
DATE_ADDED
,
}
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01
* @tc.name : Create an image file asset in predefined path
* @tc.desc : Create an image file asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01
'
,
0
,
async
function
(
done
)
{
media
.
getFileAssets
(
fetchOp
,
(
getFileAssetsErr
,
queryResultSet
)
=>
{
if
(
queryResultSet
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getAllObject Successfull
'
+
queryResultSet
.
getCount
());
if
(
queryResultSet
.
getCount
()
>
0
)
{
queryResultSet
.
getAllObject
((
getAllObjectErr
,
fileList
)
=>
{
if
(
fileList
!=
undefined
)
{
fileList_
=
fileList
;
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 :PASS
'
);
expect
(
true
).
assertTrue
();
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 :FAIL
'
+
getAllObjectErr
.
message
);
expect
(
false
).
assertTrue
();
done
();
}
});
}
else
{
console
.
info
(
'
MediaLibraryTest : getFileAssets :No data
'
);
expect
(
true
).
assertTrue
();
done
();
}
}
else
{
console
.
info
(
'
MediaLibraryTest : getFileAssets Unsuccessfull
'
+
getFileAssetsErr
.
message
);
console
.
info
(
'
MediaLibraryTest : getFileAssets :FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 end
'
);
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_ASSET_01
* @tc.name : Create an image file asset in predefined path
* @tc.desc : Create an image file asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
if
(
fileList_
!=
undefined
)
{
let
counteEnd
=
0
;
for
(
let
i
=
0
;
i
<
fileList_
.
length
;
i
++
)
{
let
fileAsset
=
fileList_
[
i
];
console
.
info
(
'
MediaLibraryTest : uri is
'
+
fileAsset
.
uri
);
media
.
deleteAsset
(
fileAsset
.
uri
,
(
deleteAssetErr
,
deleteRows
)
=>
{
if
(
deleteRows
>=
0
)
{
console
.
info
(
'
MediaLibraryTest : Delete Asset Successfull
'
+
deleteRows
);
counteEnd
++
;
if
(
counteEnd
==
fileList_
.
length
){
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 : PASS
'
);
expect
(
true
).
assertTrue
();
done
();
}
else
if
(
i
==
fileList_
.
length
-
1
)
{
console
.
info
(
'
MediaLibraryTest : delete has error
'
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :Partial
'
);
expect
(
false
).
assertTrue
();
done
();
}
}
else
{
console
.
info
(
'
MediaLibraryTest : delete error
'
+
deleteAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
}
}
else
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :FAIL
'
+
getAllObjectErr
.
message
);
expect
(
false
).
assertTrue
();
done
();
}
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 end
'
);
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestCallBack.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
AlbumNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
let
AlbumHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
PATH
+
"
LIKE ?
"
,
selectionArgs
:
[
"
/data/media%
"
],
}
let
type1
=
mediaLibrary
.
MediaType
.
IMAGE
let
fileHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type1
.
toString
()],
}
let
fileNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
describe
(
'
favSmartAlbum.promise.test.js
'
,
function
()
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
path
=
"
Pictures/
"
var
media
=
mediaLibrary
.
getMediaLibrary
();
var
asset
;
var
favSmartAlbum
;
beforeAll
(
function
()
{
onsole
.
info
(
'
Smart Album Callback MediaLibraryTest: beforeAll.
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
Smart Album Callback MediaLibraryTest: beforeEach.
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
Smart Album Callback MediaLibraryTest: afterEach.
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
Smart Album Callback MediaLibraryTest: afterAll.
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_CALLBACK_001
* @tc.name : Get PrivateSmartAlbum by fav
* @tc.desc : Get PrivateSmartAlbum by fav
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_CALLBACK_001
'
,
0
,
async
function
(
done
)
{
asset
=
await
media
.
createAsset
(
mediaType
,
"
image0002.jpg
"
,
path
);
media
.
getPrivateAlbum
(
mediaLibrary
.
PrivateAlbumType
.
TYPE_FAVORITE
,
getPrivateAlbumCallBack
);
done
();
});
function
getPrivateAlbumCallBack
(
err
,
favSmartAlbums
)
{
if
(
favSmartAlbums
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbum favSmartAlbums
'
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK favSmartAlbums
'
+
favSmartAlbums
[
0
].
albumName
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK favSmartAlbums
'
+
favSmartAlbums
[
0
].
albumCapacity
);
favSmartAlbum
=
favSmartAlbums
[
0
];
favSmartAlbum
.
addAsset
(
asset
.
uri
,
addAssetCallBack
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbumCallBack Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbumCallBack : FAIL
'
);
done
();
}
}
function
addAssetCallBack
(
err
,
data
)
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK fav addAsset success
'
);
favSmartAlbum
.
getFileAssets
(
getFileAssetsCallBack
);
favSmartAlbum
.
removeAsset
(
asset
.
uri
,
removeAssetCallBack
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK addAssetCallBack Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK addAssetCallBack : FAIL
'
);
done
();
}
}
function
removeAssetCallBack
(
err
,
data
)
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK fav removeAsset success
'
);
favSmartAlbum
.
getFileAssets
(
getFileAssetsCallBack
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK removeAssetCallBack Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateremoveAssetCallBackAlbumCallBack : FAIL
'
);
done
();
}
}
function
getFileAssetsCallBack
(
err
,
fSmartFetchFileResult
)
{
if
(
fSmartFetchFileResult
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack Success fSmartFetchFileResult =
'
+
fSmartFetchFileResult
.
getCount
());
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack : FAIL
'
);
done
();
}
}
})
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestPromise.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
AlbumNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
let
AlbumHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
PATH
+
"
LIKE ?
"
,
selectionArgs
:
[
"
/data/media%
"
],
}
let
type1
=
mediaLibrary
.
MediaType
.
IMAGE
let
fileHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type1
.
toString
()],
}
let
fileNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
describe
(
'
favSmartAlbum.promise.test.js
'
,
function
()
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
path
=
"
Pictures/
"
var
media
=
mediaLibrary
.
getMediaLibrary
();
var
asset
;
var
favSmartAlbum
;
beforeAll
(
function
()
{
onsole
.
info
(
'
Smart Album Promise MediaLibraryTest: beforeAll.
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
Smart Album Promise MediaLibraryTest: beforeEach.
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
Smart Album Promise MediaLibraryTest: afterEach.
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
Smart Album Promise MediaLibraryTest: afterAll.
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001
* @tc.name : Get PrivateSmartAlbum by fav
* @tc.desc : Get PrivateSmartAlbum by fav
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001
'
,
0
,
async
function
(
done
)
{
asset
=
await
media
.
createAsset
(
mediaType
,
"
image002.jpg
"
,
path
);
const
favSmartAlbums
=
await
media
.
getPrivateAlbum
(
mediaLibrary
.
PrivateAlbumType
.
TYPE_FAVORITE
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum favSmartAlbums
'
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_PROMISE favSmartAlbums
'
+
favSmartAlbums
[
0
].
albumName
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_PROMISE favSmartAlbums
'
+
favSmartAlbums
[
0
].
albumCapacity
);
favSmartAlbum
=
favSmartAlbums
[
0
];
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002
* @tc.name : Add asset
* @tc.desc : Add asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002
'
,
0
,
async
function
(
done
)
{
await
favSmartAlbum
.
addAsset
(
asset
.
uri
);
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_PROMISE fav addAsset =
'
,
asset
.
uri
);
let
fSmartFetchFileResult
=
await
favSmartAlbum
.
getFileAssets
();
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_PROMISE getFileAssets Successfull fSmartFetchFileResult =
'
+
fSmartFetchFileResult
.
getCount
());
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003
* @tc.name : Remove asset
* @tc.desc : Remove asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003
'
,
0
,
async
function
(
done
)
{
await
favSmartAlbum
.
removeAsset
(
asset
.
uri
);
let
fSmartFetchFileResultNew
=
await
favSmartAlbum
.
getFileAssets
();
console
.
info
(
'
MediaLibraryTest : SMARTALBUM_PROMISE getFileAssets Successfull remove fSmartFetchFileResultNew =
'
+
fSmartFetchFileResultNew
.
getCount
());
await
media
.
deleteAsset
(
asset
.
uri
);
done
();
});
})
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestCallBack.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
AlbumNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
let
AlbumHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
PATH
+
"
LIKE ?
"
,
selectionArgs
:
[
"
/data/media%
"
],
}
let
type1
=
mediaLibrary
.
MediaType
.
IMAGE
let
fileHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type1
.
toString
()],
}
let
fileNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
describe
(
'
file.callback.test.js
'
,
function
()
{
var
asset
;
var
assetMove
;
var
media
=
mediaLibrary
.
getMediaLibrary
();
beforeAll
(
function
()
{
onsole
.
info
(
'
File Callback MediaLibraryTest: beforeAll.
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
File Callback MediaLibraryTest: beforeEach.
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
File Callback MediaLibraryTest: afterEach.
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
File Callback MediaLibraryTest: afterAll.
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001
* @tc.name : Create an asset in predefined path
* @tc.desc : Create an asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001
'
,
0
,
async
function
(
done
)
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
path
=
"
Pictures/
"
let
pathMove
=
"
Pictures/Move/
"
asset
=
await
media
.
createAsset
(
mediaType
,
"
image00001.jpg
"
,
path
);
assetMove
=
await
media
.
createAsset
(
mediaType
,
"
imageMove00001.jpg
"
,
pathMove
);
media
.
createAsset
(
mediaType
,
"
imageCallBack000001.jpg
"
,
path
,
createAssetCallBack
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002
* @tc.name : Modify asset
* @tc.desc : Modify asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002
'
,
0
,
async
function
(
done
)
{
asset
.
title
=
"
image00003
"
;
asset
.
relativePath
=
"
Pictures/Move/
"
;
asset
.
displayName
=
"
image00002.jpg
"
asset
.
commitModify
(
commitModifyCallBack
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_003
* @tc.name : Get assetList By NoArgsfetchOp
* @tc.desc : Get assetList By NoArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_003
'
,
0
,
async
function
(
done
)
{
media
.
getFileAssets
(
fileNoArgsfetchOp
,
getFileAssetsCallBack
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_004
* @tc.name : Get assetList By HasArgsfetchOp
* @tc.desc : Get assetList By HasArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_004
'
,
0
,
async
function
(
done
)
{
media
.
getFileAssets
(
fileHasArgsfetchOp
,
getFileAssetsCallBack
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005
* @tc.name : Open and Close asset
* @tc.desc : Open and Close asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005
'
,
0
,
async
function
(
done
)
{
asset
.
open
(
'
Rw
'
,
openCallBack
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_AND_TRA_ASSET_CALLBACK_006
* @tc.name : Favourite and Trash
* @tc.desc : Favourite and Trash
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_FAV_AND_TRA_ASSET_CALLBACK_006
'
,
0
,
async
function
(
done
)
{
asset
.
isFavorite
(
isFavoriteCallBack
);
asset
.
isTrash
(
isTrashCallBack
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DIR_ASSET_CALLBACK_007
* @tc.name : Favourite and Trash
* @tc.desc : Favourite and Trash
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_DIR_ASSET_CALLBACK_007
'
,
0
,
async
function
(
done
)
{
asset
.
isDirectory
(
isDirectoryCallBack
);
done
();
});
function
getAllObjectInfo
(
data
)
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK id is
'
+
data
.
id
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK uri is
'
+
data
.
uri
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK displayName is
'
+
data
.
displayName
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK mediaType is
'
+
data
.
title
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK relativePath is
'
+
data
.
relativePath
);
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK getAllObjectInfo no assets
'
);
}
}
function
createAssetCallBack
(
err
,
asset
)
{
if
(
asset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK createAsset Successfull
'
+
asset
.
uri
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK createAsset : PASS
'
);
media
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
,
getPublicDirectory
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK createAsset Unsuccessfull
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK createAsset : FAIL
'
);
done
();
}
}
function
getPublicDirectory
(
err
,
publicDirectory
)
{
if
(
publicDirectory
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK publicDirectory =
'
+
publicDirectory
);
media
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK publicDirectory Unsuccessfull =
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK publicDirectory : FAIL
'
);
done
();
}
}
function
commitModifyCallBack
(
err
,
commitModify
)
{
if
(
commitModify
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK commitModify success
'
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK commitModify Unsuccessfull =
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK commitModify : FAIL
'
);
done
();
}
}
function
getFileAssetsCallBack
(
err
,
fetchFileResult
)
{
if
(
fetchFileResult
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK fetchFileResult success
'
);
fetchFileResult
.
getAllObject
((
err1
,
data1
)
=>
{
if
(
data1
!=
undefined
)
{
data1
.
forEach
(
getAllObjectInfo
);
console
.
info
(
'
MediaLibraryTest : getAllObject :PASS
'
);
done
();
}
console
.
info
(
'
MediaLibraryTest : getFileAssets :No data
'
);
done
();
});
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK fetchFileResult Unsuccessfull =
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK fetchFileResult : FAIL
'
);
done
();
}
}
function
openCallBack
(
openError
,
fd
)
{
if
(
openError
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : open : FAIL
'
+
openError
.
message
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK : FAIL
'
);
}
console
.
info
(
"
==========================asset.open success=======================>
"
);
console
.
debug
(
"
open success fd =
"
+
JSON
.
stringify
(
fd
));
console
.
info
(
"
==========================asset.close begin=======================>
"
);
asset
.
close
(
fd
,
closeCallBack
);
console
.
info
(
"
==========================asset.close end=======================>
"
);
}
function
closeCallBack
(
closeErr
)
{
if
(
closeErr
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : close : FAIL
'
+
closeErr
.
message
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK : FAIL
'
);
}
console
.
info
(
"
==========================asset.close success=======================>
"
);
}
function
isDirectoryCallBack
(
err
,
isDirectory
)
{
if
(
isDirectory
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isDirectory =
'
+
isDirectory
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK isDirectory Unsuccessfull =
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK isDirectory : FAIL
'
);
done
();
}
}
function
favoriteCallBack
(
err
,
favorite
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK favorite
'
);
done
();
}
function
isFavoriteCallBack
(
err
,
isFavorite
)
{
if
(
isFavorite
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isFavorite =
'
+
isFavorite
);
asset
.
favorite
(
true
,
favoriteCallBack
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK isFavorite Unsuccessfull =
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK isFavorite : FAIL
'
);
done
();
}
}
function
trashCallBack
(
err
,
trash
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK trash
'
);
done
();
}
function
isTrashCallBack
(
err
,
isTrash
)
{
if
(
isTrash
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash =
'
+
isTrash
);
asset
.
trash
(
true
,
trashCallBack
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull =
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK isTrash : FAIL
'
);
done
();
}
}
function
deleteAssetCallBack
(
err
,
deleteAsset
)
{
if
(
deleteAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK deleteAssetCode =
'
+
deleteAsset
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK deleteAssetCode success
'
);
done
();
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK deleteAsset Unsuccessfull =
'
+
err
);
console
.
info
(
'
MediaLibraryTest : ASSET_CALLBACK deleteAsset : FAIL
'
);
done
();
}
}
})
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
AlbumNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
let
AlbumHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
PATH
+
"
LIKE ?
"
,
selectionArgs
:
[
"
/data/media%
"
],
}
let
type1
=
mediaLibrary
.
MediaType
.
IMAGE
let
fileHasArgsfetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type1
.
toString
()],
}
let
fileNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[],
}
describe
(
'
file.promise.test.js
'
,
function
()
{
var
asset
;
var
assetMove
;
var
media
=
mediaLibrary
.
getMediaLibrary
();
beforeAll
(
function
()
{
onsole
.
info
(
'
File Promise MediaLibraryTest: beforeAll.
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
File Promise MediaLibraryTest: beforeEach.
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
File Promise MediaLibraryTest: afterEach.
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
File Promise MediaLibraryTest: afterAll.
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001
* @tc.name : Create an asset in predefined path
* @tc.desc : Create an asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001
'
,
0
,
async
function
(
done
)
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
let
path
=
"
Pictures/
"
let
pathMove
=
"
Pictures/Move/
"
asset
=
await
media
.
createAsset
(
mediaType
,
"
image01.jpg
"
,
path
);
assetMove
=
await
media
.
createAsset
(
mediaType
,
"
image01Move.jpg
"
,
pathMove
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE asset.displayName =
'
+
asset
.
displayName
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE asset.displayName =
'
+
asset
.
title
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE assetMove.displayName =
'
+
assetMove
.
displayName
);
let
relativePath
=
await
media
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_IMAGE
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE relativePath =
'
+
relativePath
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_PROMISE_002
* @tc.name : Modify asset
* @tc.desc : Modify asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_PROMISE_002
'
,
0
,
async
function
(
done
)
{
asset
.
title
=
"
image03
"
;
asset
.
relativePath
=
"
Pictures/Move/
"
;
asset
.
displayName
=
"
image02.jpg
"
await
asset
.
commitModify
();
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ASSET_PROMISE_003
* @tc.name : Get assetList By NoArgsfetchOp
* @tc.desc : Get assetList By NoArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_ASSET_PROMISE_003
'
,
0
,
async
function
(
done
)
{
let
fetchFileResult
=
await
media
.
getFileAssets
(
fileNoArgsfetchOp
);
let
assetList
=
await
fetchFileResult
.
getAllObject
();
assetList
.
forEach
(
getAllObjectInfo
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ASSET_PROMISE_004
* @tc.name : Get assetList By HasArgsfetchOp
* @tc.desc : Get assetList By HasArgsfetchOp
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_ASSET_PROMISE_004
'
,
0
,
async
function
(
done
)
{
let
fetchFileResult
=
await
media
.
getFileAssets
(
fileHasArgsfetchOp
);
let
assetList
=
await
fetchFileResult
.
getAllObject
();
assetList
.
forEach
(
getAllObjectInfo
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005
* @tc.name : Open and Close asset
* @tc.desc : Open and Close asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005
'
,
0
,
async
function
(
done
)
{
asset
.
open
(
'
Rw
'
).
then
((
openError
,
fd
)
=>
{
if
(
openError
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : open : FAIL
'
+
openError
.
message
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE : FAIL
'
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
"
==========================fileAsset.open success=======================>
"
);
console
.
debug
(
"
open success fd =
"
+
JSON
.
stringify
(
fd
));
console
.
info
(
"
==========================fileAsset.close begin=======================>
"
);
fileAsset
.
close
(
fd
).
then
((
closeErr
)
=>
{
if
(
closeErr
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : close : FAIL
'
+
closeErr
.
message
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE : FAIL
'
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
"
==========================fileAsset.close success=======================>
"
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE : PASS
'
);
expect
(
true
).
assertTrue
();
});
console
.
info
(
"
==========================fileAsset.close end=======================>
"
);
});
console
.
info
(
"
==========================fileAsset.open end=======================>
"
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_AND_TRA_ASSET_PROMISE_006
* @tc.name : Favourite and Trash
* @tc.desc : Favourite and Trash
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_FAV_AND_TRA_ASSET_PROMISE_006
'
,
0
,
async
function
(
done
)
{
let
isDirectory
=
await
asset
.
isDirectory
();
let
isFavorite
=
await
asset
.
isFavorite
();
let
isTrash
=
await
asset
.
isTrash
();
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE isDirectory =
'
+
isDirectory
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE isFavorite =
'
+
isFavorite
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE Trash =
'
+
isTrash
);
await
asset
.
trash
(
true
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE favorite trash
'
);
await
asset
.
favorite
(
true
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE favorite success
'
);
let
isFavoriteChange
=
await
asset
.
isFavorite
();
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE isFavoriteChange =
'
+
isFavoriteChange
);
let
isTrashChange
=
await
asset
.
isTrash
();
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE isTrashChange =
'
+
isTrashChange
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DIR_ASSET_PROMISE_007
* @tc.name : Favourite and Trash
* @tc.desc : Favourite and Trash
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_DIR_ASSET_PROMISE_007
'
,
0
,
async
function
(
done
)
{
let
isDirectory
=
await
asset
.
isDirectory
();
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE isDirectory =
'
+
isDirectory
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_DELETE_ASSET_PROMISE_008
* @tc.name : Delete asset
* @tc.desc : Delete asset
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_DELETE_ASSET_PROMISE_008
'
,
0
,
async
function
(
done
)
{
await
media
.
deleteAsset
(
asset
.
uri
);
await
media
.
deleteAsset
(
assetMove
.
uri
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE DELETE SUCCESS
'
);
done
();
});
function
getAllObjectInfo
(
data
)
{
if
(
data
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE id is
'
+
data
.
id
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE uri is
'
+
data
.
uri
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE displayName is
'
+
data
.
displayName
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE mediaType is
'
+
data
.
title
);
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE relativePath is
'
+
data
.
relativePath
);
}
else
{
console
.
info
(
'
MediaLibraryTest : ASSET_PROMISE getAllObjectInfo no assets
'
);
}
}
})
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAlbumsPerformance.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
getAlbumsPerformance.test.js
'
,
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
let
times
=
25
;
let
AlbumNoArgsfetchOp
=
{
selections
:
""
,
selectionArgs
:
[
""
],
}
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
const
albumArray
=
await
media
.
getAlbums
(
AlbumNoArgsfetchOp
);
if
(
albumArray
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getAlbums : PASS
'
+
albumArray
.
length
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getAlbums : FAIL
'
);
expect
(
false
).
assertTrue
();
}
}
console
.
info
(
'
MediaLibraryTest : for : end
'
);
done
();
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 end
'
);
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
getFileAssetsPerformance.test.js
'
,
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
let
times
=
25
;
let
queryResultSet_
;
let
fileList_
;
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
type
=
mediaLibrary
.
MediaType
.
IMAGE
let
fetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type
.
toString
()],
order
:
fileKeyObj
.
DATE_ADDED
,
}
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01
* @tc.name : Create an image file asset in predefined path
* @tc.desc : Create an image file asset in predefined path
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
const
queryResultSet
=
await
media
.
getFileAssets
(
fetchOp
);
if
(
queryResultSet
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getFileAssets : PASS
'
+
queryResultSet
.
getCount
());
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getFileAssets : FAIL
'
);
expect
(
false
).
assertTrue
();
}
}
console
.
info
(
'
MediaLibraryTest : for : end
'
);
done
();
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01 end
'
);
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance_object.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
getFileAssetsPerformance_object.test.js
'
,
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
let
times
=
100
;
let
queryResultSet_
;
let
fileList_
;
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
type
=
mediaLibrary
.
MediaType
.
IMAGE
let
fetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type
.
toString
()],
order
:
fileKeyObj
.
DATE_ADDED
,
}
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
MediaLibraryTest : getFileAssets begin
'
);
const
queryResultSet
=
await
media
.
getFileAssets
(
fetchOp
);
queryResultSet_
=
queryResultSet
;
console
.
info
(
'
MediaLibraryTest : getFileAssets after
'
);
if
(
queryResultSet_
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
else
{
for
(
let
i
=
0
;
i
<
3
;
i
++
)
{
console
.
info
(
'
MediaLibraryTest : getAllObject begin :times:
'
+
i
);
const
data1
=
await
queryResultSet_
.
getAllObject
();
if
(
data1
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getAllObject :PASS times:
'
+
i
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getAllObject :FAIL times:
'
+
i
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
'
MediaLibraryTest : getAllObject after :times:
'
+
i
);
}
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01 end
'
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
if
(
queryResultSet_
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
else
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
console
.
info
(
'
MediaLibraryTest : getFirstObject begin :times:
'
+
i
);
const
fileAsset
=
await
queryResultSet_
.
getFirstObject
();
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getFirstObject :PASS times:
'
+
i
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getFirstObject :FAIL times:
'
+
i
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
'
MediaLibraryTest : getFirstObject after :times:
'
+
i
);
}
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01 end
'
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
if
(
queryResultSet_
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
else
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
console
.
info
(
'
MediaLibraryTest : isAfterLast begin :times:
'
+
i
);
const
isAfterLastBool
=
queryResultSet_
.
isAfterLast
();
expect
(
!
isAfterLastBool
).
assertTrue
();
console
.
info
(
'
MediaLibraryTest : isAfterLast after :times:
'
+
i
);
}
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01 end
'
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
if
(
queryResultSet_
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
else
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
console
.
info
(
'
MediaLibraryTest : getLastObject begin :times:
'
+
i
);
const
fileAsset
=
await
queryResultSet_
.
getLastObject
();
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getLastObject :PASS times:
'
+
i
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getLastObject :FAIL times:
'
+
i
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
'
MediaLibraryTest : getLastObject after :times:
'
+
i
);
}
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01 end
'
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
if
(
queryResultSet_
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
else
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
console
.
info
(
'
MediaLibraryTest : getPositionObject begin :times:
'
+
i
);
const
fileAsset
=
await
queryResultSet_
.
getPositionObject
(
i
);
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getPositionObject :PASS times:
'
+
i
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getPositionObject :FAIL times:
'
+
i
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
'
MediaLibraryTest : getPositionObject after :times:
'
+
i
);
}
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01 end
'
);
done
();
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
MediaLibraryTest : getFileAssets begin
'
);
const
queryResultSet
=
await
media
.
getFileAssets
(
fetchOp
);
console
.
info
(
'
MediaLibraryTest : getFileAssets after
'
);
if
(
queryResultSet
==
undefined
)
{
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
else
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
console
.
info
(
'
MediaLibraryTest : getNextObject begin :times:
'
+
i
);
const
fileAsset
=
await
queryResultSet
.
getNextObject
();
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getNextObject :PASS times:
'
+
i
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getNextObject :FAIL isAfterLast:
'
+
queryResultSet_
.
isAfterLast
());
console
.
info
(
'
MediaLibraryTest : getNextObject :FAIL times:
'
+
i
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
'
MediaLibraryTest : getNextObject after :times:
'
+
i
);
}
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01 end
'
);
done
();
});
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getMediaFileAssetStatus.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
let
fileKeyObj
=
mediaLibrary
.
FileKey
let
type
=
mediaLibrary
.
MediaType
.
IMAGE
let
fetchOp
=
{
selections
:
fileKeyObj
.
MEDIA_TYPE
+
"
= ?
"
,
selectionArgs
:
[
type
.
toString
()],
order
:
fileKeyObj
.
DATE_ADDED
,
}
describe
(
'
getMediaFileAssetStatus
'
,
function
()
{
console
.
info
(
"
MediaLibraryTest Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
MediaLibraryTest Instance after
"
);
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_01
* @tc.name : judge file asset trash or not
* @tc.desc : judge file asset trash or not
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_01
'
,
0
,
async
function
()
{
try
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
const
cur
=
Date
.
now
()
let
displayName
=
"
FILE_ASSETS_TRASH_STATUS_01.jpg
"
+
cur
;
let
rp
=
"
Pictures/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileAsset
)
=>
{
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull file uri =
'
+
fileAsset
.
uri
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS
'
);
fileAsset
.
isTrash
((
err
,
istrash
)
=>
{
console
.
info
(
"
MediaLibraryTest SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_01
"
+
istrash
)
expect
(
istrash
==
false
).
assertTrue
;
done
();
})
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
MediaLibraryTest has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_02
* @tc.name : judge file asset trash or not
* @tc.desc : judge file asset trash or not
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_02
'
,
0
,
async
function
()
{
try
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
const
cur
=
Date
.
now
()
let
displayName
=
"
FILE_ASSETS_TRASH_STATUS_02.jpg
"
+
cur
;
let
rp
=
"
Pictures/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileAsset
)
=>
{
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull file uri =
'
+
fileAsset
.
uri
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS
'
);
fileAsset
.
trash
(
true
,
(
err
)
=>
{
fileAsset
.
isTrash
((
err
,
istrash
)
=>
{
console
.
info
(
"
MediaLibraryTest SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_02
"
+
istrash
)
expect
(
istrash
==
true
).
assertTrue
;
done
();
})
})
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
MediaLibraryTest has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_03
* @tc.name : judge file asset trash or not
* @tc.desc : judge file asset trash or not
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_03
'
,
0
,
async
function
()
{
try
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
const
cur
=
Date
.
now
()
let
displayName
=
"
FILE_ASSETS_TRASH_STATUS_03.jpg
"
+
cur
;
let
rp
=
"
Pictures/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileAsset
)
=>
{
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull file uri =
'
+
fileAsset
.
uri
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS
'
);
fileAsset
.
trash
(
false
,
(
err
)
=>
{
fileAsset
.
isTrash
((
err
,
istrash
)
=>
{
console
.
info
(
"
MediaLibraryTest SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_03
"
+
istrash
)
expect
(
istrash
==
false
).
assertTrue
;
done
();
})
})
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
MediaLibraryTest has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_04
* @tc.name : judge file asset trash or not
* @tc.desc : judge file asset trash or not
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_04
'
,
0
,
async
function
()
{
try
{
let
mediaType
=
mediaLibrary
.
MediaType
.
IMAGE
;
const
cur
=
Date
.
now
()
let
displayName
=
"
FILE_ASSETS_TRASH_STATUS_03.jpg
"
+
cur
;
let
rp
=
"
Pictures/
"
;
console
.
info
(
'
MediaLibraryTest : createAsset begin
'
);
media
.
createAsset
(
mediaType
,
displayName
,
rp
,
(
createAssetErr
,
fileAsset
)
=>
{
if
(
fileAsset
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createAsset Successfull file uri =
'
+
fileAsset
.
uri
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS
'
);
fileAsset
.
trash
(
true
,
(
err
)
=>
{
fileAsset
.
isTrash
((
err
,
istrash
)
=>
{
console
.
info
(
"
SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_04 istrash
"
+
istrash
)
expect
(
istrash
==
false
).
assertFalse
;
done
();
})
})
}
else
{
console
.
info
(
'
MediaLibraryTest : createAsset Unsuccessfull
'
+
createAssetErr
.
message
);
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL
'
);
expect
(
false
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
MediaLibraryTest has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getPrivateAlbumsPerformance.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
getPrivateAlbumsPerformance.test.js
'
,
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
let
times
=
50
;
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
const
albums
=
await
media
.
getPrivateAlbum
(
mediaLibrary
.
PrivateAlbumType
.
TYPE_TRASH
);
if
(
albums
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : getAlbums : PASS
'
+
albums
[
0
].
albumName
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : getAlbums : FAIL
'
);
expect
(
false
).
assertTrue
();
}
}
console
.
info
(
'
MediaLibraryTest : for : end
'
);
done
();
});
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 end
'
);
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/smartAlbumOperatePerformance_object.test.js
0 → 100644
浏览文件 @
a9a2966e
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
smartAlbumOperatePerformance_object.test.js
'
,
async
function
()
{
console
.
info
(
"
mediaLibrary Instance before
"
);
const
media
=
mediaLibrary
.
getMediaLibrary
();
console
.
info
(
"
mediaLibrary Instance after
"
);
let
times
=
50
;
beforeAll
(
function
()
{
onsole
.
info
(
'
MediaLibraryTest: beforeAll
'
);
})
beforeEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: beforeEach
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterEach
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
MediaLibraryTest: afterAll
'
);
})
/*
* @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01
* @tc.name :
* @tc.desc :
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01 begin
'
);
it
(
'
SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01
'
,
0
,
async
function
(
done
)
{
for
(
let
i
=
0
;
i
<
times
;
i
++
)
{
console
.
info
(
'
MediaLibraryTest : createSmartAlbum begin :times:
'
+
i
);
const
smartAlbum
=
await
media
.
createSmartAlbum
(
"
laoxu886
"
);
if
(
smartAlbum
!=
undefined
)
{
console
.
info
(
'
MediaLibraryTest : createSmartAlbum albumuri
'
+
smartAlbum
.
albumUri
);
console
.
info
(
'
MediaLibraryTest : createSmartAlbum :PASS times:
'
+
i
);
expect
(
true
).
assertTrue
();
}
else
{
console
.
info
(
'
MediaLibraryTest : createSmartAlbum : FAIL
'
);
expect
(
false
).
assertTrue
();
}
console
.
info
(
'
MediaLibraryTest : createSmartAlbum after :times:
'
+
i
);
}
console
.
info
(
'
MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01 end
'
);
done
();
});
});
multimedia/medialibrary/mediaLibrary_js_standard/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
a9a2966e
{
"string"
:
[
{
"name"
:
"entry_MainAbility"
,
"value"
:
"MediaLibraryJSTestMain"
},
{
"name"
:
"mainability_description"
,
"value"
:
"MediaLibraryJSTestMain Ability"
}
]
}
\ No newline at end of file
multimedia/medialibrary/mediaLibrary_js_standard/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
a9a2966e
6.6 KB
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录